Connecting your electricity meter to Pachube

Here's a quick and cheap way to connect your electricity meter to Pachube, in order to embed graphs in webpages, to monitor it from afar, or just to show others what your consumption is. It uses an Arduino and a 'reflective object sensor'. This works on those UK meters that have a visible spinning disk; you will notice that the disk has a black stripe -- our sensor is going to measure how quickly that disk is spinning, which is proportional to the current power consumption. It may work in other countries that have the same type of visible disk; and you could get this to work using a meter with a flashing LED too. Of course, with an ethernet shield it's then pretty straightforward to connect your electricity meter to Pachube.

See it in action here: http://www.pachube.com/feeds/504

(1) Power in Watts; (2) Power averaged over 15 minutes

First, check that your meter has a spinning disk and a black stripe. It might look something a little like this:

Then make sure you can find out how the disk is callibrated. On mine it said "200 revs per kWh". So I knew that if I could measure the time between black stripes (i.e. disk revolutions), then I could work out how many kilowatts are being used at any particular time:

To detect the stripes, I used a 'reflective object sensor' which you can find at RS here: http://uk.rs-online.com/web/search/searchBrowseAction.html?method=getPro...

and then stuck it on using bluetack. This is probably the most difficult part, because you have to get it pointing in exactly the right direction so that it hits the disk and the disk reflects back to the sensor -- not too high, not too low.

This was wired up according to the following diagram (thanks to Chris Leung for resistor values):

The Arduino reads the analog value from the signal -- you could tweak for hours to get the resistors exactly right so that you get a definite high (when the black stripe is present) and a definite low (when not present), but instead I just looked at the analog values coming in from the signal pin and then determined (by comparing averages) when there has been a sudden change. I also power the sensor using a pin so that I can switch it on and off, rather than powering it straight from the 5v supply. I did this because I found the signal level was wandering quite a bit when the transistor side of the sensor was permanently powered. So instead, I power on the sensor for about 50 ms, then check the value and process it, then switch off for 50 ms.

You need to make sure you have a definite difference in the values (mine were around 300 when no stripe was present; and around 400 when it was present so I look for a change in average about 1.1) and if there is not, then the sensor is not oriented correctly.

After determining the number of seconds since the last stripe (interval), and taking our value for "revolutions per kWh" (which was 200 in my case), we can work out the current power consumption using the following:

currentPower = (3600 / interval) / revsPerkWh;

(the 3600 is the number of seconds in an hour).

Although, in my code I used the following:

currentPower = (1000.0 * 3600000.0 / interval) / revsPerkWh;

where I used 3600000 as the number of *milliseconds* in a hour; and I multiply by 1000 again because I am interested in the number W (watts) rather than kW (kilowatts).

Attached here: http://community.pachube.com/files/officeSensorsExample.zip is the original Arduino 11 code. This makes use of http://www.nuelectronics.com/estore/?p=14 the NuElectronics ethernet shield, though any other shield can also be used, for serving these values to Pachube and includes values for a temperature sensor, humidity sensor and light sensor.

AttachmentSize
officeSensorsExample.zip5.17 KB

Re: Connecting your electricity meter to Pachube

Hi There!

I'm doing something similar, but using an Optek OPB705. I found that orientation of the sensor is critical to getting good results. By aligning the sensor vertically I get a much larger difference in reading than when it was horizontal... Strange but true.