Raspberry Pi BTMon.py Setup Guide
Posted: Fri Jun 24, 2016 11:38 am
BTMon.py Raspberry Pi Setup Guide
Updates:
2016-06-24: created initial guide.
This guide assumes a Raspberry Pi or other system is already setup and running EmonCMS. If you haven't previously setup a system, please start with the guide below.
viewtopic.php?f=40&t=1567
Required downloads
- PuTTy or equivalent SSH program http://www.chiark.greenend.org.uk/~sgtatham/putty/.
Installing BTMon
Steps:
NOTE: You may copy and paste the command line information from this guide into PuTTy.
1. Go to your home folder.
2. Download the latest version of BTMon.
3. Create a configuration file for BTMon, replace TOKEN with the API Key copied above and the NODE_NAME with whatever you want it labelled as. In this example, we'll be using BTMon in Server mode. Change device_type to ecm1240 is using an ECM-1240 and not a GEM.
Energy Monitor running as TCP Client
a. Copy/paste the following code. Change ip_port to whatever port the GEM is configured to send to.
Energy Monitor using Serial-to-USB Cable
a. Download and install PySerial (this link may change, if below doesn't work check https://pypi.python.org/pypi/pyserial for a new link and replace the string following wget).
b. Plug in the Serial-to-USB cable and find out how it's been assigned.
c. Take the value from above and run the command below, replace "ttyUSB#" with the value found above. Change serial baud to 19200 if using an ECM-1240.
4. Start BTMon to test.
Starting on boot
Steps
1. Run the following command.
Updates:
2016-06-24: created initial guide.
This guide assumes a Raspberry Pi or other system is already setup and running EmonCMS. If you haven't previously setup a system, please start with the guide below.
viewtopic.php?f=40&t=1567
Required downloads
- PuTTy or equivalent SSH program http://www.chiark.greenend.org.uk/~sgtatham/putty/.
Installing BTMon
Steps:
NOTE: You may copy and paste the command line information from this guide into PuTTy.
1. Go to your home folder.
Code: Select all
cd /home/pi
Code: Select all
sudo wget https://raw.githubusercontent.com/matthewwall/mtools/master/bin/btmon.py
Energy Monitor running as TCP Client
a. Copy/paste the following code. Change ip_port to whatever port the GEM is configured to send to.
Code: Select all
printf "[source]\ndevice_type = gem\nip_read = true\nip_port = 8000\nip_mode = server\n[oem]\noem_out = true\noem_token = TOKEN\noem_url = http://localhost/emoncms/input/post.json\noem_node = NODE_NAME" > btmon.cfg
a. Download and install PySerial (this link may change, if below doesn't work check https://pypi.python.org/pypi/pyserial for a new link and replace the string following wget).
Code: Select all
wget https://pypi.python.org/packages/3c/d8/a9fa247ca60b02b3bebbd61766b4f321393b57b13c53b18f6f62cf172c08/pyserial-3.1.1.tar.gz#md5=2f72100de3e410b36d575e12e82e9d27
sudo tar xvf pyserial-3.1.1.tar.gz
cd pyserial-3.1.1
sudo python setup.py install
cd ..
sudo rm -R pyserial*
Code: Select all
dmesg | grep -Eio "ttyUSB[0-9]+"
Code: Select all
printf "[source]\ndevice_type = gem\nserial_read = true\nserial_port = /dev/ttyUSB#\nserial_baud = 115200\n[oem]\noem_out = true\noem_token = TOKEN\noem_url = http://localhost/emoncms/input/post.json\noem_node = NODE_NAME" > btmon.cfg
Code: Select all
sudo python btmon.py -c btmon.cfg --debug
Steps
1. Run the following command.
Code: Select all
sudo sed -i 's:exit 0:python /home/pi/btmon\.py -c /home/pi/btmon\.cfg \&\nexit 0:' /etc/rc.local