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 Senors - Introduction

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.

logiklevel's picture

Re: How to build an arduino energy monitor

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

glyn.hudson's picture

Re: How to build an arduino energy monitor

Newbie's picture

Re: How to build an arduino energy monitor

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!

maurymw's picture

Re: How to build an arduino energy monitor

Hi

This blog valuable for us. it's very intersting.

Coaxial Adapter

 

TrystanLea's picture

Re: How to build an arduino energy monitor

hello, yes they dont need to be 5V, they need to be at least 5V. Normally 16V or 25V. Farnell, RS, rapidonline, maplin are all good sources if your in the UK.

 

Guest's picture

Re: How to build an arduino energy monitor

How do I amend the code to just monitor the amperage using one CT....

Guest's picture

Re: How to build an arduino energy monitor

Thanks.
I've waited 3 weeks for some 5v 10uf capacitors to arrive from Hong Kong and they sent me 50v 10uf (Hilarious)!

Cor's picture

Re: How to build an arduino energy monitor

Ive been thinking about building this very cool project, but adding an arduino wifi board so I can push the values realtime to a website that would graph the data. Before I go about doing that, do you see any practical problems with that?

Paul Reed's picture

Re: How to build an arduino energy monitor

 Hi Cor, you're treading in my shoes!!

I've already built the monitor, see here and it is really accurate and worth the effort.

I have also built a Nanode which in effect is a Ethernet equipped Arduino kit for £22 delivered, which again has been built and is sending sample power data to pachube, see feed 34577 .

However, I havn't managed to connect the two together yet, and could do with a little help...

The Nanode kit is brilliant, easy to build, even for a guy with dodgy eyesight and a 50w soldering iron!

Also, if you have a iPhone try the app Hubcape for viewing Pachube feeds.

Cor's picture

Re: How to build an arduino energy monitor

Pachube seems like a good way to go about it. Would save me from having to make the graphing myself. Thanks for the tip. Also didn't know about the Nanode, and that as well seems like the perfect platform for this. It would be my first venture into Arduino, so im not sure im able to help much at this point, but I am a developer/programmer/hacker so I dont expect too many problems. And ive got tons of coworkers that have already made elaborate arduino projects.