Arduino based Electricity monitor 8

Over the past 12 months or so I’ve been looking to add various “Smart House” components to my home, rather than do this in the traditional sense of buying something off-the-shelf I’ve been experimenting and building my own. One of the real plus points in me doing this is that all the data that is passed around is in an open standard and format chosen by me, not some cludge to try and extract information in a format decided by a-n-other manufacturer.

This post will cover the process I’ve gone through to build an Arduino based energy monitor, in the first instance this is only monitoring electricity usage

First step was to look at what information I could glean from the meter itself, there are a number of ways to extract information here, a clamp which sits around the wire between the meter and the consumer unit:

IMAG0525

The other ways generally involve retrieving a pulse of some kind from the meter, either via a screw in terminal which sends a pulse over wire or a flashing LED. In my case it was a flashing LED as you can see in the following image.

IMAG0518

This LED sends out a pulse every time a watt is used, or for monetary conversion 1000 for every kilowatt used. So knowing this I could create a device to read these flashes and convert them into usable data.

arduino-energymon

 

The configuration of the above circuit is really simple, a TSL261 Light to Voltage sensor connected to an arduino with an ethernet shield.

How to connect the TSL261
looking at the component, the sensor will have a raised part above it, this is the front. Front the front the pins run from left to right, pin 1 being GND, pin 2 V+ and pin 3 output. In my circuit I connected the voltage and ground appropriately (3v) and attached the output to digital pin 2.

TSL261

My current incarnation has pins soldered to one end of a length of wire and the sensor the other (I used strands from CAT5e cable) to allow me to position the arduino then attach the sensor to the front of the electric meter, the attachment was a complicated process of sticking with some trusty old duct tape. I still need to get some heat shrink tubing to ensure the pins don’t short but it’s ok for now.

meter-mon-on

While researching this project I found this site, http://www.airsensor.co.uk/component/zoo/item/energy-monitor.html which took the data collected and stored it in a file on the SD card. This wasn’t exactly what I was looking for as I wanted to graph the data preferably from a live feed. I thought the best way to do this was to utilise one of my favourite current tools which I use in a lot of my other projects MQTT, I wanted the arduino to simple detect a pulse and send out information which I could retrieve on any device subscribed to a particular topic. More research led me to a page Nicegear¬†where I found Hadley Rich doing pretty much exactly what I was looking for, his Arduino sketch created an output on a particular MQTT topic when a pulse was detected, but to top this he had also created a function to output the current watt usage every second. This proved to be more useful than the original idea of outputting the pulse on detection.

You can find the sketch at Hadleys website, or on my GitHub page. The only real difference between his sketch and the one on my arduino is the count of LED flashes per kWh, his needs to flash 1600 per kWh mine flashes 1000, or 1watt per flash.

So subscribing to the topic
house/power/meter/1/current would recieve a number of watts currently being used

mqtt-current

or topic
house/power/meter/1/usage
would output a 1 everytime a pulse occurred.

mqtt-usage

Now what to do with this data?
My plan was to graph the data so had to figure some way of getting this data into a graphing application or service. More research ensued, Graphite/Carbon seems to be an ideal choice to pursue but at this point in time haven’t got anything functional. A lot of posts around the internet suggest the use of pachube, which became cosm which then became xively. Using a python script to listen to the mqtt topic usage and pipe to the xively API I ended up with a nice graph.

enmon1

You can see my live feed here, xively.com/feeds/73975854

All in all, I’m really pleased with this project. It’s still rough around the edges in places, both physically and software wise. I’d like to move the project to an Arduino mini pro with one of the smaller ethernet shields and have a nice box to house it. Get a graphite instance working and retrieving the data. First on the next steps list however is to try and extract the same information from the gas meter, I believe there is a pulse output on the front of the meter but this will require some more research so watch this space.

 

8 thoughts on “Arduino based Electricity monitor

  1. Reply Laura Hill Apr 21,2014 10:13 am

    Heh,

    No project is complete without the use of duct tape :) Reading your post I just had a thought about data sampling, to conserve power, I wonder if it would be possible to monitor LED flashs for 1 minute every ten minutes, to be more energy efficient, that still leaves wifi….

    We actually created a similar real time graphing system to yours:
    http://www.sqldashboards.com/b/real-time-charting-electrical-sensor-data/

    • Reply Jon Archer Apr 21,2014 10:17 pm

      I like your idea of conserving power, but as this is running on an Arduino it really doesn’t consume a worrying amount. Besides there are 2 feeds of data coming out, a real time pulse into MQTT and the current usage, the real time pulse repeat will actually need the device to be on all the time.

      I’ve moved on slightly from when I created this post, I’ve now got the pulses logging into a mysql database which creates a precise count (similar to the meter reading). I’m also using the data inside Open HAB, a home automation control system I am prototyping.

      With regard to duct tape, you should see my nature cam. It’s waterproof by duct tape ;)

  2. Reply Ben Jones Jul 6,2014 8:05 pm

    Hi Jon,

    Nice project. Always interesting to hear how others are using openHAB. Have you come across Open Energy Monitor (in the UK)? I am about to dive into one of their designs myself. It is all open source and designed for Arduino and RPis. Some pretty clever stuff going on there if you are interested.

    Cheers,
    Ben

    • Reply Jon Archer Jul 7,2014 11:41 am

      Hi Ben,
      Thanks, appreciate you taking the time to read it. It’s been a really interesting project and lovely to work with an MQTT data feed, I’ve had it displaying in all sorts of forms since I wrote this post and also logging to a MySQL database (I’d like to switch that to Mongo though). I have looked at Open Energy Monitor which looks a fab project, got a simple demo system up and running on a Pi. I’m looking to extend the monitoring to the Gas meter as I mentioned, but also temperatures across the house, using Arduino’s and a string of Dallas one-wire thermometers.
      I have so many plans in my head, it’s just finding the time to implement them.

  3. Pingback: Electricity Monitoring with a Light-to-Voltage Sensor, MQTT and some Duct Tape

  4. Pingback: Electricity Monitoring with a Light-to-Voltage Sensor, MQTT and some Duct Tape - RaspberryPiBoards

  5. Pingback: Electricity Monitoring with a Light-to-Voltage Sensor, MQTT and some Duct Tape | Orange Claymore Red Slime

  6. Pingback: Electricity Monitoring with a Light-to-Voltage Sensor, MQTT and some Duct Tape | Ad Pub

Leave a Reply