Simple DIY Power Monitoring System

Share it!

Background Info

In the fall of 2008, Portland General Electric (PGE) replaced our electric meter with a new smart electric meter. When I asked the PGE guy at the time if I could have access to the data from the electric meter, he told me that in about a year it would probably be possible.

Time has passed and we received a letter from PGE last month (Aug 2012) that our daily electric usage would now be available from our account at the PGE website, When you login to your account, you will see a section called ‘Energy Tracker’ in the lower right hand side of the screen. Apparently, PGE subcontracted the project to a company called Aclara Technologies. Category charts that break down the energy usage by category is bogus, because there is no possible way for them to know where or how the power is used. :) . However, the charts are helpful to see how much energy is used daily. Remember that the data is rounded up/down, or averaged, it is not raw data. And during that process, lot of the details are lost.

PGE could have set up an opt-in system where people who are interested could sign up to a program where their electric usage could be emailed to them hourly/daily/weekly. It would have been much more useful then. I think the best way to access energy usage would be if the electric meter provided a little socket on the side (electrical or optical) where users could plug in their own power monitoring system.

From the charts on the PGE site, I could see that we were using most days about 30 KW hour per day, on some days as much as 45 KW hour. I don’t know if this is typical. But I wanted to know in real-time how the energy was used in our house.

When I researched the power monitoring systems, I found out that the cost was anywhere from $300 to about $1000 and more. But, if you google for ‘DIY electric power meter’, you can see that it is possible to build a power monitoring system with a little bit of work at a very low cost.

NOTE: I used ideas from many other posts in this project.

Interfacing to Smart Electric Meter

The new electric meter has an interesting feature where an infrared (IR) LED sends out a pulse per each watt hour used, however since these pulses are in infrared, they are not visible to naked eye.

Radio Shack sells an IR photo transistor (=IR sensor) for $2. It looks just like an ultra bright clear LED. In fact, if they were mixed in, probably you could not tell which one is which.

I connected my voltmeter (DVM) to see the pulses, but there was absolutely nothing. After a little bit of testing on the bench with IR LEDs and IR sensors, I noticed two things:

  • IR transmitter and IR sensor alignment is critical (they both need to be on a perfect line),
  • IR transmitter and IR sensor need to be as close as possible.

To mount the IR sensor accurately, first I took a picture of the meter, printed it on a printer so the picture is 1 to 1 scale, and used the picture as a guide to make a hole on the Tupperware bowl for the IR sensor.

smart meterIR LED location

I used the following circuit for testing. The pulse was very feeble, but clearly visible on the oscilloscope. Each pulse lasted about 0.8 seconds, which explained why the voltmeter did not detect it. It was a very short pulse. Note: the width becomes shorter as more energy is used. The second generic NPN transistor amplified the signal. Update: put a limiting resistor of 470 ohms in series with the ultra bright LED diode.

circuit1Circuit to test and use with ultra bright LED

Left over bell wire from our garage door opener was used to bring the signal into my room, but shielded wire would be better to prevent noise from power lines.

The setup explained above worked great except in the afternoons. The electric meter in our case is installed on the garage wall facing west. This created a very big problem. When the sun shined on the meter, the signal would be washed off. The picture below shows how the signal levels change with sun light.

sunlightSunlight Problem

The chart at the top shows the signal at night and daytime without sunlight on the meter. In that case the voltage mostly stayed around 1 volts and the pulse would go as high as 5 to 7 volts. The chart at the bottom shows the signal when sunlight hit the meter. The signal would stay at about 5 volts and the pulse voltage would go to 6 or 7 volts.

To prevent any light going into the meter, I wrapped black plastic around the meter. However, this did not make any difference at all. Later I realized that this was because although the visible light was blocked, the plastic was getting hot, and emitting infrared light into the meter.

When I put a large enough cardboard box around the whole meter, the afternoon problem was fixed. The next morning on 08/21 when I checked on PGE website for the power usage for 08/20, the message said that the data for 08/20 was missing. Damn! I thought cell phone signals would go right through the cardboard box, but somehow it did not in this case.

I removed the cardboard box, and when I checked the next day on 08/22, the data was received, but because of a bug in the Aclara system, it was applied to 08/20, and now the message said that the data was missing for 08/21. Missing data is not properly handled by the Aclara system.

LED Power Monitor Schematic

The schematic above shows the circuit I used to get the ultra bright LED to pulse as the signals from the electric meter are received. The electrolytic capacitor is used to partly filter out the DC component of the input signal from the meter.


Most of the time the LED was blinking at a background rate of once per several seconds. Surprisingly this rate did not seem to change even in the evening when we turned on the lights and the TV.

However, the toaster was very noticeable, almost once per second. I also thought that the clothes washer would use up lot of power, but apparently not, because I did not notice any change in the rate when the washer was turned on.

The clothes dryer used so much power that the LED was blinking maybe twice per second? The same goes for the electric oven.

The system is working very well. In one case I noticed that there were a few extra rapid pulses against the backdrop of steady rate of pulses. I thought something was wrong with the system. But later I realized that there was tea on the electric stove set to LOW setting, and every time the heating element came on for a few seconds every minute or so, extra few pulses were generated, and that is what I was noticing.

Up to this point, it has been a fairly simple project. Although not as simple, it is possible to connect this signal to the computer with much better results. In the rest of this post, I give some pointers on how to do that.

Connecting to a Computer – Hardware

To access these pulses from the computer, I used another photo transistor. Infrared or visible light, both work fine. Parallel port pin 13 is the ACK signal from the printer into the computer, and pin 25 is the ground. There is an internal pull-up resistor, so you can connect the photo transistor directly to pin 13 and pin 25. There is only two way to connect it. For NPN type transistor, emitter should be connected to the ground. If the photo transistor is connected the wrong way, LPT port will not sense the signal, but the photo transistor will not be damaged. Photo transistor should be lined up with the ultra bright LED mentioned earlier.

Connecting to a Computer – Software

Going through every step of the software set up would take a very long time, so I will describe it broadly here, and you can fill in the blanks.

What we want to do is to measure the time between pulses to millisecond accuracy. To digress for a moment, lets say everything in the house is turned off, except for a 60 watt light bulb. We would then get one pulse per minute (= 60 watt hours). If we turn on another 60 watt light bulb on, we would get one pulse per 30 seconds. So the formula to calculate how much energy we are using per hour is P = 3600 * 1000 / T (in milliseconds, P in watt-hours).

Normally we would use a real time interrupt driven system to setup a system like this, but I was not able to do that. There is a time.h structure that gives you micro second access, but I didn’t go that route either. What I did is that I used a kernel module that gave me access to millisecond counter in the kernel through the /proc interface (jiffies). In fact the time.h structure info is derived from jiffies (AFAIK). Getting /proc/jiffies through a loadable kernel module is the first step.

Parallel port provides 4 input lines, one of which is inverted. We are using the ACK line here, but any other input line would work just fine. An example of how to access parallel port input lines is available from my earlier post titled EPROM reader.

The output of this program will look like this:

2012/10/04 19:55:42  3832    939.5     22.5    676.4
2012/10/04 19:55:46  3782    951.9     22.8    685.4
2012/10/04 19:55:50  3832    939.5     22.5    676.4
2012/10/04 19:55:53  3842    937.0     22.5    674.6
2012/10/04 19:55:57  3804    946.4     22.7    681.4
2012/10/04 19:56:01  3842    937.0     22.5    674.6

Each line is a record that is produced whenever an electric meter pulse is sensed. The first two columns are the date and the time. The third column is the time in milliseconds between pulses. The fourth column is the calculated watts per hour for that pulse. The fifth column is the calculated KwHr per day, and the sixth column is the calculated KwHr per month.

Note that if there are multiple pulses within the same second, the date-time stamp will be identical to each of those records.

MySQL database table to store records discussed above can be created with the following command:

create table power(
       id int not null auto_increment,
       date datetime not null,
       timer int unsigned default 0,
       watthour decimal(10,2) default 0.0,
       kwhrday decimal(10,2) default 0.0,
       kwhrmonth decimal(10,2) default 0.0,
       primary key(id, date));

To plot the data collected in the MySQL database, I used a package called ‘highcharts’. The integration of this package involves javascript, php, html, css, and httpd.

Share it!
This entry was posted in Projects and tagged , , . Bookmark the permalink.

10 Responses to Simple DIY Power Monitoring System

  1. Steve says:

    Hello Nev,

    Thank you for sharing this project.

    I have the exact same Sensus Icon meter on house and until today when I found your web site, I wrongly assumed that the IR port on this meter used some proprietary technology that common IR diodes or transistors could not read. I have an old and inexpensive digital camera that has poor IR suppresion filters compared to more modern cameras. This old camera allows you see IR pulses from TV remotes very easily. The day they installed the New Sensus meter, I took my old camera outside to see the what I could see and I saw nothing. I waited till it was dark outside and still nothing. Rats!

    After reading about your project, I’m guessing that the IR pulses were so fast and narrow that my camera could not detect them. I can’t wait to get hold of some photo transistors and interface them up to a micro controller for processing.

    Best regards,


  2. nev says:

    Hi Steve-
    The IR signals from the TV remotes are modulated at high frequency. So I am not surprised you did not see the signals from the meter with your camera. I used a simple photosensor transistor without any filters. That should work..

  3. Steve says:

    Hello Nev,

    I purchased the same photo-transistor you did and I’m getting pretty good results. Also like you, I had problems during the those parts of the day that sun light hit the Sensus meter, but I think I’ve got a solution for that.

    My current prototype uses a (116 mm dia.) wooden disk cut from 3/16 inch plywood, that’s attached to the face of the Sensus meter using duct tape (for now anyway). I mention this because it does not appear to interfere with the daily KWH data presented on PGE’s web site.

    I’m feeding the IR pulse train into an ATmega 328P micro-controller chip, set up as a poor mans Arduino UNO board. This chip has hardware interuppts, which made it pretty easy to write a small software routing to compute the current Watt load and accumulated Watt Hours.

  4. nev says:

    Hi Steve-
    I am happy to see that you had good progress on your project. I would say that you
    are one step ahead of me now! :)
    Plywood is a good idea for now when the temperatures are low, but in the summer when
    the ambient temperature go higher, it may not work. You may want to consider styrofoam
    to block the heat.
    I briefly looked into ATmega chip, sounds great. I was planning on using Texas Instruments
    MSP 430 LaunchPad. How do you get the data out of the ATmega chip, or how do you access it?
    My system has been working for over 4 months now without any problems, but because of
    all this data the system is becoming sluggish. I need to find a way to archive the previous
    months without any downtime..
    Thanks for keeping me updated!

  5. Anonymous says:

    Hello Nev,

    I agree, plywood is not an optimal choice of materials. Once I get a good functional design in place, I hope to replace the plywood with something else. Maybe a custom cut piece of Acrylic or ABS plastic.

    The ATmega328P micro-processor used in genuine Arduino products and numerous clones, has a pair of discrete I/O pins that can be used to communicate with computers and other devices using 5 Volt TTL streams of pulses to create a very simple style of serial link. One pin is the RX line, the other is the TX line. The newer Arduino incorporate an on-board serial to USB circuit, so hooking up to a computer is dead simple. If your just using the ATmega328P alone, as I am, then you need an external TTL to USB converter, like the shown in the link below:

    So for the time being, I wrote a little sketch (that’s what the call a program in Arduino land) that spits out the accumulated Watt Hours and the most recent Watt load every 2 seconds. I can view this data on my PC using the “Serial Monitor” tool in the Arduino IDE software or I can use any terminal emulation software (like PuTTY).

    Someday I may add a 2 x 16 LCD panel to view the data and/or use an Arduino Ethernet board as a mini web server. Another idea would be to have the data logged on to an SD flash memory card.

  6. Steve says:

    Hi Nev,

    It’s been a week since I checked in, so here’s a update on where things stand.

    Last week I was fighting a steady stream of mysterious pulses that were consistently spaced at intervals of 90,000 microseconds (= 40,000 Watts). Now in my all electric home, it is theoretically possible to pull that size of load, but the conditions to make that happen were all absent during my testing.

    Cleaning up my 5Vdc power supply helped reduce these mystery pulses from several per second to several per minute. What ultimately seems to have fixed this was replacing the PN2222 (NPN-BJT) whose base was tied to the IR photo-transistor and whose collector to the interrupt pin on the ATmega328P with a 2N7000 ( N-channel, enhancement-mode MOSFET).

    Now things are much better. While I still see bogus pulses now and then, their intervals are so absurd that it’s easy to have the program running in the ATmega328P just ignore them.

    I want to let what I’ve got now run for another week to see how well my KWH data matches up with what PGE posts on their web site. If thing look close, I’ll start moving the hardware from a breadboard to something more permanent.



  7. nev says:

    Thanks for the update, sorry for late response…
    40KW sounds very high, for me the highest reading is about 6 to 7 KWs when the dryer
    or the oven is turned on.
    As far as the power supply, I used a big rechargeable car battery. It provides clean 12 V and
    the circuit draws so little power that I need to recharge it maybe twice a year, or maybe once.
    Something else to consider is the time base. I don’t know how stable the built-in oscillator is.
    For millisecond accuracy you may need to install an external crystal, I don’t know.
    PGE website is useful, but note that they massage the data quite a bit (sometimes upwards,
    sometimes downwards). It only gives a very rough idea about the power usage. They don’t
    just round it. Weird, I don’t know why they do that..
    Thanks Steve

  8. Steve says:

    Hi Nev,

    Hope your doing well.

    Yes, 40KW is big, yet quite possible in an all electric home like mine. This could occur not just from short term inrush currents from large loads on start-up, but steady state conditions. My heat pump system has 20KW of axillary (resistance type) heaters that kick in occasionally on very cold days when the outdoor coil needs to be defrosted. If that defrost cycle occurred while my hot water tank was energized, the oven was in use, a load of clothes was in the dryer, I could hit that 40KW mark with ease.

    I like that 12V battery idea, yet I’m confused. Your original post mentioned using a parallel port, so I assumed you were using traditional PC hardware. If you don’t mind me asking, what hardware are you using?

    I do have my Atmel ATmega328P micro-controller running off a 16MHz external crystal. Atmel’s documentation states that the internal microsecond timer/counter in the chip has a tolerance of +/- 4 microseconds which is pretty good for this application, yet I agree with you that my crystal’s characteristics must have some influence of the overall system accuracy. I’m just not sure how much.

    Timing issues aside, the results I see look quite good. For example, I’ve set up test trials where my house is consuming several thousand Watts from steady (non reactive) loads, and then switched on and off an old fashion 40 Watt incandescent lamp. The software reports a nice +/- 40 Watt change to the base load. Nice :-)

    As for the PGE web site. I’m grateful to have what they offer, but it’s not even close to what I was hoping for. In an era when someone can sit a home and get split second updates on stock prices along with sophisticated historical graphs and comparison charts, it’s rather sad that the “Smart Grid” still looks pretty dumb from where I sit.

    Best regards,


  9. nev says:

    Hi Steve-
    I just read your comment and then reviewed the original post and I realized that I never shared the circuit diagram. This was probably because at that time I did not have a good way to draw circuit diagrams.
    Well things are improving, wheels are turning, and new software is becoming available. I found out about a program called ‘Fritzing’ and started to use it. It allows users to draw circuit diagrams easily.
    I updated the post to include the circuit diagram that I am using. This will probably answer your question about 12VDC. As you can see from the circuit diagram, it is optically isolated from the PC. The second photo sensor is connected to the PC and it faces the ultra bright LED light.
    You mentioned that there might be a noise from the power supply. One way to protect your circuit from the power supply spikes is to connect a large capacitor close to your circuit, something like 100uF.

  10. WT says:

    I went out at night with Gen 1 NV goggles and the IR pulse was extremely bright from the meter. I walked a 1/2 mile up the mountain behind my home and through the goggles at that distance it was still quite a noticeable beacon. This pulse would be visible from the air quite easily as well. Must be annoying for law enforcement in helo’s at night.

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="" highlight="">