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, http://www.portlandgeneral.com. 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.
IR 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.
Circuit 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.
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.
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));