I wanted to see if I could use an Arduino to monitor my Electricity and Gas usage. Reading up on how most meters have a ‘pulse’ I was able to put together a sensor hooked up to the Arduino to monitor my electricity meter.
Following this I then passed said details back to my Vera on which I put write a short llup plugin to receive the kwh values.
Well, I’m new to Vera, but my Arduino among other things, is polling my electric meter pulses, too. I like the control the Arduino gives - such as real-time meter readings. See here: [url=http://www.sdyoung.com/home/home-status/how-i-monitor-my-smart-meter/]http://www.sdyoung.com/home/home-status/how-i-monitor-my-smart-meter/[/url].
I’ve only just begun the Vera integration but I’ve set up the Arduino to send a JSON response with the current real-time watts in use by adding this to the code:
The [font=courier]kwNow.print(sum * 60);[/font] takes the number of pulses in the last rolling 60 seconds and multiplies them by 60 (minutes per hour) for the (if things stayed the same for an hour) kilowatt hours that would be consumed in 60 minutes. In other words, for the first 60 seconds the Arduino is on it’s is still building up a 60 second buffer. Say it took in 10 pulses in that 60 seconds. For my Itron meter, that translates to 10 watts. If that was a constant I would have consumed 600 watts, or 0.6 kW in one hour. Then it rolls to second 61 and the buffer still contains 60 seconds of pulses, just now they are from second 1 to 61. This repeats ad nauseum. The full code is in the link above (too lazy to chop it down so you have to weed through the other routines going on).
The Vera polls the Arduino HTTP interface periodically for the kwNow JSON but I’m still working out what exactly I want Vera to do with the data.
You’ll be OK since your meter looks to be indoors, but using an analog pin and comparing the pulse intensity against a static value to determine if a pulse was generated/legitimate on an outdoor meter won’t work. The stray light will double-pump some pulses and if the meter is in direct, unshaded light, it will erratically trigger above the threshold you defined. Ask me how I know. The better solution is to use interrupts on a digital pin. My meter is in morning sunlight from sunrise until about 11 or 12, but between 8 and 9 it gets hit with light at such a sharp angle that it caused me all sorts of trouble accurately registering. That’s when Nick on the Arduino forums schooled me on interrupts [url=http://gammon.com.au/interrupts]http://gammon.com.au/interrupts[/url]. Not only is it reliable, but the code is simpler, too!
Best Home Automation shopping experience. Shop at Ezlo!