How to build an Arduino energy monitor - measuring mains voltage and current
Including voltage measurement via AC-AC voltage adapter and current measurement via a CT sensor.

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.
Step One – Gather Components
You will need:
1x Arduino
Voltage sensing electronics:
1x 9V AC-AC Power Adapter
1x 100kOhm resistor for step down voltage divider.
1x 10kOhm resistor for step down voltage divider.
2x 10kOhm resistors for biasing voltage divider (or any equall valued resistor pair upto 470kOhm)
1x 10uF capacitor
Current sensing electronics
1x CT sensor SCT-013-000
1x Burden resistor 18 Ohms if supply voltage is 3.3V or 33 Ohms if supply voltage is 5V.
2x 10kOhm resistors (or any equall valued resistor pair upto 470kOhm)
1x 10uF capacitor
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 mains voltage and current) 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 see:
CT Sensors - Interfacing with an Arduino
Measuring AC Voltage with an AC to AC power adapter
Assemble the components as in the diagram above.
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.
a) Download EmonLib from github and place in your arduino libraries folder.
Download: EmonLib
b) Upload the voltage and current example:
#include "EmonLib.h" // Include Emon Library EnergyMonitor emon1; // Create an instance void setup() { Serial.begin(9600); emon1.voltage(2, 234.26, 1.7); // Voltage: input pin, calibration, phase_shift emon1.current(1, 111.1); // Current: input pin, calibration. } void loop() { emon1.calcVI(20,2000); // Calculate all. No.of wavelengths, time-out emon1.serialprint(); // Print out all variables }
c) Open the arduino serial window
You should now see a stream of values. These are from left to right: real power, apparent power, rms voltage, rms current and power factor.
Re: How to build an arduino energy monitor
Can you recommend me which Hardware I require to develop a small project to measure Energy saved not too dissimliar to yours.
Having read your forum I'm already thinking you will save me a lot of work since the system you have is not too dissimar but I have not purchase any hardware yet and it looks like the arduino route is the way to go but which one ?
I have a system which currently switches off AC and lighting circuits for rental homes when the client is out of the premisses using a simple keyfob Timer and Relay circuit. I would like to develop a monitoring systems to show me energy saved using the efergy sensors which I already own.
I wish to Measure 2 analogue sources of Current (like 2x 110v on each line) using a small loop sensor which give me a small voltage change. Then I need to record the values and compare them to values obtained prior to them removing the keyfob which generates another signal to tell me to start counting time and multiplying that by time elapsed and the energy used thus giving me the amount of KWH saved between Client out and Client In.
I wish to store the results to show me how much energy has been saved since the last reset say and display this on a LCD (Louis project with 16 x2 chars LCD should do) which could also show me lapsed energy saved until the key is returned on the keyfob.
I have looked at the Arduino Uno option with Makershield but there are other options which seems more attractive given that I will want a more permanent solution once developped.
1) Ardweeny + Protoshield
2) Prototino
3) Boardwino
I Have yet to purchase any of these but would like guidance as to which combination I should use to develop then build my boards--- given that I might want to make about 20 of these to hand out to my clients. The Programming side looks fairly comprehensible as I was a C programmer.
I will start with building a dual Current sensor module using your code as guidance and see how I do before I need help.
Background : I'm Responsible for switching over 100KW of energy (Client cannot leave without taking key and AC and lights switch off automatically once they are gone) in 25 rental homes in a tourist town in Costa Rica and live here during the UK winters - this project is to pay for my beers and to give something back to the environment !
Jean
Re: How to build an arduino energy monitor
Hi Jean,
Sounds like an interesting project. I like the sound of your lifestyle, working with open-source hardware certainly better than bar work! I hope your not flying out there!
The choice of hardware largely down to personal choice, as all the options you suggested above will do the job. I would go for an Arduino uno with the maker shield as its the most flexible option and the option which requires the least work to get going; it's compatible with other shields, has a USB port onboard so no messing about with FTDI cables and when soldered up and housed in an enclosure is just as permanent as any other option.
If you were going to be making many more than 20 it might be worth making your own custom shield and getting it PCB'ed.
To monitor two lines you will need to use two CT's and two separate monitoring circuits (2x mains non-invasive 3.0). The two monitoring circuits can share the same voltage adapter. I have just uploaded an example Arduino sketch of two channel CT monitoring. It can be downloaded from the 'mains non-invasive 3.0' page or the 'software' page, look for TwoChannelExample. Your programming skills are probably better than mine, if you make any improvements please let me know.
Good luck, Glyn.
Re: How to build an arduino energy monitor
I ended up bying a bunch of building blocks from Solarbotics.com
I liked the idea of the Ardweeny and its bits so got that and an Ardweeny shield which makes it the same as a UNO , yes its true theres a extra FTDI breakout to buy but then you only buy that once.
Then I got a Ardweeny backpack with LEDs to play with (Use that for my Solar Differential Controller Upgrade one day ) . and finally A Protoshield for prototyping. So yes its slightly more bitsy to say the least but I will know in time if that was the right choice.
What would be good is a board like the Prototino with custom designed layout when I finalise the design. you could put in your design for the PCB and they would ship you a board with the brains + your layout area to one side and all you do is slot in your components.
Anyway I have yet to build a single thing yet so what do I know until get my hands dirty.
Will be in touch when I get my bits to Costa Rica could be a long wait !!!!
Regards
Jean
Re: How to build an arduino energy monitor
Hi
I am just trying to use the device more as a non invasive way of determining whether 240 VAC current is flowing or not ie when a Water Tank Pump is running. So I am just more looking for a digital signal to the Arduino ie High = Current flowing, Low = No Current flowing.
How do I best modify the circuit to provide that?
Cheers
Garry
Re: How to build an arduino energy monitor
You could do this in software. When current is more than a given threshold then we have flow. Not sure of the best way to modify the circuit to give a digital signal. Maybe a rectifier capacitor combination... worth a try?
Re: How to build an arduino energy monitor
Hi
I am using same configeration as yours, part from using a precision full wave rectifier to interface with the arduino board. How would i do that in term of code? will i will be needing an array to manage samples??
Re: How to build an arduino energy monitor
Hello Ying, do you have a schematic of your setup as Im not clear on what your trying to do. Have you got a rectifier connected to your CT?
Re: How to build an arduino energy monitor
Hey Trystan
let me tell you more of what i am trying to do.
My aim is to measure power on a socket level for a single appliance on different settings. For example I want to know exactly the difference between operating your washing machine on 15 degrees and 90 degrees. By a given tariff on a period of time, I will know how much i saved when i run the washing machine on lower temperatures.
I am using a precision full wave rectifier to get a unipole signal into arduino. here is a schematic of the rectifier:
http://img10.imageshack.us/i/rectnewpreamp.jpg/
my ac transformer is 220>>10V step down transformer.
will i will need to know the CT turns and burden resistor value??? it doesnt mention that in datasheet of sensor.
Re: How to build an arduino energy monitor
Are the # of loops in the CT important? I purchased a couple of CTs but realized I don't have the specs which indicate how many turns they are made up of....
They only indicate :
Input: 0-200A
Output: 0-3V
Thanks again for the excellent project and reference!
mike
Re: How to build an arduino energy monitor
I would like to ask the same question, I've purchased CT sensor from Seedstudio (Model SCT-013-030), but they don't have the spesification, could anyone help us on this?