Home Power Monitoring

powermonitor

Reader [john] finished up his home power monitor over the holiday weekend. It uses a pair of current transducers clamped onto the mains. These output 0-3V and are read by the Arduino’s ADC. The Arduino averages samples over a 20 second period, calculates power used, and uploads it using an Ethernet Shield. The shield can’t do DNS lookups, so he uses a WRT54G to negotiate with the remote webserver. He admits that the system could be more accurate; it can’t detect small loads like wall warts. He also says that money could be saved by talking serial to the router instead of over ethernet. Here are the current usage charts.

You can find many power monitor projects like this in out Home Hacks category.

25 thoughts on “Home Power Monitoring

  1. it would be easy to have it estimate something like cost per hour, and predict your electricity bill. install something like that in every US home, and I’ll bet energy consumption would drop significantly.

  2. Seems to calculate “power” used by taking the maximum current of 10000 samples, then summing 10 such values.

    Would be (a lot) more accurate to sample voltage and current each time, and take the RMS power from that.

    This is obviously a lot more complicated, but gives another benefit of giving you power factor data.

  3. @Mephistopheles

    Im not sure if Im missing something but the cnt variable is used twice, hence as far as I can tell it should always be greater than NUM_READINGS after running the for loop. Though this then means that the output number is not the average but is the maximum divided by 10… Very strange…

  4. @chris – I didn’t notice the two uses of “cnt”, but having looked again I think the scope of the first one will be restricted to the for 10000 loop?

    Then the second (count to 10) one can do its thing independantly.

    I’m not sure though, and even if it does work like that it’s not very good coding practice…

  5. @chris – you are right on both counts, it’s restricted to the scope of the for loop but it’s also horrible coding :/ I must have been tired or something, I renamed the second loop counter. -john

  6. Care must be taken that the secondary of a current transformer is not disconnected from its load while current is flowing in the primary, as the transformer secondary will attempt to continue driving current across the effectively infinite impedance. This will produce a high voltage across the open secondary (into the range of several kilovolts in some cases), which may cause arcing. The high voltage produced will compromise operator and equipment safety and permanently affect the accuracy of the transformer.
    http://en.wikipedia.org/wiki/Current_transformer

  7. @john: what are you trying to measure ? Apparently you’re storing the max current over 20 seconds intervals (actually the raw ADC value), and using this directly as Watts. It’s not the same as power at all, you need at least to calibrate the current reading, compute the RMS average value, and calculate the power assuming a constant RMS voltage and power factor. Ideally as Mephistopheles said you’d compute the power by integrating the u*i product over a few AC cycles, but it requires a voltage reading.

  8. Love the project and now want to get some current transducers!

    Re: Linksys router + Arduino + Ethernet shield: I have been using an Asus wl520gu wireless router with OpenWRT because it has a host USB 2.0 port, an internal serial port, it is cheap, and it is difficult to brick. I use a USB hub with a Duemilanove USB Arduino and 1GB USB memory stick plugged in (amongst other things!). The only downside of the wl520gu is that you need to use 2.4 with it because the wireless driver under 2.6 is not working well (AFAIK). Asus WL500 (not sure which – Deluxe? Premium?) have two USB ports, 32MB memory, and 8MB flash but are more expensive.

    @andrew: Thanks! *very* important to know.

    @vic: don’t be a tosser just because it doesn’t meet your anal standards. It is a work in progress, he calibrated it using the killawatt, and most importantly it gives him a usable indication of power usage over time.

    @John – thanks for making the effort to write this up – Many of us lurkers really do appreciate it (even if we don’t say much normally!).

  9. @andrew, thanks for the warning, I didn’t think of that but it makes sense. I’ve noticed open-loop hall-effect current sensors are reasonably priced and shouldn’t have the same danger as a transformer, is there any downside (other than having to break the circuit to install)?

  10. @robocat – thanks! yeah I have the same annoying problem with the broadcom router which requires 2.4 in order for the wireless to work :/ i’ve had it for awhile so i think i would definitely like to get one with a host usb port, that would be very convenient.

    @vic – my clunky way of estimating power was to empirically using a kill-a-watt come up with a scaling factor that would map the peak value measured on the ADC to watts. For the stuff I care to monitor the results were reasonable. Thanks to this post I’ve had some email exchanges with friendly people who really know what they are talking about; I might have some additional ideas to make this more accurate for different loads. I’m interested if people think it’s possible at all to measure power, compensating for power factor and whatnot, by simply using CTs on the mains. Makes me wonder how http://www.theenergydetective.com/index.html is doing it. -john

  11. Seen this kind of hack before; the most interesting part is the use of the arduino (which I approve of highly).

    This one is cheaper (because of the eth shield & wrt) but doesn’t allow you to use your own servers:
    http://www.instructables.com/id/real_time_web_based_household_power_usage_monitor/

    This one is just over the top.
    http://www.kondra.com/circuit/circuit.html (not too much info here, saw on /. circa 2005)

    As far as making this easier on the software side, can you make a leaky integrator in analog space and just sample the result of that? If you make the filter period long enough (longer than 1/60th of a second), it’ll do your RMS averaging for you, assuming the CT output is rectified.

    Your other option is actually doing integration in software (which would be the same thing as the above filtering, except requiring cpu cycles).

    I think it’s safe to assume that your line voltage will be 230 V, 3 phase within ~3% (when mine varies outside that range, the power company gets pissed at me)

  12. @John:
    “I’m interested if people think it’s possible at all to measure power, compensating for power factor and whatnot, by simply using CTs on the mains”

    It is not possible by using only a CT, with a CT you can only measure current. If you also measure the voltage then all said above is possible.

  13. @John.

    :) You can not calculate anything without knowing the instantaneous voltage and power draw at same time. That’s what vic was trying to explain. The powerfactor is a phase relationship of voltage to power. For the most time you’ll actually be pretty low on the powerfactor, somwhere in 75-95% range. It’s unlikely that you’ll be at a 100% powerfactor ever, the capacitance in the powerlines cause loses and there are also a lot of other forces involved. The dynamics of power in a typical home is a lot more then what most people realize. Depending on where you live in the US. Your voltage can swing 20-30v. That’s a lot of voltage not to account for in the calculations. I also wanted to point out to make sure that you have the CT’s pointed in the right diraction. Otherwise current in one of the incoming lines your measuring will be subtracting from the other.

    -Roman D

  14. @roman d – interesting, what direction do you mean by “right”, does this picture look correct?
    http://jarv.org/power/pwr_arduino.png.

    From the data I’m collecting it seems about right, but then again I don’t have a variety of different types of loads with varying power factors. From the comments so far I’m guessing then that theenergydetective has the same problems unless there is some magic happening in their setup that I don’t understand :)

  15. There should be a red dot on one side of the CT’s, But the main thing is you just want to make sure the polarity matches from your outputs. I’ve seen them mis-marked at factory, rarely but it does happen. Just put a volt meter on the CT’s and make sure your ground is actually ground and not other way around. I can’t tell from the picture and I don’t see the schematic of how you have it wired to your A/D converter but like I said basically just make sure your polarity is right.

    Reguarding the power factor :) there is magic that happens in backround but it’s nothing that magical just a matter of collecting the data and doing the propper calculations. Our system takes into the account voltage and phase factors. Though normaly a home is a single phase feed, in large appartment complexes and high-risers they sometimes use a single-derived from 3-phase power. That’s where it gets messy. Your voltage between phases is 208v not 240v so you have to account for that difference. Also as vic mentioned the most critical part of the system is the calibraton. :D Keeping a stable 200Amp load so you can calibrate is not an easy task. Also you have to remember there are two types of loads, capacitive and resistive.

    -Roman

  16. @tw – thanks for the links. Using a cheap AC clamp is a really good idea. I love the overkill of the second one!

    I presume it would be realtively easy to add voltage measurement, with a step-down transformer plugged into any wall socket (transformer for isolation from mains – a spare AC wallwart should be fine; try to pick a socket on a circuit with low load; if you have more than one phase then just presume voltage imbalance between phases is insignificant).

    Use the arduino to find the voltage phase by detecting -ve to +ve zero crossing (maybe need an RC filter to remove noise?).

    You could also measure the voltage if you use the ADC to measure the step-down voltage reading (maybe need voltage divider depending on transformer output voltage). Calibrate the stepdown voltage readings against a mains voltage reading taken using a multimeter.

  17. @tw: I think ill try to measure the voltage as well and see what I can do for a more accurate measurement. I’m pretty sure i have an extra transformer lying around and i don’t think it will be hard to rig it up next my electrical box.

    @roman: thanks for the insight into energy detective, it sounds you guys have a great product. think my next step for this project is going to see if I can incorporate voltage measurements and continue to use the kill-a-watt as a calibration tool.

  18. Hello John

    I just came across your power monitoring project. Great work! The online graphing is ace!

    I’ve been working on the same thing using a current transformer and an arduino. I think I may have got around this issue of not measuring voltage. Im getting good results by ‘synthesising’ the voltage waveform infering it from the current waveform.

    I’ve put all the details up here:
    http://openenergymonitor.org/emon/node/28

    I haven’t done any internet connectivity stuff yet but will do soon, your work will definitely help me out!

  19. Thanks for the complete writeup. Excellent reference. I am looking to build an exact replica.
    Are there any more efficient ways of tapping into the main incoming power lines from the MCB?
    Do u know of any options?
    Thanks
    Gopal

  20. If you use two hall effect clamp on current sensors (4 wire device) and excite them with in-phase AC voltage then power falls out as a DC voltage on two of the wires. Resolution can be impoved with a computer controlled amplifier.

Leave a Reply

Please be kind and respectful to help make the comments section excellent. (Comment Policy)

This site uses Akismet to reduce spam. Learn how your comment data is processed.