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.

Mr. Sharkey's picture

Re: How to build an arduino energy monitor

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.

chaseadam's picture

Re: How to build an arduino energy monitor

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.

Adam Chasen's picture

Re: How to build an arduino energy monitor

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?

nicky's picture

Re: How to build an arduino energy monitor

 Is there a reason to not share the 2.5V reference for both current sensing and voltage sensing circuit ?

 

Mr. Sharkey's picture

Re: How to build an arduino energy monitor

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.

Guest's picture

Re: How to build an arduino energy monitor

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

james.j.hedges's picture

Re: How to build an arduino energy monitor

 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.

 

glyn.hudson's picture

Re: How to build an arduino energy monitor

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. 

Sergegsx's picture

Re: How to build an arduino energy monitor

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

glyn.hudson's picture

Re: How to build an arduino energy monitor

 you have mail!