To
use power measurements from an emonTX and rfm12pi with Python:
The modules from openenergymonitor.org are great but getting them working is not easy. Hopefully this will help -
- Purchase an rfm12pi, a current transformer (or three) and an emonTX kit, solder the emonTX together and upload your chosen firmware to it.
- Plug the current transformer into the emonTX, clamp it around a neutral or live cable and power the emonTX.
On the Raspberry Pi -
- sudo nano /boot/cmdline.txt
and remove the line
console=ttyAMA0,115200 kgdboc=ttyAMA0,115200
- sudo nano /etc/inittab
remove the line towards the bottom
T0:23:respawn:/sbin/getty -L ttyAMA0 115200 vt100
- install Python Serial:
sudo apt-get install python-serial
- Plug the rfm12pi onto the Raspberry Pi

- The output from the emonTX is something like:
10 201 1 25 0 28 0 4 13
which is the node number, CT1, CT2, CT3 and tempreature in the form of:
10 201+(1*256) 25+(0*256) 28+(0*256) 4+(13*256)
And the serial connection between the RFM12pi uses port /dev/ttyAMA0 at 9600 kbps
So running a Python script somthing like the following should give you some meaningful output:
#! /usr/bin/python
# serial monitor for emonTX (current only) plus RFM12pi
import serial
# setup the serial port
ser = serial.Serial("/dev/ttyAMA0", 9600)
ser.bytesize = serial.EIGHTBITS
ser.parity = serial.PARITY_NONE
ser.stopbits = ser.STOPBITS.count(1)
ser.timeout = 10
while True:
ser.open()
c = ser.readline()
try:
c = bytes.decode(c)
except:
c = 'Decode Error'
# print the whole thing
print (c)
# work out the (apparent) power and print it
n = c.split(" ")
power = int(n[2])+(256*int(n[3]))
print "Apparent Power = ", str(power)
print ""
ser.close()
- Calibration ? must look into it.
- Clock with power monitor ... work in progress.