home power monitoring using an arduino and CTs

Over the weekend i finished up a home power monitoring
project using CTs and an arduino to get a rough measure
of power off the mains. I have about a week's worth of data collected and graphed here -
http://jarv.org/pwrmon_current.shtml

as well as details on the construction here -

http://jarv.org/pwrmon.shtml

feedback appreciated, thanks! -john

I use an arduino for doing the same, the CT route was my first bit I did. I found a toroidal current transformer on Ebay and used that for the interface. The problem with current transformers and using the arduino as an AC voltmeter is that what it measures is Apparent Power (Volts * Amps or VA) What you get billed for is Real or True power (Watts) . The difference between the two is whats called the power factor. Cheap computer power supplies in particular tend to have terrible power factors, so there is a wide discrepancy between the two. My next step was a reflective object sensor (an IR and photo transistor in a common housing) to measure how long the aluminium disk takes to rotate on the meter. I then plot them on the same graph. I've added quite a lot of other stuff and the result can be viewed here :

http://pluggy.is-a-geek.com/index.html

I haven't published my methods yest as its forever evolving. The last graph is a digital plot of the ADC against time and shows the waveform coming out of the current transformer. The difference between it and a sine wave is effectively a measure of the power factor. When I turn on an heavy power device with a good power factor (Electric Kettle - a resistor with little or no reactive element) the graph smooths up into a pretty convincing sine wave. Most of the time when its running my computer and TV and stuff, its a spikey mess. The gas graph is the same technology as the electric meter - watching a reflective bit on the last reel of the meter.Not much happening in summer as I don't burn much gas. The temperatures are 'Dallas' one wire digital thermometers. and the light levels are LDRs in a voltage divider circuit. One of these days I'll do a write up and take some pictures.......

very interesting, out of curiosity which line on this graph is measuring power using a CT vs the meter?
http://pluggy.is-a-geek.com/1hourjuice.png

I'm definitely seeing the same thing regarding the power factor as there are large discrepancies between measuring say a 100W lightbulb vs a 100W computer power supply. I was thinking there has to be a way to measure it more accurately since the folks at "the energy detective" are doing it in a similar fashion. I'm going to start by instead of just measuring peak voltage of the CT which was a quick hack to calculate an RMS value but it seems that still won't get me to where I want to be accuracy wise.

Well the other problem is that calculated power assumes the current is consumed continuously as a sine wave where as in reality many loads just 'sip' current when it reaches a certain level. The classic case is a standard linear DC rectifier/filter capacitor configuration. Once the filter caps charge then the rectifier only draws current when the AC voltage is at or higher then the DC voltage charge on the caps, so that power is consumed in 'pulses' rather then in a continuous draw like a lamp or pure resistance load. Anyway a typical solution requires a ''true rms' converter chip much like what the nicer DVM meters have internally so that voltage and current are displayed as their true rms value.

Lefty

What is a CT?

What is a CT?

It's a transformer designed to measure the AC current flowing in a single conductor. The current to be measured is a wire routed through the center hole of the transformer. The measured AC current is the ratio transferred to the windings of the CT. To use in a Arduino this secondary current must be terminated in a resistance load and then rectified, filtered and scaled before wiring to an Arduino A/D input pin.

http://cgi.ebay.com/WICC-MW1163-1-600-1A-Current-Transformer_W0QQitemZ140305973765QQcmdZViewItemQQptZBI_Circuit_Breakers_Transformers?hash=item20aae34205&_trksid=p3286.c0.m14&_trkparms=65%3A12|66%3A2|39%3A1|72%3A1205|293%3A1|294%3A50

ok, thanks.
I tested to measer current and i used one of that http://www.allegromicro.com/en/Products/Part_Numbers/0712/ with no problem but i had to cut the wires :stuck_out_tongue:

On my power graph. the red line is the CT, the green line is from counting meter revs. I use an average of the voltage either side of the mid point, I found it gave more convincing readings than a peak, especially when the peak is a spike. I multiply my figure by 7. It tends to be high when I'm not using much and low when somebody turns on a heavy appliance (Kettle, Tumble Drier, Shower etc etc). The problem with meter rev counting is that at very low usage it only gets an update every few minutes. It usually drops to sub 50W overnight between fridge and freezer and it takes 8 minutes to rotate at 50W. The graph just cribs the last reading when it hasn't had an update in the previous minute.

would it work on a cable with bidirectional current, like a power strip chord ?
nice work btw, thanks for sharing

Never tried it but I doubt it. The returning current in the neutral wire would cancel out the transformer effect.

Don't you need to sample both the voltage and the current simultaneously and integrate their product over time to get real power?

"Don't you need to sample both the voltage and the current simultaneously and integrate their product over time to get real power? "

Definitely - With just a current measurement a single device estimation for power is not going to be very accurate due to Power factor - Wikipedia as well as voltage not necessarily staying constant.

I've added another section to discuss accuracy of this system as well as some trials using different single devices. I've also switched from simply using the peak value off of the CT to an RMS calculation.

http://jarv.org/pwrmon.shtml#accuracy

You are making good progress. The problem with using RMS values is that unless the load is purely resistive, you must know the power factor for the load you are driving. This is usually unavailable or so inaccurate as to be useless.

As you can see from the current waveforms for the non-resistive or non-linear loads you are driving, they are quite different from sinusoidal and if you will display the voltage waveform at the same time you will see that the phase relationship is no longer constant either.

True power is the (integral over time T of i(t) * v(t) *dt) / T. Where i(t) and v(t) are the instantaneous current and voltage. You can approximate this integral pretty accurately by sampling both the instantaneous voltage and current simultaneously at a high rate by latching the values with separate sample and hold circuits and doing an a/d conversion.

The meters the power companies use don't measure power correctly either which is why if the know you have loads that are very reactive, they will apply a "fudge factor" to the rate to compensate for the error.

That's probably more than you really wanted to know about it but if you are interested in knowing how accurate ac power measurements are made in the lab there is a good article that doesn't assume you have a math degree that explains the process pretty well.

"You are making good progress. The problem with using RMS values is that unless the load is purely resistive, you must know the power factor for the load you are driving. This is usually unavailable or so inaccurate as to be useless."

Yeah I talk about that some in the section on accuracy. If you scroll down to my comparison chart from this link - http://jarv.org/pwrmon.shtml#accuracy you can see the power-factor for the computer is 0.64 where the power factor for the purely resistive loads are closer to 1. This obviously makes a huge difference for individual devices, does it matter much for the aggregate? Not sure, for now i'm approximating my power factor to be relatively constant for my total power consumption.

I thought about hooking up a transformer for both phases and monitor voltage in parallel to current. I was looking over ladyada's kill-a-watt hack (Tweet-a-Watt! A safe and simple wireless power monitor) and saw that it's possible to grab a voltage waveform from the device although I'm not how it is adjusted prior, maybe I'll look into that.

Thanks for the link!

I'm curious to know how the kill-a-watt actually works. For $20 I'd be surprised if it gives an accurate measurement of reactive loads. They claim "up to" 0.2% accuracy which would be easy for resistive loads and they know no one is likely to dispute them anyway.

The thing you want to do for your application is probably measure power the same way the power company does, as inaccurate as it is, because that's how you bill is calculated after all. :wink:

I think your project is great! It really shows what we can do with inexpensive hardware. Keep up the good work.

I have one of these, which is probably a similar device and price to the kill-a-watt.

I haven't opened it up to establish how it works , but it gives convincing readings which do bear some relationship to my meter rev counter readings. (I reckon my freezer uses about 100 watts and my new mini server about 10 watts both by the meter revs and by the power monitor ) I get high and low power factor readings when I expect them. Freezer 0.96, Computer 0.46.

I could probably get some better figures from my CT if I applied my mind to the problem, it gives terrible readings at low power usages.

I notice my site gets a mention on Jarv's page now. I really must do a write up........

I've been using the Allegra Hall effect sensors with excellent results. They require you to be able to place them in series with the load but I don't see that as a problem if the plug in meters work for you. You could use one to calibrate the CTs, perhaps. They are relatively inexpensive, $4-$5, as well.

"I'm curious to know how the kill-a-watt actually works. For $20 I'd be surprised if it gives an accurate measurement of reactive loads. They claim "up to" 0.2% accuracy which would be easy for resistive loads and they know no one is likely to dispute them anyway."

Yeah I'm suspicious as well. :confused: I found two contrary claims, one on consumer reports - http://www.consumerreports.org/cro/magazine-archive/march-2009/appliances/energy-monitors/overview/energy-monitors-ov.htm?resultPageIndex=1&resultIndex=1&searchTerm=kill-a-watt

And another comparing it to a fluke 1735 which paints a less rosy picture - http://forums.anandtech.com/messageview.aspx?catid=84&threadid=2147352&enterthread=y

I expected as much. Reactive loads are the most difficult to measure accurately. But, as one article said, for <$20, not bad.

Consumer Reports didn't say what type their "calibrated" instrument was.

I have just start with Arduino boards, I have picked this for my 1st project. I got the CT etc, still need a few things.
Can you please try this code out and let me know how it looks

float rms_val1 = 0;
float rms_val2 = 0;
float power_rms = 0;
for (int cnt=0; cnt<SAMPLES; cnt++) {

val1 = analogRead(S1_PIN);
val2 = analogRead(S2_PIN);

rms_val1 = rms_val1 + sq( (float)val1 );
rms_val2 = rms_val2 + sq( (float)val2 );
power_rms = power_rms + sq(val1*val2);
}

rms_val1 = sqrt(rms_val1 / (SAMPLES/2) );
rms_val2 = sqrt(rms_val2 / (SAMPLES/2) );
power_rms= sqrt(power_rms / (SAMPLES/2) );

In theory power factor will no longer be an issue, however I don't about only using half the wafeform