How to build a basic energy monitor - Mains AC: non-invasive 3.0
Voltage and current measurement
This guide details how to build a simple electricity energy monitor on that can be used to measure how much electrical energy you use in your home. It measures voltage with an AC to AC power adapter and current with a clip on CT sensor, making the setup quite safe as no high voltage work is needed. The energy monitor can calculate real power, apparent power, power factor, rms voltage, rms current. All the calculations are done in the digital domain on an Arduino. The Arduino can then be connected to a computer, data logger, lcd screen, Ethernet link, etc to make use of the data.
Changes since last version
Electronics
- 2x 10uF bias stabilizing capacitors added: more info
- Changed Voltage measurement circuit
- Power for arduino comes from a seperate transformer to AC voltage measurement transformer.
Software
- Arduino sketch rewrite, sketch now follows Atmel's 465 appnote method, adding:
- Phase calibration
- Digital high pass filter to remove offset.
Step One – Gather Components
You will need:
1x Arduino oomlout £23.67 , nuelectronics £16.99
Voltage sensing electronics:
1x 9V AC-AC Power Adapter farnell £2.67
1x 100kOhm resistor
3x 10kOhm resistors
1x 10uF capacitor
Current sensing electronics (you will need 2 of these for whole house monitoring in the US)
1x CT sensor efergy £7.50 , seeedstudio $11.50
1x 56Ohm – 100Ohm burden resistor (for more info on choosing a burden resistor look on the detailed system design page)
2x 10kOhm resistors
Other
1x A breadboard and some single core wire.
Oomlout do a good arduino + breadboard bundle here £29
Step Two – Assemble the electronics
The electronics consist of the sensors (which produce signals proportional to the voltage and current in the mains) and the sensor electronics that convert these signals into a form the Arduino is happy with.
For a circuit diagram and detailed discussion of sensors and electronics look on the detailed system design page.
Also have a look at this page for a new detailed description of the current sensing electronics, hopefully it will clarify a couple of aspects.
Assemble the components as in the diagram:

Step Three – Upload the Arduino Sketch
The Arduino sketch is the piece of software that runs on the Arduino. The Arduino converts the raw data from its analog input into a nice useful values and then outputs them to serial.
Download the library and examples sketches from github here:
https://github.com/openenergymonitor/MainsACv3
The sketch with a calibration method thanks to Eric Sandeen that allows you to set the component values of the measurement circuit to obtain a rough calibration that can be tweaked further for accuracy with the calibration method at the bottom of this page. For further details see the discussion in detailed system design. If you are using an SCT-013-030 you can set up a burden resistor of 62 Ohms and 1800 turns.
Download the sketch with calibration method: basicSketchWCal.tar.gz
and then upload it onto the Arduino. Then go to the Arduino serial monitor and you should see values being printed to the scre, looking something like this:

From left to right: Real Power, Apparent Power, Power Factor, Vrms, Irms.
Step Four - Calibration
If you compare the output from the serial monitor with the output from a reference energy monitor (like a kill-a-watt plug in meter) they probably wont be the same. To get accurate measurements the energy monitor needs to be calibrated, as follows:
Step one – calibrating power factor
Power factor needs to be calibrated due to phase displacements from the CT sensor, Power adapter and multiplexed ADC readings. To calibrate choose a load that is reactive like a fridge or a grinder and a load that's resistive like a heater. Compare the value for power factor on your energy monitor and your reference meter. Look in the Arduino sketch for the line:
double PHASECAL = 1.0;
Try different values until the power factor's agree for when you have the reactive load connected and when you have the resistive load connected. I found 2.3 worked well.
Step two – calibrating voltage and current
For best results choose a load that's within but close to the maximum range of your energy monitor and your reference meter minus a couple of hundred watts, most domestic plug in meters go up to about 3120W so around 2000-2800W would be fine (as long as this is also within the range of the energy monitor)
If your using non-halogen heaters beware that the power that they consume decreases for sometimes up to 10mins as they heat up. To take an accurate calibration point wait until the power consumption is stable.
Note down the Voltage and Current value off your reference meter and from the Arduino serial monitor and then calculate the calibration coefficients:
newCAL = ActualValue / currentValue
Look in the Arduino sketch for the lines:
double VCAL = 1.0; double ICAL = 1.0;
Multiply the old VCAL by the new VCAL and replace the old value with the result.
Upload the sketch and now hopefully your values should be a lot closer to what they should be.
For more information see pages on:
- Accuracy
- Detailed system design
- AC Power Theory 1
- AC Power Theory 2
- Household wiring
- Revision Log and further development questions
US 3-wire single phase installation
If your based in the US you need a bit of a modification on the above to make it work with 3-wire single phase. Dave over at draythomp.blogspot.com has made a great write up of his installation + source code that's well worth a look at here.
i think u cant use AC /DC
i think u cant use AC /DC bcoz u need AC signal as output to measue the voltage and get power factor if u used AC/DC u ll not get the voltage i think
:P
USING 9Vdc ADAPTER
hello,
can i use a 9v ac/dc adapter for this kind of project?..
thanks for the reply.
i think u cant use AC /DC
i think u cant use AC /DC bcoz u need AC signal as output to measue the voltage and get power factor if u used AC/DC u ll not get the voltage i think
1st build
I have just built this circuit for my solar immersion controller and all seems to work ok except that after a few minutes running the arduino stops transmitting to the serial monitor.
Is it something to do with this line of code
for (int n=0; n<numberOfSamples; n++)
I am not to hot on the code side so bear with me. I want the code to run all the while so it monitors my solar pv all day.
any help would be great
thanks.
strange that it works for
strange that it works for some time and then stops working.
try adding some serial.prints to debug at which point exactly does it stop, if inside the "for" and with what value of "n"
so you could at before the FOR
Serial.println(numberOfSamples);
and also the same line inside the FOR.
Serial.println(n);Serial.println("\t");Serial.println(numberOfSamples);
that way you can see if for some reason the value of "n" is not increasing and therefore the program gets stuck inside the FOR
I think it happened because I
I think it happened because I closed down the serial monitor. If I leave the serial monitor running it works continuous. Am I right in thinking that it will still stop after 3000 samples.
same trouble
I seem to be having the same problem, I'm starting to think my burden resistor is too big. It works fine when there's no large draw, but stops when the wattage goes way up. I'm using two 30A split core current sensors. ( http://www.sparkfun.com/products/11005 ) got a pcb fabbed for a pro mini, and a set of xbees.
No one can help me with
No one can help me with this?
Digital filtering for phase lag
Hi,
Running into the same problem, I came across this note that describes the problem (and solution!) rather well:
www.ti.com/lit/an/slaa122/slaa122.pdf
From the example, you can see that the formula defining FilteredV does the actual work, and that the PHASECAL is a correction to it to account for additional phase lags of the CT transformer.
Bart
Shifted voltage vs instantaneous voltage
Reading the basicSketchWCal (found in this page), I came across with the following line:
Studying the code, I realized that shiftedV is used to calculate the real power.
In "AC Power Theory 2" page is said that the real power is calculated with the instantaneous power.
There is something I did not understand? Or the documentation is really at disagree with the code?
What this line really do?
Hi, hope you dont consider
Hi, hope you dont consider this an offtopic, and if so, please move it or let me know.
I have bought this CT sensors on ebay.
I was using a smaller version of 5Amps for some time with no problem.
however the 20Amps version produce a buzzing noise when current goes through the primary wire. even if its "just" 1000W which is something the 5Amps CT worked just fine and did not produce a noise.
readings are correct but i dont now if its safe to leave this unattended due to the noise. it does not get hot though.
I also have an efergy CT and also a blue version of similar one. and none produces noise.
oh btw, I have 3 of this units and all produce the same noise.
thank you a lot !!
Re: Hi, hope you dont consider
It's probably just loose secondary coils reacting to the electromagnetic field induced from the primary, causing vibration and hence a buzzing noise. Does is get louder if the current increases?
It's an unusual choice of CT, as the split-core 'clamp' rogowski coils are usually a lot easier to fit and maintain.
I will try tomorrow to
I will try tomorrow to increase the current and see what happens.
So by unusual you also mean bad? I got them because of their price on ebay and cause i did not mind having to fit the wire inside.
what do you mean about maintain?
I really dont think its a loose secondary coil as all three of them do it. by loose you mean inside the CT??? of my conection of the secondary to the circuitry?
thank you so much and please if you have time, help me out a bit more. thanks again.
Re: I will try tomorrow to...
So by unusual you also mean bad?
No not bad, in fact they are supposed to be more accurate than the split core CT's, but as you have said, more difficult to fit as they require disconnecting/reconnecting supply leads which some people are not comfortable in doing.
what do you mean about maintain?
CT's without a burdon resistor attached can develop very voltages in the secondary coils - enough to give you a wake-up call! so it's always handy being able to simply unclip it when working on your circuit/wiring ect.
I really dont think its a loose secondary coil as all three of them do it
That depends upon the build quality/design of all three. For example, if the sec coil is just a loose fit inside the plastic case, then it's hardly suprising that they buzz.
what do you mean about
what do you mean about maintain?
CT's without a burdon resistor attached can develop very voltages in the secondary coils - enough to give you a wake-up call! so it's always handy being able to simply unclip it when working on your circuit/wiring ect.
This CTs generate a current of up to 20mA if I am not mistaken, please see this:
www.ebay.com/itm/Horizontal-Mount-20A-Input-Current-Inverter-Transformer-/220923995722
So I guess the maintain issue is not applicable? I am using a burden resistor to read from them. I dont really understand the wake-up call you mention.
I will try to record a video with sound tomorrow, however this things look very robust, and actually i have tried 5 of them, and all make the same sound.
ac/ac adapter
I'm in the U.S. and I have a 120vac to 4vac transformer, can I use this or does the output need to be 9vac?
Thanks
~Corry
Re: AC-AC adapter voltage
Different voltage AC adapter can be used but resistor values should be calculated accordingly: see detailed design page: http://openenergymonitor.org/emon/node/59
hey guys thanls for
hey guys thanls for uploading this project its really usefull but i have some problems i have connected every thing same but the output results is not satisfactory and not the same as given . an other thing i want to ask the ouput from the adapter and CT conneted to the arduino should be AC or DC i got one AC and an other DC .
so any one can help me please
thanks
AC and DC adaptor.
Hi omer.
You need the AC/DC adaptor to power the Arduino which in turn powers the CT circuit. You also need an AC/AC adaptor set to 9v to as the reference input. Don't forget to modify the sketch for your voltage, burden resistor etc.
AW
Hi, I have a fully working
Hi, I have a fully working version 3.0 in my house expanded to not only 1 CT but 5 of them (1 efergy and 4 smaller 5A CTs from ebay)
I bought some 20A CT sensors to completely monitor each section of my house and wanted to make all 8 work together.
When testing the 20A CT individually they seam to work correctly however when using them with the rest of the proyect I get two problems´:
- The voltage regulator starts to get hot (probably the new CTs are using up to much current)
- The readings start to fail when I add the third new CT.
At first I thought there was something wrong with the CT sensors but now I think I might be hitting a max current value of the regulator.
so the question.....
Would it be possible to supply the 2,5V to all the CTs from another source or regulator? can I feed it also to the arduino to control voltage fluctuation?
Thank you for your help
What are the resistor values
What are the resistor values of the voltage dividers you are using? You can use a regulated external power source, but you should either also power the arduino with the same power source (not through it's voltage regulator), or apply a voltage divider to the power source for the CTs to the AREF pin to get equivalent behavior to not using an external power source.
I plan on doing a similar "zone" monitor, but haven't gotten around to it.
resistors are 470ohms I also
resistors are 470ohms
I also thought about the external power source, i am using the AC-AC transformer with a rectifier to DC of a capacitor and a diode bridge.
So I could get the output from there, pass it through an externar regulator and feed that to a voltage divider, then put those 2,5V to the CT sensors and the AREF pin.
Do you think this is correct?
I will have to look into the AREF pin as I have not used it before, but I guess there is some code tweaking to use that value as reference for the analog input?
thanks
re: resistors are 470 ohms
470 ohms seems awfully low in value to me. The CT's in my system run on 10,000Ω (10kΩ). Try changing to that value and see it if helps keep your regulator happy.
Yes that is very low, there
Yes that is very low, there must be a mixup? we usually use 470kOhms
well I dont know why but yes
well I dont know why but yes I am using 470ohms.
so could this be the reason? what could be happening by using 470ohms instead of 470kohms?
btw, I am building a new system for a freind and the AC to AC transformer is of 1Amp instead of 0.5Amps which i have in my setup. Well in my setup the regulator does not heat up but in my friends setup it does and a lot !!
Why could this be?
Thank you very much
I guess 2x470ohms still does
I guess 2x470ohms still does not use that much current, only 26.5 mA for 5 CT's which of course is much less than 1A. Could there be a short someware?
Trystan I am building a meter
Trystan I am building a meter for a friend and want to use only CT sensor with no Voltage reading.
What is the best code to use here? I will be using 3 CTs which are different.
I have seen in the emonTx_SimgleCT_example
https://github.com/openenergymonitor/emonTxFirmware/tree/master/emonTx_S...
but here the burden resistor says 15 ohms !!!!!! Is that correct? You were telling me about going up to 470kOhms because my values where too low.
could you explain please
RE Burden Resistor Value
You seem to be confusing the burden resistor with the voltage divider resistors, which provide the DC bias, or offset. Regard the image below:
The two resistors marked Rvd are the bias resistors, and they should be something between 10k and 470k. The burden resistor (marked "Burden") will likely calculate out to be a very low resistance in comparison, 15 ohms doesn't sound excessively low for the this resistor.
That may be enough current to
That may be enough current to cause a probelm with your arduino. Try using a much higher resistance. There is not a good reason to use one that low.
Bricked Arduino from power sensing circuit?
It appears I bricked my arduino attempting to use this circuit. Everything appeared to be ok (other than some values appeared as negative), but then I removed the USB from the arduino *and it stayed on*. I then removed the +5V line from the arduino and it still stayed on. Then I removed the ground (I may have plugged the 5v line in) and the on LDE dimmed, but still stayed on.
I am not sure what the impact of these actions is, but it appears I bricked my Arduino and unfortnuately it is an Uno which probably means the whole thing is toast.
Now it is time for the autopsy and understanding why it happened to prevent it from happening again. I am guessing the current transformer, but more probably the 9VAC wall wart kept powering the ardino. My guess is that I fried it when I removed the ground or the 5v and the positive had to flow through the analog pin.
Can anyone provide confirmation or other hypothesizes?
Sharing 2.5V reference ?
Is there a reason to not share the 2.5V reference for both current sensing and voltage sensing circuit ?
Sharing 2.5V reference
I tried doing this and it didn't work. Although it seems reasonable that one reference source should work for both, remember that the AC voltage coming from the CT and the line voltage reference is imposed across the resistor and capacitor going to Arduino ground. As such, there would be an adding/cancelling relationship between the two voltages, complicated by the phase difference in the CT signal caused by reactive loads.
Better to provide two separate reference voltages to avoid interaction, that circuit is more than a simple DC bias.
voltage
hi, we have made the model of your project, it seems to work except, values keep serially appearing on the window, but here we use 220v supply but o/p is shown t be around 130v, wat may be the problem!??
plus is there any provision wherein i can store these lines of data into a file?? etc
Efergy CT Sensor with 3-pin 3.5mm jack
I saw that there was an earlier post on this forum by someone who was asking whether the 'newer' style 3-pin Efergy CTs were compatible with this project. Are there any thoughts on this?
http://www.efergy.com/index.php/default/products-uk/accessories-uk/jackplug-extra-sensor.html
I see that photos on eBay of the other recommended CT, the SCT-013-000, show it as also having three pins. I'm guessing then that as far as this project is concerned, one of these pins is extraneous? Any feedback on using these new (Oct-2011) efergy CTs would be appreciated. Thanks, James.
efergy CT sensors
Hi James,
Its highly likely that the third pin is not connected. I imagine its's just case of stereo jacks being more abundant and therefore cheaper for efergy to manufacture than mono jacks.
We have a load of the older efergy CT's with the two pin availalbe for purchase if you want to be sure.
Ive tried to reach you by
Ive tried to reach you by mail but seems something is wrong with the email in your profile.
Are this CTs replaceble with the 3 pin one (the newer version)?
I would like to know the cost to see if they are cheaper and buy a couple of them
contact
you have mail!
Yes, the 3-pin CTs from
Yes, the 3-pin CTs from efergy work quite well. They seem to be about £7.50 each and about £4.00 for postage. You'll probably get a discount on postage if you order more than one. It took about 4 days for them to deliver the CT to central London.
You should be able to use a 'mono' 2.5mm socket. The 'tip' and 'bottom' conductors are the ones to use. You can easily work this out though by connecting a multi-meter on 'resistance' mode to find out which two conductors to use.
Apart from that, I followed the circuit diagrams exactly (using a 100ohm burden resistor) and got my prototype up and running as described. A tip though, it's worth following the circuit diagrams rather than the photos of the example breadboard as they are a little misleading.
i was asking cause Glyn was
i was asking cause Glyn was saying they had a load of them around and maybe they want to sell them, in that case i am interested.
nevertheless, what do you think about this other option of CT ??
openenergymonitor.org/emon/node/156#comment-2231
thanks
I suppose these look OK. It
I suppose these look OK. It depends on how much current you would like to measure I suppose. I wanted a CT that I could easily 'clip onto' a wire without having to pass the wire through. I also wanted to build the prototype with as fewer changes to the example code as possible. The recommended CT is the efergy model and it seems to work really well. I can't comment on the other CTs but I'm pretty sure I saw a comment from someone saying they performed fairly well.
thanks for that. I have one
thanks for that.
I have one of those TA12-200 and performs amazing. i have test it against a plug power meter for 30 hours and accuracy error was within 1,4%.
The thing i dont understand is what is more convenient of those two TA12-200 and TA12-100, as both of them are 0 to 5Amps, so I dont understand the difference with them and what that means.
thanks for any feedback
I have that sensor, but only
I have that sensor, but only two wires are inside the cable. EmonTx uses 2.5mm vs 3.5mm plug on the sensor - you can always cut it and use the propper plug
Thanks for your reply. Indeed
Thanks for your reply. Indeed you are correct. A 2.5mm plug. Do you know which of these pins are 'hot'? I'd prefer not to cut the plug off if possible. Do you think a 'mono' 2.5mm socket will work? Presumably the tip and middle conductors are connected to one wire with the bottom conductor reserverd for the second wire? I'm guessing that if this is the case, a mono socket will work just fine. Thoughts?
Did you also find you had to tweak any of the default values in the code as fas as adjusting the CT (number of turns etc) or other elements of the circuit? I have tried to follow the spec as close as possible and I have a 230VAC to 9VAC AC/AC adaptor. I'm undecided whether to use either a 56ohm or a 100ohm burden resistor. Will changing the values of the burden resistor affect the calibration settings in the code? 26Ams max current should be more than enough so I'm guessing the 56 ohm resistor will be fine. I'm just not sure if any code changes are requried in this instance.
Adding more CTs
Hi, I would like to propose this CT which i just found which are much cheaper and after testing one of them, they work pretty well.
www.ebay.com/itm/0-5A-Input-2-5mA-Output-AC-Current-Transformer-TA12-200-/300609568022
Also would like to ask, I want to add extra CT to my current proyect. Right now I am reading 1 CT and already have a second one prepared to modify the code and make it read also this second CT.
The thing is, would it work if I use the same voltage divided (2Rvd + capacitor) for several CT sensors, and just have a burden resistance and a CT in each of the locations of the house? this way I could send 1 wire for voltage and 1 wire for each extra CT I want, instead of having to send 2 wires per CT. also the circuit would be simpler.
would this work? maybe adjusting resistors watt ratio, or changing the capacitor for a bigger one??
-------
I would also like to add more CT than analog inputs i have, could i connect the voltage divider to a relay to switch between powering a row of 4 CTs and read using (analog 0,1,2,3) and then power the other 4 CTs and read using same analog pins ??
sorry i know there are 2 questions here, but they are kind of related and any help is much appreciated.
I have gone ahead and tested
I have gone ahead and tested my question (should have done it before asking, sorry)
In regards to first question about supplying 2,5V to several CTs using same wire and circuit, it seams to work ok. i have 2 CTs connected to the same voltage divider and capacitor and readings seam to be correct.
Im still thinking whats the best option as for multiplexing, ive seen some multiplexer chips which could also be a good option, instead of using a rudimentary relay.
Measure current for 1000A
Hi all,
I followed and built this project for an small domestic consumption, but if i wanted to measure the consumption of an industrial machine of 1000A, that i need to do is only to replace the burder resistor and the CT sensor?
I would like to use this CT sensor:
http://it.rs-online.com/web/p/trasformatori-di-corrente-shunts/3810800/
Is possible? how can i do?
thanks
Marco
Re: large CT
Be very cautious. We have no experiance measuring such large currents with CT's. The current and voltage in the secondary winding of the CT (arduino side) can get up to dangerous levels.
We would recommend getting a pulse output utility meter installed the monitoring the power optically by reading the pulse output LED. The emonTx can do this. See pulse counter under input modules for general information.
large CT
Thanks glyn,
so you have an idea of how i can build an interface for measure this power (380V - 1000A max) with arduino starting from this http://openenergymonitor.org/emon/node/54 ? have some link so i can see and study how i can convert egergy in pulse?
Thanks again
Marco
Pulse counting code example
https://github.com/openenergymonitor/emonTxFirmware/tree/master/emonTx_1CT_and_PulseCounting_example
Capacitors
Does anyone know what the voltage is on the capacitor and where can I purchase them?
I assume they are 5v 10uf electrolytic capacitors but trying to source them is really difficult!