Monitoring electricity usage at home
I wanted to gather statistic about the electricity usage at my new house, mainly to see how much using the fireplace lowers the bill. The meter installed by the utility company has a led that blinks at the speed that is relative to the usage. Text on the meter says that 480 blinks equals 1 kWh used. I thought that building a device that keeps count of these blinks should be easy enough to make. I used photoresistor attached on top of the led with blu-tack. This way the measuring circuit is isolated from the mains and the setup doesn’t require tampering with the meter. The led on the meter is not very bright, so the circuit is quite sensitive to ambient light, but works reliably when the cabinet enclosing the meter is kept closed.
Measurer
The schematic for the device is quite simple:
Currently I’m using XBee to communicate with the server which gathers the measurements. The meter itself is at the utility room, which is too far to run cables to. I’ve already bought XBee pinout compatible wlan transmitter to get rid of the XBee eventually.
In the circuit, analog part on the left turns value of photoresistor (R3) to digital signal read by ATtiny2313. Sensitivity of the photoresistor is changed with the variable resistor R5. The avr responds to two commands (in current code “LUKU” and “VALI” translation would be “COUNT” and “INTERVAL”). Count simply returns number of blinks since the last count command. When read periodically, electricity usage can be calculated from the number of blinks and the time used to count them. Second command returns the time between two last blinks, so current consumption can be calculated from that.
I’d like to show the picture of the setup, but currently I’m using circuit boards from the past projects, one has the avr and the other contains the XBee, so the setup is quite messy. I’ll create custom PCB as soon as I get the wlan transmitter working. The attached AVR code is also quite messy and currently compiles to ATmega8. It could be easily ported to ex. Arduino if needed.
Server
The server part consists of two scripts. Measurer.py runs constantly and queries the device every 5 minutes and records the consumption to sqlite database together with temperature, which is parsed from the web page provided by local university. It also provides unix socket for the second script to query current consumption and temperature.
The second script, show_graph.py is meant to be run by web server. It returns graph about the usage and the temperature as png picture. Cgi parameters (to, from, interval) can be used to get graph about specific time period. Interval is used to set time in minutes for how long period of measurements are averaged. I’ve found it useful in winter time to average measurements for at least an hour, because on shorter periods consumption varies greatly based on how many heaters are running at the time. The variance makes it hard to understand what is going on and to compare the usage.
Files
All project files are available at Gitorious: https://gitorious.org/home-automation/home-automation
Related post
Wall display for showing the graph: http://antibore.wordpress.com/2012/03/05/info-display-for-home/


Do you have photos of the project?
Very cool. I had an Itron meter w/ an IR pulse out the top (one pulse per watt-hour) and was monitoring that way for a while. It was on a south wall, and had serious issues with daylight; I put a black rubber shade/hood over it, and it worked fine.
After I went solar and got a net meter, the IR pulse went away, and I had to construct a CT-based monitor. Was fun while it lasted
This is sweet… would love to make one of these. Could you please approximate the overall cost of the entire build ? Including the programming board or whatever it is used to program the IC, the XBee, the display, everything… thanks !
Thanks for the interest. Avr and analog parts cost about 5€. Currently the most expensive part is the XBee, about 20€ and you need two of these. I planned to replace those with
RN-XV WiFly Module, which costs 30€ and then I could read the measurements via wlan and eliminate XBee receiver.
Another option would be to use Raspberry Pi, when it becomes available. You could easily connect Avr to it and add wlan usb-stick for under 50€ for the whole set. Then you wouldn’t even need the separate server at all, since the raspberry could record measurements and generate graphs.
for some slicker looking graphs I would suggest using rrdtool. that’s what i would have used in any case.
Thanks. Finding a suitable graph lib was a major headache. I got Matplotlib to do what I want, but it’s not exactly beautiful and definitely not the easiest to use.
@antibore: “The led on the meter is not very bright, so the circuit is quite sensitive to ambient light…” Have you considered a differential circuit, with one photoresistor simply measuring the ambient light?
Very good idea. Currently I’m able to keep the cabinet closed, so ambient light is not a problem for me, but if someone wants to build this for outside meter, something like that could be usable (In addition to changing the photoresistor to phototransistor).