Raspberry Pi Electricity Monitor


Created by: jps

Published May. 29, 2013

I’ve built a system for monitoring the electricity consumption of my home with a Raspberry Pi. Full write up at http://unop.co.uk/

I bought a wireless electricity monitor from Maplin. It’s one of the standard affairs which has a transmitter with a current clamp that you put around the main in-feed and a portable display unit. However, this unit has a serial connection (accessible via an RJ45 socket) which allows you to download live and historic data to a PC.

There are limitations though; the on-board memory only stores daily totals and the windows software that comes with it is awful. So I reverse engineered the communication protocol and built my own logger. A Raspberry Pi was a great choice for the host machine as it would be far too ironic to leave a power hungry PC on to monitor electricity consumption. I have a plug in power meter and have measured the draw of the whole system as negligible (barely a few watts). Here is the whole system (the Pi and receiver obviously don’t always have to be next to the transmitter). The cable was excessively long so I shortened it by crimping on a new plug.

Parts list (hardware):

  • Maplin wireless electricity monitor
  • Raspberry Pi
  • Micro USB power supply
  • SD card (mine is 32GB high speed but 2GB would be fine)
  • WiFi adapter (optional; you could just plug it into your router)
  • Case (optional; but it looks nice and stops shorts)


How to get up and running:

  • Install the Apache web server with apt  (sudo apt-get install apache2)
  • Install http://pyserial.sourceforge.net/ with apt (sudo apt-get install python-serial)
  • Download the repository from github (https://github.com/jpsingleton/Raspberry-Pi-Electricity-Monitor)
  • Copy the www folder to /var/www
  • Copy the python file to anywhere you want (e.g. home folder)
  • Plug in the receiver (the USB serial driver should already be present)
  • Execute “sudo python raspberry-pi-electricity-monitor.py &” (add this to /etc/rc.local to run at boot)
  • Visit your Pi in a browser to see the data (visit raw.html to see the noisy data)

The system has a sample period of 7 seconds as the transmitter only broadcasts this often to save power. This still results in far too much data to render (after a few days) so the software filters out the noise to reduce the data points. Future plans include using the ADC and micro-controller on my self assembled Gertboard with my new Pi to achieve a much higher sample frequency.

Thanks to http://dygraphs.com/ for an awesome library and http://www.raspberrypi.org/ for the great hardware.

P.S. The dygraphs library is also used at shutdownscanner.com (which is a service for monitoring how many computers have been left on out of hours). If you want to play with the interactive features of the graphs or see some of the more advanced interface options then take a look at the example dashboard.

Related categories: Web


comments powered by Disqus