You are not authorized to post comments.

Detailed energy monitor system design

This part details the system design of the measurement part of a mains AC: non-invasive energy monitor built upon an Arduino. The system can be divided into 3 main parts:

  1. Current sensors + current sensor electronics

  2. Voltage sensor + voltage sensor electronics

  3. Arduino (the microcontroller platform)

The sensors produce signals proportional to voltage and current. The analog electronics convert these signals in to a form ready for the Arduino which in turn calculates useful values in the digital world.

Sensing current

 

Image 1 – Clip-on CT sensor.

UK: Whole house energy use is measured with 1 CT sensor.

US: Whole house energy use is measured with 2 CT sensors.

Current is measured using a sensor called a current transformer (CT). A CT sensor works by induction. The current in the mains wire produces a magnetic field in the ferrite core of the CT. A secondary coil is wrapped around the ferrite core. When a resistor is connected across the terminals of the coil a current flows that is proportional to the current in the mains wire.

The sensor just clips around the wire to be measured which means that it can be easily used to measure the electrical energy used by a whole building.

The CT sensor produces a current that is proportional to the current flowing in the mains wire by:

Isensor = CTturnsRatio * Imains

The number of secondary turns on a typical home energy monitor CT is around 1500 and so the current in the secondary is 1500 less than the current in the mains wire. The current in the secondary is also electrically isolated from the primary current. This makes household CT's a safe way of measuring mains current.

Current sensor electronics

The current sensor electronics is divided into two main parts:

  1. Current sensor and burden resistor

  2. Biasing voltage divider

Here's the circuit diagram:

 

Schematic 1 – current measurement circuit

The CT sensor produces a current that is proportional to the instantaneous current flowing in the mains wire by:

Isens = CTturnsRatio x Iinst

The resistor in parallel with the CT sensor is called a burden resistor and converts the current Isens into a voltage:

VsensI = Burden Resistance x Isens

The two Rvd resistors from a voltage divider that outputs a voltage at half the Arduino supply voltage of 5V. This voltage biases the AC voltage produced by the CT sensor and burden resistor by 2.5V, needed because the Arduino analog input channel requires a positive voltage.

Voltage at analog input = Bias Voltage + VsensI

The capacitor C1 stabilizes the DC bias as this can often be a source of considerable noise.

Suitable sizes for resistors Rvd are 10 to 100k. Higher resistance lowers energy consumption but also increases noise.

A suitable value for C1 is 10uF.

Choosing the size of the burden resistor

  1. Choose the power range you wish to measure.

  2. Divide by the mains voltage to give mains current.

  3. Convert the mains current from an RMS value to a Peak value by multiplying by sqrt(2).

  4. Divide this peak value by the CTturnsRatio to give the current in the secondary coil.

  5. The Burden resistor that gives the specified range is equal to 2.5V divided by the current in the secondary coil.

For quick reference:

A 100Ohm burden resistor with an efergy CT gives a current measurement range of 0 to 26.5Amps.

A 56Ohm burden resistor with an efergy CT give a current measurement range of 0 to 47.4Amps.

Efergy CT turns ratio: 1:1500

CT's also have an intrinsic phase shift of 0.1 to 0.3 degrees

A useful web page for calculating burden resistor size, CT turns and max Irms

Thanks to Tyler Adkisson for building and sharing this: http://tyler.anairo.com/?id=5.3.0



Sensing Voltage

 

Image 2 – AC to AC power adaptor

Voltage can be measured using an AC to AC step down power adapter. Using the power adapter method rather than making a direct measurement on the high voltage side maximizes safety as no high voltage work is needed.

Sensor Electronics

The voltage sensor electronics is divided into two main parts:

  1. Step down voltage divider

  2. Biasing voltage divider

Here's the circuit diagram:

 

Schematic 2 – voltage measurement circuit

The step down voltage divider scales the AC voltage coming from the voltage adapter down from 9V to around 1V peak-peak.

The resistors R3 and R4 form a voltage divider that outputs a voltage at half the Arduino supply voltage of 5V. This voltage biases the AC voltage produced by the AC adapter and burden resistor by 2.5V, needed because the Arduino analog input channel requires a positive voltage.

Voltage at analog input = Bias Voltage + VsensV

The capacitor C1 stabalizes the DC bias as this can often be a source of considerable noise.

R1 and R2 need to be chosen to give a peak to peak voltage of around 1V.

Suitable sizes for resistors R3 and R4 are 10 to 100k. Higher resistance lowers energy consumption but also increases noise. Suitable size for R1 is 10K and R2 is 100K

A suitable value for C1 is 10uF.

The Arduino

The arduino is the heart of the system and also the bridge in-between the analog world of electronics and the digital world of software. The arduino makes it possible to graph energy consumption on a computer, upload information to the internet and display information on lcd's with ease.

For the basic energy monitor setup the Arduino takes the input from the sensors and sensor electronics, calculates values for real power, apparent power, power factor, rms voltage and rms current and outputs these values to the USB port were we can access them on the computer.

The interface between the analog and the digital world, the ADC

The Arduino turns the analog input signals into digital information with an on-board Analog to Digital converter.

The Arduino ADC has a resolution of 10bits this along with the sample rate determines the detail of the digital representation of the input analog signal. The Arduino analog input has a default input range of 0 to 5V (this can be changed). 10 bits means we can divide that range in to 2^10 or 1024 divisions. The ADC therefore has a 5V / 1024 = 4.8mV sensitivity (It can detect changes in the input voltage of 4.8mV).

An analog input is read by the command: sample = analogRead(pinNumber).

sample is an integer. If the voltage at the pin is 0 sample = 0. If the voltage is 5V, sample = 1024. If the voltage is equal to 2.5V, sample = 512 and so forth.

Arduino Sketch Structure

The Arduino sketch is structured as follows:

variable deceleration and setup

void loop()

{

for n=0 to numberOfSamples

{

read in voltage and current sample

remove voltage and current sample offset with digital high pass filter

correct current phase displacement with linear interpolation caused by: ADC multiplexing,

inherent CT and power adapter phase displacements.

accumulate squares of voltage and current for rms calculation

accumulate product of voltage and current for real power calculation

}

calculate values for real power, apparent power, power factor, rms voltage, rms current from accumulators

apply voltage and current calibration coefficients.

print values to USB serial

reset accumulators.

}

For a more detailed treatment of calculating values for real power, apparent power, power factor, rms voltage, rms current, have a look at AC Power Theory 1 and 2.

madmurg's picture

help with code

can someone see my mistake as i can not see why I cant get a reading for apparentpowersolar. the reading is 0.

apparentpower is working ok and i know the electronic circuit is ok here is my code.

 

//Basic energy monitoring sketch
//Authors: Trystan Lea, Eric Sandeen

//Licenced under GNU General Public Licence more details here
// openenergymonitor.org

//Sketch measures voltage and current.
//and then calculates useful values like real power,
//apparent power, powerfactor, Vrms, Irms.
#include <LiquidCrystal.h>

// Connections:
// rs (LCD pin 4) to Arduino pin 12
// rw (LCD pin 5) to Arduino pin 11
// enable (LCD pin 6) to Arduino pin 10
// LCD pin 15 to Arduino pin 13
// LCD pins d4, d5, d6, d7 to Arduino pins 5, 4, 3, 2
LiquidCrystal lcd(12, 11, 10, 5, 4, 3, 2);

int backLight = 13; // pin 13 will control the backlight
//Setup variables
int numberOfSamples = 3000;

//Set Voltage and current input pins
int inPinV = 2;
int inPinI = 1;
int inPinIsolar = 0;
//Sanity check calibration method thanks to Eric Sandeen http://sandeen.net/wordpress
//See discussion here: http://openenergymonitor.org/emon/node/59
//Enter the values of your setup below

// Voltage is reduced both by wall xfmr & voltage divider
#define AC_WALL_VOLTAGE 235
#define AC_ADAPTER_VOLTAGE 9
// Ratio of the voltage divider in the circuit
#define AC_VOLTAGE_DIV_RATIO 11
// CT: Voltage depends on current, burden resistor, and turns
#define CT_BURDEN_RESISTOR 56
#define CT_TURNS 1500

//Calibration coeficients
//These need to be set in order to obtain accurate results
//Set the above values first and then calibrate futher using normal calibration method described on how to build it page.
double VCAL = 1.0;
double ICAL = 1.64;
double PHASECAL = 2.3;

int a = 9; // analog output pin with connected triak
int v = 0; // analog output value

// Initial gueses for ratios, modified by VCAL/ICAL tweaks
#define AC_ADAPTER_RATIO (AC_WALL_VOLTAGE / AC_ADAPTER_VOLTAGE)
double V_RATIO = AC_ADAPTER_RATIO * AC_VOLTAGE_DIV_RATIO * 5 / 1024 * VCAL;
double I_RATIO = (long double)CT_TURNS / CT_BURDEN_RESISTOR * 5 / 1024 * ICAL;
double I_RATIOsolar = (long double)CT_TURNS / CT_BURDEN_RESISTOR * 5 / 1024 * ICAL;
//Sample variables
int lastSampleV,lastSampleI,sampleV,sampleI,sampleIsolar,lastSampleIsolar;

//Filter variables
double lastFilteredV, lastFilteredI, filteredV, filteredI,lastFilteredIsolar,filteredIsolar;
double filterTemp;

//Stores the phase calibrated instantaneous voltage.
double shiftedV;

//Power calculation variables
double sqI,sqV,instP,sumI,sumV,sumP,sqIsolar,instpsolar,sumIsolar,sumpsolar;

//Useful value variables
double realPower,
apparentPower,
powerFactor,
Vrms,
realpowersolar,
apparentpowersolar,
powerFactorsolar,
realPowersolar,
apparentPowersolar,
Irmssolar,
sparepower,
sum,
Irms;

void setup()
{
Serial.begin(9600);
}

void loop()
{

for (int n=0; n<numberOfSamples; n++)
{

//Used for offset removal
lastSampleV=sampleV;
lastSampleI=sampleI;
lastSampleIsolar=sampleIsolar;
//Read in voltage and current samples.
sampleV = analogRead(inPinV);
sampleI = analogRead(inPinI);
sampleIsolar = analogRead(inPinIsolar);

//Used for offset removal
lastFilteredV = filteredV;
lastFilteredI = filteredI;
lastFilteredIsolar = filteredIsolar;
//Digital high pass filters to remove 2.5V DC offset.
filteredV = 0.996*(lastFilteredV+sampleV-lastSampleV);
filteredI = 0.996*(lastFilteredI+sampleI-lastSampleI);
filteredIsolar = 0.996*(lastFilteredIsolar+sampleIsolar-lastSampleIsolar);
//Phase calibration goes here.
shiftedV = lastFilteredV + PHASECAL * (filteredV - lastFilteredV);

//Root-mean-square method voltage
//1) square voltage values
sqV= filteredV * filteredV;
//2) sum
sumV += sqV;

//Root-mean-square method current
//1) square current values
sqI = filteredI * filteredI;
sqIsolar = filteredIsolar * filteredIsolar;
//2) sum
sumI += sqI;

//2) sum
sumIsolar += sqIsolar;
//Instantaneous Power
instP = shiftedV * filteredI;
instpsolar = shiftedV * filteredIsolar;
//Sum
sumP +=instP;
sumpsolar +=instpsolar;
}

//Calculation of the root of the mean of the voltage and current squared (rms)
//Calibration coeficients applied.
Vrms = V_RATIO*sqrt(sumV / numberOfSamples);
Irms = I_RATIO*sqrt(sumI / numberOfSamples);
Irmssolar = I_RATIOsolar*sqrt(sumIsolar / numberOfSamples);
//Calculation power values
realPower = V_RATIO*I_RATIO*sumP / numberOfSamples;
apparentPower = Vrms * Irms;
powerFactor = realPower / apparentPower;

realpowersolar = V_RATIO*I_RATIO*sumpsolar / numberOfSamples;
apparentpowersolar = Vrms * Irmssolar;
powerFactorsolar = realPowersolar / apparentPowersolar;

//Output to serial
//Serial.print(realPowersolar);
//Serial.print(' ');
//Serial.print(apparentPowersolar);
//Serial.print(' ');
//Serial.print(powerFactor);
//Serial.print(' ');
//Serial.print(Vrms);
//Serial.print(' ');
//Serial.println(Irmssolar);

//Reset accumulators
sumV = 0;
sumI = 0;
sumP = 0;
sumIsolar=0;

Serial.begin(115200);
pinMode(backLight, OUTPUT);
digitalWrite(backLight, 'high'); // turn backlight on. Replace 'HIGH' with 'LOW' to turn it off.
lcd.begin(16,2); // columns, rows. use 16,2 for a 16x2 LCD, etc.
lcd.clear(); // start with a blank screen
lcd.setCursor(0,0); // set cursor to column 0, row 0 (the first row)
lcd.print("Power Mains "); // change this text to whatever you like. keep it clean.
lcd.setCursor(0,1); // set cursor to column 0, row 1
lcd.print(double(apparentPower));lcd.print(" Watts");
delay(3000);
lcd.clear();
lcd.print("Power Solar ");
lcd.setCursor(0,1); // set cursor to column 0, row 1
lcd.print(double(apparentPowersolar));lcd.print(" Watts");
delay(3000);
sparepower=apparentpowersolar/apparentPower;
sum=3000/sparepower;
v=1024/sum;
analogWrite(a, v); // set analog out pin a to value v
delay(10);
//Reset values ready for next sample.
sumI=0.0;

// if you have a 4 row LCD, uncomment these lines to write to the bottom rows
// and change the lcd.begin() statement above.
//lcd.setCursor(0,2); // set cursor to column 0, row 2
//lcd.print("Row 3");
//lcd.setCursor(0,3); // set cursor to column 0, row 3
//lcd.print("Row 4");

}
 

Anonwelder's picture

Apparentpowersolar

Hi.

 

I don't know if this has a bearing, but you have two occurances of apparentpower solar in part of your code..?

 

//Useful value variables
double realPower,
apparentPower,
powerFactor,
Vrms,
realpowersolar,
apparentpowersolar,
powerFactorsolar,
realPowersolar,
apparentPowersolar,
Irmssolar,
sparepower,
sum,
Irms;

and a reference to both later in your code

lcd.print(double(apparentPowersolar));lcd.print(" Watts");
delay(3000);
sparepower=apparentpowersolar/apparentPower;

AW

acac1313's picture

Voltage sensing

 Amateur question:

1. What exactly is the meaning of non invasive?

2. Is there any other way to measure the input voltage except the AC AC adapter? (meaning other sensors etc.)

BTW awesome documentation of your work!

bside's picture

AC to AC Adapter

I need an ac-ac adaptor  but in Farnell  are No longer Manufactured is possible to use a Transformer (pcb version for example)   with Primary Voltages 230V  and Secondary 9V ? 

Please let me know 

 

Thanks in advance.

 

Regards 

Francesco.

Anonwelder's picture

Source for AC-AC adaptor

Maplins sell the plug-in type. Google 'N57AT' and it should find, if not the same one, then the newer design.

Richard's picture

working with multiple inputs

Hi,

I am trying to design an arduino energy monitor, but I would like to measure the power consumption of each breaker. Therefore, My problem is that I do not know how to connect those multiple inputs to the Arduino. Do you know any method that can convert those multiple input into one for the arduino.

Thank you

Krumlov's picture

No is the answer to your

No is the answer to your question but you could use multiple CTs and just add all of the individual powers together in software on the Arduino. I have three phase power so that is the same as monitoring 3 breakers. Have a look at my post here: http://openenergymonitor.org/emon/node/259

pd.gomes89's picture

AC-AC adapter

Sorry this may look stupid, but I need an ac-ac adaptor for an EURO plugin (not UK) but in Farnell I only find ac-dc adaptors. Can you give me a help. Thanks in advance.

ViniciusB1985's picture

Number of samples

Hi TrystanLea,

What number of samples should I use?

Thanks.

 

Guest's picture

Help me with building energy meter for 3 phase AC power

Is it possible to build energy meter for 3 phase AC supply using arduino? If you have any idea please help me

Krumlov's picture

Yes

Have a look at my posts in the "Questions and Support" forum. Topis is "A Few Questions"

http://openenergymonitor.org/emon/node/259

Denny's picture

code

I don't know these lines of codes.
Can someone explain to me these lines of code?

#define CT_BURDEN_RESISTOR 68
#define CT_TURNS 1012
#define AC_ADAPTER_VOLTAGE 15.2
#define AC_ADAPTER_RATIO (AC_WALL_VOLTAGE / AC_ADAPTER_VOLTAGE)

filteredV = 0.996*(lastFilteredV+sampleV-lastSampleV);
filteredI = 0.996*(lastFilteredI+sampleI-lastSampleI);

shiftedV = lastFilteredV + PHASECAL * (filteredV - lastFilteredV);

TrystanLea's picture

Re: code

 The first four lines are configuration variables

CT_BURDEN_RESISTOR = resistance of your burden resistor

CT_TURNS = number of turns in your ct

AC_ADAPTER_VOLTAGE = rms voltage of your ac adapter

AC_ADAPTER_RATIO = the ratio that the ac adapter voltage is scaled by the step down voltage divider.

filteredV = 0.996*(lastFilteredV+sampleV-lastSampleV);
filteredI = 0.996*(lastFilteredI+sampleI-lastSampleI);

are part of the Digital High pass filter code. The digital high pass filter removes the DC offset of 2.5V or 512(analog reading) that is recorded by the analog channel sampling, the result is a digital representation of the sensed AC waveform that center's around 0V.

ShiftedV removed the phase offset associate with the different hardware components.

 

 

 

Denny's picture

Thank you explain. I have

Thank you explain.

I have other question.

The capacitor C1 stabalizes the DC bias as this can often be a source of considerable noise.<<<<<<<<<<<<<<< I don't knwo real mean! Would you explain detail?

Thank you!

JrBenito's picture

Voltage bias

Hi,

If this is a dummy question please let me know:

Wouldn't be better to use a voltage reference CI to produce accurate bias voltage of 2.5v?

I mean, as you stated the bias voltage could be a source of noise. The choice of divider resistor values will also make the circuit more or less susceptible to noise and there is no way to predict the resistors value variance in function of ambient temperature. I think both resistor could also present different values and the cost of precision resistors could justify the reference stabilized CI.

Am I too wrong?

Regards,
Benito.

Amin Zayani's picture

Ceramic/Tantalum capacitors instead of the electrolytic?

 Do the capacitors need to be electrolytic? Ceramic or tantalum with the same value are suitable?

Robert's picture

Variant for burden resistor calculation

I was having trouble calculating the burden resistor necessary for my 5 current sensors. I have 2 200-Amps on the mains coming into the house (I live in north-america), 2 100-Amps floating on different individual breakers and 1 30-Amps also floating.
Each sensor type has a different number of turns on the secondary coil. These figures are not published. I could guess the turn-ratio based on max current output from the manufacturers site. For example, the SCT-013-000 outputs a maximum current of 33 milli-Amp at 100 Amps. In theory. I have two of those, and they have different readings for a given current.

To calculate the burden resistor value for each sensor, I used a known amperage value load, from the reading of a Kill-A-Watt (two 400-Watts lamps) giving me 6.88 Amps.
So for the 200-Amps: I want to be able to monitor total energy usage for the whole house. In my home, each branch coming into the house can supply 100 Amps (for 200-Amps total). I want to maximize the sensitivity on the analog-to-digital pin of the Arduino. This is the key. If a 100 Amps current passes through the sensor, I want the analog pin to read 1024 (this is the maximum value that an analog pin can report, at 5 volts. The circuit suggested in these pages uses a voltage divider (two 10K resistors). So if no current passes through the sensor, you can expect to read 512 on the analog pin. To measure this reading on the analog pin, I used this piece of code in my energy monitor program:

tmpRead = analogRead(analog-pin-for-this-sensor);
if(tmpRead > maxRead)
maxRead = tmpRead;
Serial.print(maxRead);

where tmpRead and maxRead are integers

Since I want to measure a maximum of 100 Amps, I use 6.88/100 * 512 = 35. So I should choose a resistor that will give me a reading of 547 on the analog pin. Let's look at the formula:

D = Amp / max-Amp * analogRead(no-load)

or

know-amp-value-from-Kill-a-watt / maximum-amperage-expected-on-this-wire * mid-range-point-from-voltage-divider. So, in this case, a deflection of 35 on the analog pin corresponds to 6.88 Amps on the wire, related to an expected maximum of 100 Amps.

In practice, using the code above, I choose an analog pin and measure the idle value with any burden resistor (try any between 50 and 1000 Ohm). The value on the analog pin (maxRead above) should be close to 512 but can vary because of resistor precision in the voltage divider). I then use a known amperage (hence the Kill-A-Watt) and read the analog pin again. I choose a resistor that will give me a deflection of 35 (for my sensor) using a simple division.

As you can see, this is independent of the type of sensor used. Of course, you have to plan to measure a maximum amperage within the range of your sensor, and I would recommend a safety margin so you don’t overload the analog pin.

Robert's picture

Recalculate the burden resistors on 3.3 volts

 I live in Canada. Mains is 120-240 volts. I switched to 3.3 volts Arduinos ( jeelab's jeenodes) and recalculated the burden resistors for my CTs. I have two sct-019-000 that can measure up to 200 Amps. I biased them for 132 Amps each on the two 240 volts branches by using 68 ohms resistors (calculated using the methods above).  I also have two sct-013-000 CTs that I biased for a max 50 Amps reading by using 47 ohms resistors. They have been tested/calibrated using a Kill-a-Watt, and then rechecked "in circuit" using a clip on Amp meter.  

Robert's picture

Recalculate the burden resistors on 3.3 volts

 I live in Canada. Mains is 120-240 volts. I switched to 3.3 volts Arduinos ( jeelab's jeenodes) and recalculated the burden resistors for my CTs. I have two sct-019-000 that can measure up to 200 Amps. I biased them for 132 Amps each on the two 240 volts branches by using 68 ohms resistors (calculated using the methods above).  I also have two sct-013-000 CTs that I biased for a max 50 Amps reading by using 47 ohms resistors. They have been tested/calibrated using a Kill-a-Watt, and then rechecked "in circuit" using a clip on Amp meter.  

Guest's picture

what is the part of filter v

what is the part of filter v and filter i in the program do?? im getting all mixed up..

//Filter variables
double lastFilteredV, lastFilteredI, filteredV, filteredI;
double filterTemp;

double shiftedV; //instantaneous voltage saved

double sqI,sqV,instP,sumI,sumV,sumP; //calculation of power using the variables

void setup()
{
Serial.begin(9600);
}

void loop()
{

for (int n=0; n {

//Used for offset removal
lastSampleV=sampleV;
lastSampleI=sampleI;

//Read from analog in for sample of current and voltage
sampleV = analogRead(PinV);
sampleI = analogRead(PinI);

//Used for offset removal
lastFilteredV = filteredV;
lastFilteredI = filteredI;

//Digital high pass filters to remove 2.5V DC offset.
filteredV = 0.996*(lastFilteredV+sampleV-lastSampleV);
filteredI = 0.996*(lastFilteredI+sampleI-lastSampleI);

//Phase calibration goes here.
shiftedV = lastFilteredV + PFCAL * (filteredV - lastFilteredV);

//Root-mean-square method voltage
//1) square voltage values
sqV= filteredV * filteredV;
//2) sum
sumV += sqV;

//Root-mean-square method current
//1) square current values
sqI = filteredI * filteredI;
//2) sum
sumI += sqI;

//Instantaneous Power
instP = shiftedV * filteredI;
//Sum
sumP +=instP;
}

//Calculation of the root of the mean of the voltage and current squared (rms)
//Calibration coeficients applied.
Vrms = V_RATIO*sqrt(sumV / Samples);
Irms = I_RATIO*sqrt(sumI / Samples);

i just cant understand anything :/

im sry if im causing any trouble

Guest's picture

Can anybody explain to me

Can anybody explain to me this part please.. coz i still cant understand it and its been weeks asking there and there and no answer :(

TrystanLea's picture

Re: filtered values

filteredV and filteredI is the input signal with the offset removed. The offset is removed by what is called a digital highpass filter. The input signal is a sinusoid that centres around 2.5V or 512 analog read reading. The digital high pass filter removes this 512 offset as it where.

Guest's picture

http://www.arduino.cc/playgro

http://www.arduino.cc/playground/Main/Smooth

hmm i think this gives a kind of answer

Guest's picture

can someone explain to me

can someone explain to me these two lines of code??
#define AC_WALL_VOLTAGE 122
#define AC_VOLTAGE_DIV_RATIO 11

TrystanLea's picture

Re: calibration constants

These are callibration constants that are used in the sketch to create a quick calibration.

AC_WALL_VOLTAGE 122  -> Your mains voltage 110V in the US, 230V in UK.

AC_VOLTAGE_DIV_RATIO 11 -> The amount that the Voltage adapter input voltage divider scales down the voltage adapter input by.

Hope that helps

Guest's picture

hey guys, if i chose r3 and

hey guys,
if i chose r3 and r4 to be 10 k.....then which sizes are best for r1 and r2 in the voltage sensor part...
many thanks

TrystanLea's picture

Re: choosing R1 and R2

Hello, The magnitude of R1 and R2 depends on the output of your AC-AC adaptor. It will usually say on the adaptor someware that its output is 9VAC or 12 or so on. What is the spec of your adaptor?

Guest's picture

mine is 9VAC , 500mA and 5Va

mine is 9VAC , 500mA and 5Va output.. and input -230v, 50Hz and 11.W

TrystanLea's picture

Re: choosing R1 and R2

Great thanks, so what you need to do is to scale down the 9VAC RMS (12.8 peak: rms x sqrt(2) ) to close to 1 V peak. 100k for R2 and 10k for R1 would work well reducing the voltage to 1.16V peak which should be fine. Are you running your arduino at 5V?

Guest's picture

yes at 5v, iv built a power

yes at 5v, iv built a power supply for it only, so it can run alone at different places...thanks a lot eeee :D

Guest's picture

may i ask.. which reasoning

may i ask.. which reasoning you followed in order to come up with the two circuits shown above?is there any principles to follow
thanks a lot

TrystanLea's picture

re reasoning

Can you be more specific? Most of the detail of the design is documented above.

Guest's picture

if I chose a 560 ohms burden

if I chose a 560 ohms burden resistor..than both the rvd's how much should they be??

Guest's picture

even for r1 and r2...

even for r1 and r2...

glyn.hudson's picture

Burden resistor sizing

 Hi, 

The burden resistor you choose depends on the type of CT (number of turns) and what power level (how many amps) you plan to measure. For example: if you are using the Efergy CT and wish to measure up to about 47A (11.3Kw @ 240V) then you should use a 56ohm burden resistor. The voltage divider resistor values should both be identical, their value is a trade off between noise and quiescent power consumption. We often go for 2x 10K ohm if running off a power adapter of 470K if running off battery.

Hope this is useful, good luck and have fun!

Glyn. 

Guest's picture

the electronics of sensing

the electronics of sensing current and voltage are both connected with the same arduino?? and which type of arduino they are connected to?? thanks

glyn.hudson's picture

Re: Voltage and current sensing

Hi,

Yes they are both connected to an Arduino. See the diagram on this page for an explination of this. Any Arduino will work, we often use an Arduino Uno, Arduino Duemilanove or Seeduino. 

All the best, Glyn. 

Guest's picture

i really appreciate your

i really appreciate your answer..thanks a lot :)

voodoo's picture

Question About CT sensors in Series

What is the best way to Join 2 efergy CT sensors in Series for Monitoring 2x 110V lines simultaniously ? Can I just have 2x 3.5mm female jack and join them like a series circuit. Also do I need to change the Burden resistor values to accomodate the fact that I have joined the CT sensors together ?

glyn.hudson's picture

Re: Question About CT sensors in Series

 Hi,

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. 

If you use our software or hardware designs please drop us a link or send us a copy of your project, we are always interested to see how its used, We hope to build up example of implementations on the 'builds' and 'case studies' pages. 

Hope this helps, Glyn. 

Brian's picture

Question about multiple circuits

Hi. I have found this to be a great resource for getting me started monitoring power in my house. I have a few questions though:

I was planning on installing 24 of the "Non-invasive AC current sensor (30A max)" from seeedstudio to monitor each circuit. I would use some 4051 analog multiplexing chips so one arduino could monitor everything. Do you think I would be able to use one voltage divider+cap to bias the AC voltage coming from the CT's to bias all of the CT's?

Additionally, with regard to the bias circuit for monitoring current. I assume that you would want to bias the AC such that the bottom of the waveform is zero? For example, if the CT's I am looking at at 3v AC, I would want to bias those with 3v DC?

Thanks!

Robert's picture

I use one voltage divider+cap

I use one voltage divider+cap for 5 sensors without problems. The voltage is stable. I use one burden resistor per sensor, each connected to an analog pin. In your case, the 30A sensor outputs a voltage, I think. So you wouldn't need burden resistors. One of my sensors is that type and works well.

TrystanLea's picture

Re: Question about multiple circuits

You would need to bias it by the AC peak voltage, so if its 3v rms then a bias of about 4.2 would be needed. HOwever this would cause the output voltage to swing higher than 5.5V and potentially damage the arduino so it may be best to add a voltage divider to step down the voltage.

Scott McGurk's picture

Hi, Im planning to add one of

Hi,

Im planning to add one of these to my house, but have a quick question.

The burden resistor, can the value of this be less than 56R to allow measurement higher than 47Amps? (44ohm for 60Amps for example?)

Should I worry about the power rating of the burden resistor?

Cheers, and very impressive project!

Scott

Esko's picture

Hi ! This is interesting and

Hi !

This is interesting and just what I have been looking for.

Where have you got (purchased) the CT sensor(s), shown in the Image 1 ?

TrystanLea's picture

Hey Esko I get my CT's from

Hey Esko

I get my CT's from efergy, they are the best value that I can find in the uk and also exellent service,

http://www.efergy.com/Products/efergy-Shop-Accessories/EFERGY/Jackplug-Extra-Sensor/pid-184334.aspx

you can get them from seeedstudio too http://seeedstudio.com/

 

Trystan

Eric's picture

Hi Trystan - A couple dumb

Hi Trystan - A couple dumb questions from me about the arduino sketch...

1) What's the magic 0.996 value in the digital highpass filter? Could use a comment. :)

2) I'm thinking there should be a "nominal" VCAL just as a sanity check; assume I have XXX VAC at the wall, YY VAC coming out of the adapter, and YY/11 VAC in the middle of the voltage divider ... there should be some known/nominal VCAL given the wall voltage, the AC stepdown voltage, and the voltage divider properties, right?

We want to turn the arduino analog read value into the instantaneous Vac at the wall... So we have to scale it back up by all the factors involved.

(below assumes we've filtered out the DC offset already)

a) multiply by arduino scaling 5/1024 to convert the value read to the voltage read at the arduino.
b) multiply by voltage divider scaling (R1+R2)/R1 to get to the value at the AC adapter output
c) multiply by AC adapter scaling - (measured Vwall/Vadapter ratio) to get to the current wall value.

So, to go from (value read) to (wall voltage) I think we need to multiply by:

(Vwall/Vadapter)*((R1+R2)/R1)*(5/1024). For my case of 120VAC wall, 12VAC adapter, and 1/11 (10:1) reduction voltage divider, this would give me about 0.537 as a VCAL starting point, does that sound right?

If that all sounds right, maybe it'd be nice to have variables for the above values in the sketch, and scale by that initially, then let VCAL do the final tweaking; IOW VCAL would usually be closer to 1.0

(However, above only works if PHASECAL is 1.0 ... OTOH Vrms should be whatever it is, regardless of the phase calibration, right? So not quite sure how/why PHASECAL affects the measured Vrms, I guess it's because we're sampling over time and have to "scale" the voltage in the loop to accomidate the net effect of the phase shift...?)

Thanks,
-Eric

TrystanLea's picture

Sorry for the late reply on

Sorry for the late reply on this

1) The magic 0.996 was the value I think ATMEL used in their power meter example, it worked so I kept it the same. 

2) Yes there should be, do you think though that many people will be using different step down transformers and voltage dividers and so a calibration will need to be done anyhow, specially given different voltages around the world? I could leave my setups calibration in there though as  a guide, although it should be stressed that using it would not give accurate results even if components are the same, due to tolerances.

Trystan

Eric Sandeen's picture

As for the 0.996 value So

As for the 0.996 value

So this is a digital highpass filter and 0.996 is α ... I actually had this stuff in grad school but don't remember it at all now ;)

However, we -know- what the DC offset is; it's 2.5V (or as close to that as the voltage divider is accurate) so I just subtracted 511 from the value, it's a lot less computationally intensive...

Eric Sandeen's picture

The initial calibration may

The initial calibration may not be that important

... if you need to measure it and adjust it anyway, but it might be nice for people who have no reference meter to get at least a decent starting point for the values.

Plus it's a sanity check on the rest of the calculations; in my setup I only had to tweak VCAL (0.9820) and ICAL (1.0249) a little bit away from 1.0.

I did something like this:

// Voltage is reduced both by wall xfmr & voltage divider
#define AC_WALL_VOLTAGE        122
#define AC_ADAPTER_VOLTAGE     15.2
// Ratio of the voltage divider in the circuit
#define AC_VOLTAGE_DIV_RATIO   11

// CT: Voltage depends on current, burden resistor, and turns
#define CT_BURDEN_RESISTOR    68
#define CT_TURNS              1012

//Calibration coeficients
//These need to be set in order to obtain accurate results
double VCAL = 1.0;
double ICAL = 1.0;
double PHASECAL = 2.3;

// Initial gueses for ratios, modified by VCAL/ICAL tweaks
#define AC_ADAPTER_RATIO       (AC_WALL_VOLTAGE / AC_ADAPTER_VOLTAGE)
double V_RATIO = AC_ADAPTER_RATIO * AC_VOLTAGE_DIV_RATIO * 5 / 1024 * VCAL;
double I_RATIO = (long double)CT_TURNS / CT_BURDEN_RESISTOR * 5 / 1024 * ICAL;

...

//Calculation of the root of the mean of the voltage and current squared (rms)
//Calibration coeficients applied. 
Vrms = V_RATIO*sqrt(sumV / numberOfSamples); 
Irms = I_RATIO*sqrt(sumI / numberOfSamples); 

//Calculation power values
realPower = V_RATIO*I_RATIO*sumP / numberOfSamples;

*shrug* it's up to you :)