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.

Hay's picture

Re: How to build an arduino energy monitor

You find a spec datasheet here:
http://www.watterott.com/de/Wechselstrom-Messwandler-30A-max

The SCT-013-030 has a built-in burden resistor.
Therefor the output of the CT is a VOLTAGE (AC) and not a current.
The measuring range of the SCT-013-030 is 0-30 Amps AC.
The voltage should be linear with the measured current:
1 Amps AC measured gives 1 Vac on the output of the CT
30 Amps AC measured gives 30 Vac on the output of the CT

Greets, Hay

Hay's picture

Re: How to build an arduino energy monitor

Apparantly I made a mistake in my answer above....sorry for this!
The SCT-013-030 has a measuring range (Ip) of 0...30 Amps AC
The built-in resistor makes that the output of this CT is an AC Voltage.
The following relationship discribes the outputvoltage of this model CT:
Vout = (Ip/30) or Ip = Vout*30
When you want to utilize the full CT range of 30 Amps, Vout will be (30 Amps/30) = 1 Volt AC.
Another example:
When you measure 0.15 V (150 mV) on the output of this CT, the actual Ip is (Vout*30) = 0.15*30 = 4.5 Amps AC

Kind regards, Hay

Coldstorageunit's picture

Re: How to build an arduino energy monitor

Hi Guys,

 

I've been putting together this build over the last couple days and have a nagging problem on the current sense side.

I'm using a current sense transformer with 3000 turns in the secondary and have a burden resistor of 43 ohms. I should also mention that I'm using 220uF caps in the circuit as that's all I had lying around.  10KOhms on the voltage divider. 

When I pull the leads from the CT out of the circuit and measure with my multimeter I can see the voltage change as I add load. So I'm pretty sure that portion of the build is working. 

The problem is that with the CT back in the circuit the Arduino readings don't change on the current side no matter what sort of load is added. 

The voltage sensing side is working great and the numbers are bang on.  

Here's a typical set of readings from the serial monitor: 

2.06      14.28      0.14      122.25     0.12

Anyone have any ideas as to what I'm missing here?

Thanks,

-Tim

Amin Zayani's picture

Re: How to build an arduino energy monitor

Try to find a 10uF capacitor, it seems like the big cap is absorbing all change in CT generated voltage due to load increase.

TrystanLea's picture

Re: How to build an arduino energy monitor

 Hey Tim, Amin, I think the capacitor should be fine as it is across the biasing voltage divider where the voltage should be a constant DC. If the capacitor was across the output of the circuit it would absorb all the change. Have you seperated you AC cables? Clipped around only neutral or live?

Coldstorageunit's picture

Re: How to build an arduino energy monitor

 Well, I think I just made a pretty rookie mistake here. 

I had my CT clipped around the power cable; power, neutral and ground. I thought I had seen pictures on this site and others that looked like the CT was clipped around the whole cable, but now that I look at the top picture on this site a little more carefully I see that you are just clipped around the power wire. 

I'll give this a try when I get home. 

Thanks,

-Tim

Amin's picture

Re: How to build an arduino energy monitor

But I thought you said:
"When I pull the leads from the CT out of the circuit and measure with my multimeter I can see the voltage change as I add load. So I'm pretty sure that portion of the build is working. "

How is that possible?

Coldstorageunit's picture

Re: How to build an arduino energy monitor

 That's a good questions but it was definitely happening. I had a halogen desk lamp hooked up with 2 brightness levels. 

I was seeing 0.04V with the lamp off, 0.06 on low, and 0.08 on high. 

 

Dawn's picture

Re: How to build an arduino energy monitor

If it helps anyone, I ordered my cts for SEEEDSTUDIO and I calculated my CT sensors to be 1200. I don't know if all of them are 1200 but if you are ordering yours from seeedstudio you might want to use 1200 instead of 1500.

If someone else has ordered cts from SEEEDSTUDIO and found that their cts sensors are different than 1200 please hit reply. I am just curious if 1200 turns is standard for them or if it varies.

Thanks.

nedir's picture

Re: How to build an arduino energy monitor

i agree Step one – calibrating power factor..