Home > Electronics > Monitoring electricity usage at home

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.


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.


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.

Example output with 2h average


All project files are available at Github: https://github.com/JanneMantyharju/electricity-monitor

Related post

Wall display for showing the graph: https://antibore.wordpress.com/2012/03/05/info-display-for-home/

Categories: Electronics Tags: ,
  1. 07/03/2012 at 01:23

    Do you have photos of the project?

  2. 07/03/2012 at 02:31

    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 ;)

  3. 07/03/2012 at 10:51

    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 !

    • 07/03/2012 at 11:18

      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.

  4. Anonymous
    07/03/2012 at 13:20

    for some slicker looking graphs I would suggest using rrdtool. that’s what i would have used in any case.

    • 07/03/2012 at 13:31

      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.

  5. Robert Poor
    29/04/2012 at 08:30

    @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?

    • 10/05/2012 at 13:52

      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).

  1. 07/03/2012 at 01:02
  2. 07/03/2012 at 01:06
  3. 07/03/2012 at 01:29
  4. 07/03/2012 at 01:52
  5. 07/03/2012 at 08:04
  6. 11/03/2012 at 02:14
  7. 15/03/2012 at 19:14
  8. 15/03/2012 at 20:52
  9. 29/08/2012 at 20:53
  10. 06/10/2012 at 12:42
  11. 18/12/2012 at 10:47

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


Get every new post delivered to your Inbox.

Join 30 other followers

%d bloggers like this: