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
Would this Arduino MEGA board do?
http://cgi.ebay.ca/Arduino-MEGA-ATmega1280-16AU-USB-board-USB-cable-16AU...
Thanks!
Re: How to build an arduino energy monitor
Hey Simon,
Thanks for the translation link.
The Arduino MEGA board looks like the one you need, but I cant quite tell if it comes with the bootloader installed, If you look halfway down the page you see the pic with the: not included USBtinyISP bootloader. Maybe its worth dropping them an email to check whether they have already loaded the arduino bootloader to the board. Otherwise it might be a safer bet is to go with the official Arduino Mega.
The Arduino Mega is meant to be compatible with most shields so you should be ok.
Trystan
Re: How to build an arduino energy monitor
This is a fantastic idea..Im trying to build it for my own house.
But please can someone please tell me where I can find the programming part, because I got lost going from one link to another....
Thanks a lot
Re: How to build an arduino energy monitor
Anyone have try to use the same circuit but in a linux environment? Same as the dallas/maxim temperature sensor, where they use a i2c (1 wire) technology to communicate or use multiple sensors in parallel and connected to usb. It would be nice to have all these sensors in linux and differentiate one from another with a code like in digitemp...
Re: How to build an arduino energy monitor
Hello Leon
All the hardware and software here has been developed in a linux environment. All you need is the arduino IDE, arduino etc, is that what you mean?
Re: How to build an arduino energy monitor
at arduino i think like on a limited in possibility hardware clone with linux.
the example of this circuit is very simple and to be ported to some linux flavor like ubuntu (may be compatible already...)
i have a project myself, and i have searched the internet for an existent solution, but somewhat with no success. This solution seems very cost effective and simple... but is with an arduino in the middle. I searched something for my ubuntu 10.04 lts and a solution with multiple sensors (more than 20pcs), but in parallel who could be read from a rj45 port like an i2c or usb (like an existent solution in parallel with multiple temp sensors from maxim/dallas who have a code embedded who differentiate one sensor from another) and in our case a clamp from another.
Any ideas?
Re: How to build an arduino energy monitor
I've been short of time lately to read as much as possible on arduino, but if i understand right the Arduino, or AVR, or another type, use a microcontroler who is responsable for transformind a digital signal in analogical signal (plese corect me if i'm wrong), so a linux solution like an ubuntu 10.04 is not possible for commanding a relay or read an external temperature (only using usb or rs232), which are not a fesable solution.
p.s. alot of reply to this message are coming in my email, but when i look in the page i do not see an update (problems?)