Measuring AC mains energy use the non-invasive current transformer method

 

Note: there is now a new version that also measures voltage. It can be found here:

Measuring AC mains energy use non-invasively with a CT sensor and power adapter

 

This method of measuring mains AC electrical energy use is quite nice, it doesn't require any breaking of the mains wire, which makes it nice and safe, you just clip-on to the wire a sensor called a current transformer (CT) that measures the current flowing through either the live or neutral mains wire. It does this by measuring the magnetic field that surrounds the wire, created by the current. The simplicity of just clipping on the sensor means that it can be used to measure the electrical energy used by the whole house. It a method used by many commercial devices that you can buy.

How it works

The electronics only physically measures current which is measured using a CT sensor which produces a small secondary current that is proportional to the current in the mains wire. In the case of the efergy elite sensor the secondary current is 1500 times smaller than the current in the mains wire. A small resistor is then placed in parallel with the CT to produce a voltage proportional to this current. The voltage is then biased (shifted up) by 2.5V using a voltage divider. This allows you to measure both the negative and positive component of the waveform due to 0 -5V input requirement of the Arduino.

The program on the Arduino then calculates the RMS current and with a manually entered value for RMS Voltage (230V in the UK, 110V in the US) it can calculate a value for apparent power. More on this program detailed below.

There is also an alternative experimental arduino program that can calculate in addition real power and powerfactor by synthesising a voltage waveform that is in phase with the peak of the current waveform – this gives the same result as the main program for all normal real loads like heaters and incandescent lightbulbs but can accurately calculate the power factors of less than 1.0 for loads with non-linear current draws such as laptops but does not work for “real” reactive loads such as washing machines and fridges. For more information and the code for this visit this page.

How to build it

Circuit Schematic


 

Components required


 

  • Efergy Elite Sensor (or similar current transformer sensor).   Efergy Shop - £7.50.

I got an email from Seeedstudio who kindly offered to cater for any parts for this project, they currently stock 1 current transformer sensor that has current output: 100A CT  $9.78 and are working on an arduino datalogging project called Seeeduino Stalker. I haven't had the chance to test their sensor so I would recommend going for the efergy if you have a choice.

  • 6way header (To broken down in to 1x 1pin, 1x 2pin and 1x 3pin for Sheild-Arduino connection)    farnell £0.162
  • 10way sockets (To be divided in two) farnell
  • Stripboard farnell -£4.73 (you will have a lot left over for other projects)

Total cost of build: £35.76

Step 1

Place the header pins through the stripboard. First you will need to move the little plastic bit to one side of the pins. Make sure that the single pin goes to Arduino analog in 0, the double pin to GND and 5V and the triple pin to Arduino digital in/out pins 5 to 7.


 

Step 2

If you would like to connect up a 7 segment display or make the digital pins below the stripboard accessible for any other reason: Insert and solder in the first 5way socket connector nearest to the digital pins. The second header is used to place Rsens in a way that it can be changed so that you can change the range of current that can be measured.

Hint: To keep it in place while soldering use a couple of striped bits of wire about 5mm longer than the header then insert in to headers and then insert other end into breadboard.

Note: When building the board and taking the pictures I for some reason soldered in the second header after stage 4 but there's no reason why it shouldn't be done at this point.

Step 3

Place and solder both 100kOhm resistors used for the biasing voltage divider.


 

Step 4

Place the 100Ohm resistor used as a current limiter.


 

Step 6

Place the 3.5mm jack used to connect up the efergy CT sensor. I found you can cut off the side pin on the jack and just keep the one at the end and the one on the bottom.

Step 7

Place wire jumpers that route 5V and GND along to the 7 segment display socket.


 

Step 8

Remove some of the copper track. There are 6 breaks to make as in the picture below (let me know if its not clear enough) you can do this with the stripboard tool or a small drill bit.


 

Step 9

Connect the mini shield to the arduino making sure that its inserted into the correct pins as described in step 1.


 

Step 10

Connect up the CT sensor.


 

Step 11

Once your happy there are no shorts and everything is looking good connect it up to the computer the arduino power light should be on as usual and hopefully nothing will be smoking :)

right on to the software

Software side

Step 1 – Arduino software:

Download the Arduino sketch here

Step 2 – Computer side

  1. Download the ArduinoComm java program here.

  2. Unzip ArduinoComm.tar.gz

  3. Compile the program by typing $ javac *.java

  4. Run the program with $ java Program

For a 'How to' on compiling and running java programs have a look here. (It also details installation of rxtx library)

For more information about ArduinoComm visit this page

If its all working you should see something like this appear in your terminal window:

153.25 230.00 0.63
126.76 230.00 0.62
128.24 230.00 0.63
....

From left to right we have: apparent power, rms voltage, rms current.

Now clip the sensor around the live wire of a test power strip as in the picture below and connect up some a load something in the 100W range. The value for apparent power and Irms should go up but you may need to calibrate as described below to get accurate values.

Calibration

The values coming out of the sensor probably wont be correct if you compare it with a commercial plug in meter even if you use the a 100Ohm resistor and the same CT Sensor as specified above. I have a couple of CT sensors now and each one seems to give slightly different results from the other as if they have not been coiled with the exact same amount of secondary windings.

So to calibrate you need to get a plug in meter like this one that can measure the RMS current and create a spreadsheet of RMS current values measured by the plug in power meter versus RMS current values measured by the method above for different combinations of lamps, laptop, small heaters etc. Then create a scatter graph of the data points with the commercial meter on the y-axis and the method above on the x-axis and then plot a line of best fit (hopefully the data points should lie pretty close to the line). Now take the equation of the line which should be in the form y = mx +c and enter it in to the arduino sketch by modifying the following variables factorA and Ioffset at the top as follows:

double factorA = 15.2 * m ;

double Ioffset = -0.08 + c ;

Note: factorA here is equal to the CT sensor reduction factor divided by Rsens and so if you placed a 100Ohm resistor in as your Rsens you can work out how many secondary windings your CT sensor has.

Now if you compare the RMS current values again they should now be in better agreement.

Extend it

Next you may want to test it and then do useful things with it by extending it.

Changes since last version

November 5th 2009

Id like to thank Peter and Ed who posted below for pressing me on the voltage synthesis and suggesting I look at more traditional reactive loads like the washing machines or fridges instead of only laptops which even though their powerfactor is less than 1.0 aren't really reactive. The above version does not now feature any voltage synthesis just Irms and apparent power calculations (from a manually set Vrms value). I have relegated the voltage synthesis info to another page here in-case it is of any interest to anyone

Circuit now has sockets to connect up a 7 segment display which I hope to document soon.

Hey, I'm using the Irms value

Hey,

I'm using the Irms value from the Energy Monitor to control the flow of water from a 12v pump. I want the flow of water to represent the energy being used in my home. I'm sending the Irms value to digital pin 9 which then controls the pump. A schematic of my project can be found at http://alanmeany.wordpress.com/2010/03/01/ambient-energy-monitor-schematic/. The problem is that when the pump starts running it is affecting the Irms value.

Because I am using the Irms value to change the flow of water the value itself does not need to be accurate, it could be any number that changes when appliances are turned on and off.

Would you have any ideas how I could:

(a) Change the code so that the pump does not effect a value being read form the CT Sensor.

OR

(b) Rewire the circuit so that the pump does not effect the Irms value.

Any help would be greatly appreciated!

 Hey Alan  by how much does

 Hey Alan 
by how much does the value change? 
you could add another transistor between the PWM output and the TIP 121 which would reduce the load the TIP121 is putting on the arduino, which may then reduce the effect it is having on the Irms value. Or yes Im sure you could do something in software especially if the change is always the same: if (pumpIsOn==1)  Irms = Irms - change;
I like the sound of using the flow of water to represent energy use, that would be really cool!

Trystan, Thanks for the reply

Trystan,

Thanks for the reply but I do not think it will be a solution to my problem. I will use the following simplified example to explain.

If Irms is at 0 the pump is off. When I turn on a light and Irms rises to 5, the pump starts to gently flow to represent a small current flowing(the light). But when the pump does this it then increases the Irms value which then in turn increases the flow of water. Even if I say Irms = Irms - change; this new value will be changed when the pump comes on therefore turning the pump on more and keeping it on even if the light is turned back off.

If I do reduce the load the TIP121 is putting on the Arduino, the pump still gradually starts effecting the Irms value.

I was considering using the value straight from analog 0 (because the pump turning on and off should not effect this value?) but when appliances are turned on this value doesn't just rise it fluctuates up and down (like a wave).

Ideally I would like to be able to control the pump off a different arduino than the CT Sensor so that it cannot interrupt the Irms value, but I do not know if this is possible. Sending the value being read by one arduino to the computer and then from there to another arduino that controls the pump?

 I see a bit of a problem....

 I see a bit of a problem.... not sure what the best way to go and why its doing that, all I can suggest is trying to reduce the load on the arduino with yet more transistors? If I think of anything else I will let you know.
You could quite easily communicate between two arduino's. Create a software serial port on each arduino assign pins like for example RX =2 and TX=3 and connect the RX of one arduino to the TX of the other and vice versa. You will also need a wire between both arduino grounds. Then just serial print values between them. Let me know if you need any more help with that.
 

I have been working on the

I have been working on the communication between the two arduino's. The good news is that when the pump is running off a seperate arduino it no longer effects the Irms value. I'm using the following code to send a value from analog 5 on Arduino 1 (Sender) to control the pump on Arduino 2 (Receiver). Now that I have this working I want to replace the value of analog 5 with Irms value (Sender) and control the pump (Receiver), but I am having problems ....again.

//Sender

int analogValue5, val5;

void setup() {
// Serial port enable
Serial.begin(19200);
}

void loop() {
// read analog pin 5
analogValue5 = analogRead(5);

// remap values from the analogValue5 variable to 0 / 255
val5 = map(analogValue5, 0, 1023, 0, 255);

//send the value to the serial port
Serial.println(val5, BYTE);

}

//Receiver

byte incomingByte;

void setup() {
// Serial port enable
Serial.begin(19200);

// declare pin 11 as output, this is the LED
pinMode (11, OUTPUT);

}

void loop() {

// if there is bytes available coming from the serial port
if (Serial.available()) {

// set the values to the ‘incomingByte’ variable
incomingByte = Serial.read();

// write the value to the pin 11
analogWrite(11, int(incomingByte));

}
}

Although I got this code working I cannot get it to work along with your code, for example to send Irms value instead of analog 5 value to control the pump. Sorry for all the questions but I'm a bit of a newbie and now that I got this far I don't want to stop. If you could just give me any advice on how to change this code to work with yours so that I can send the Irms value instead of analog 5 value?

Thanks again for all your help.

I'm getting an error when I

I'm getting an error when I upload the sketch:

http://openenergymonitor.org/emon/sites/default/files/CTmethod.pde

error: expected ',' or ';' before 'double' In function 'void loop()':

How do I fix this?

Hey Alan There was a missing

Hey Alan
There was a missing ; in the sketch, I've corrected it now, let me know if you still get the problem.
Trystan

I've built the the non

I've built the the non invasive home energy controller, but the thing is i'm not looking to connect the CT to the main. I want to connect it to like a external receptacle to measure the current of a single device much like kill-a-watt or something similar.

I have a CT rated for less than 60A with output at 0.333Vac. I was looking at the arduino sketch and i was wondering how does setV change? because from the example setv prints
242.62
243.17
242.90
??

Also can you explain the ADCvoltsperdiv= 0.0048? how do we arrive this number and why do we use it?

Hey Steven, I see the mistake

Hey Steven, I see the mistake I made on the page, sorry yes the sketch should just output a fixed 230.
This sketch should do that:
http://openenergymonitor.org/emon/sites/default/files/CTmethod.pde
The ADCvoltsperdiv= 0.0048 is the ADC voltage range (0 to 5V) divided by the ADC resolution 1023. ADCvoltsperdiv  = 5V / 1023 = 0.0048
If you dont want to measure the whole house, the easiest way to measure from an outlet, is to get a small extension cable or 4-bank and take a small section of the outer sleeving off the cable leaving the 3 inner cables with their insulation sleeving intact. Only do this if your completely happy you know what your doing. The picture at the top of the page shows what I mean.
 

Trystan, So how do we measure

Trystan,

So how do we measure the resolution? is it generally? This is from a oscilliscope?

I have a 2 bank receptacle and that's what i'm using this AC non invasive method to measure the current.

I still have some configurations to make.

 Hey Steven, The resolution

 Hey Steven, The resolution is a property of the Arduino's ADC (Analog to digital converter)  it isnt something we measure. The Arduino ADC is a 10bit ADC 2^10 = 1024. We divide by 1023 since there are 1023 spaces inbetween the 1024 divisions. Here's a couple of pages that might be worth reading:
http://www.arduino.cc/playground/CourseWare/AnalogInput
http://en.wikipedia.org/wiki/Analog-to-digital_converter
The 2 bank receptacle sounds ideal! Let me know how you get on
 

Trystan, do you think the

Trystan,
do you think the arduino sketch you have will work the same on my 2 bank receptacle? The readings its giving me are totally off. I was wondering if you have any input.

I plugged in a toaster and I have a fluke power meter that's telling me the toaster was 6A rms but the arduino was outputting 0.244 Arms.

 Hey Steven, have you

 Hey Steven, have you calibrated the energy monitor? Make a table of rms current values from the energy monitor and their corresponding rms current values from the fluke meter. Then create a scatter plot your spreadsheet program with the energy monitor values on the x-axis and the fluke values on the y-axis. Then plot a line of best fit and get the equation. 
The equation of the line is of the form y = mx + c. Find the line in the arduino sketch that sets factorA and multiply factorA by m giving you a new value. Add c to Ioffset.
Let me know how that goes

Hi, For current transformer

Hi,

For current transformer circuit, if i'm not using a 7 segment display can i just remove the 5V input power and the 2 100k resistors? and connect the bottom branch straight to ground? or are these that important?

Hey Steven, the 2 100k

Hey Steven, the 2 100k resistors are important, they form the voltage divider that biases the signal from the CT by 2.5V to keep the signal from the CT within the 0 to 5V analog input range required by the arduino.
If you dont intend on having a display you dont need the little wire jumpers and the 5way header on the far left side that can be seen in this picture: http://openenergymonitor.org/emon/sites/default/files/B08.JPG 
Does that make sense, sorry if its not so clear.

Trystan, So i calibrated the

Trystan,

So i calibrated the CT and it measures current a bit better, I'm going to re-do the calibration and hopefully that will make it within +/-5A error, I was just wondering do you think it's possible to measure the Vrms? instead of having in constant without having to build that extensive circuit that you have in the non-invasive that measures voltage and current?

I've built the the non

I've built the the non invasive home energy controller, but the thing is i'm not looking to connect the CT to the main. I want to connect it to like a external receptacle to measure the current of a single device much like kill-a-watt or something similar.

I have a CT rated for less than 60A with output at 0.333Vac. I was looking at the arduino sketch and i was wondering how does setV change? because from the example setv prints
242.62
243.17
242.90
??

Also can you explain the ADCvoltsperdiv= 0.0048? how do we arrive this number and why do we use it?

Hi Trystan I eventually

Hi Trystan

I eventually bought an efergy CT an got my meter working. I also hooked up a 16x2 LCD display that scrolls through the different readings with a pushbutton. So the next step for me is to build the voltage sensing circuit. I'd just like to say thank you for your help so far.

I have one question. When I read the current from my power meter (for my desktop PC), I get a reading of say 0.81A. I borrowed a friend's clip on DMM and this gives a reading of about 0.63A. However, when I hook up a 2000W hairdryer, my meter gives a reading of about 5.45A, and the DMM gives a reading of 7.8A. Could this difference be because my meter is measuring Irms and the DMM is measuring Ipeak or should I be concerned about my meter's accuracy?

I can't find a datasheet on the DMM. It's a MajorTech MT750. It seems to be a discontinued meter.

Any help and insight would be much appreciated

Louis

Hey Louis Great to hear that

Hey Louis
Great to hear that you have got it working!, the LCD sounds really good! Do you have any pictures of your setup? If you'd like to share what you have done I can add you to the blog if you like? just send me an email.
To answer your question about the DMM. I also had a go at measuring with a DMM and found it to be very different, I think a lot of DMM's do only measure Ipeak/sqrt(2) not Irms. Do you have a plug meter that measures Irms to compare it with?
Trystan
 

Hi again, I have the

Hi again,

I have the Seeedstudio 100A ct sensor, and I have calibrated it on a circuit of 1kW. However when I clipped it to my mains intake, I got a hum,ming noise and measured the signal to 5.5V AC. Shifted up 2.5V that would certainly fry my Arduino, right? Has anyone else used that sensor?

Hey Joachim. That doesn't

Hey Joachim. That doesn't sounds to good! Your right 5.5V+2.5V will be no good for the arduino. What size resistor have you connected in parallel to it?

The measured signal can be decreased by decreasing the size of the resistor in parallel with the CT. Im using a 56 Ohm resistor for measuring the whole house. Gives me a range of 0 - about 10kW. At 10kW the rms Voltage across the resistor is about 1.75V (peak voltage 2.5V)

Thanks again, I will change

Thanks again,

I will change the resistor before I conect it to the arduino. Can I assume the seeedstudio one have about the same conversion factor as yours? I cannot find a datasheet...

The humming noise, is that normal?

Joachim

Well I dont get any humming

Well I dont get any humming noise, so I dont think its normal... From their website it says: "Output mode:  Current/33mA" I took that it meant 33mA at max current 100A which would work out to be a conversion factor of 3030. Lets say you wanted to measure 1V rms at 1kW then you need a 720 Ohm resistor across it. With a 100Ohm resistor and a 1kW load you should measure 0.14V. Do you get this?
Can you measure the rms current flowing in the circuit consisting of just the CT and the resistor?

Hi and thanks for a wonderful

Hi and thanks for a wonderful and inspiring site. I notice that you are using one clamp only, and there's another site using two clamps (http://www.picobay.com/projects/2009/01/real-time-web-based-power-charti...). I am thinking of monitoring the power use in my home, and clamping the device(s) at the mains intake (before the breakers). I live in Norway, using 240V 50Hz. Is one clamp enough? I am struggling a little with the theory here. And I think I will try without the phase changes in the first place (although we use the washing machine constantly...), but could I measure the voltage in one outlet instead of in the breaker box?

Joachim

Hey thanks Joachim! From what

Hey thanks Joachim! From what Jason says he is using two clamps because: "in most US homes, the electricity comes in as 220v on 3 main lines. Some appliances, like ovens and clothes dryers, are connected to these 220v lines directly. However, by using just one of the lines, the power is reduced to 110v for all the wall outlets. Usually, a home’s electrical wiring is divided into two sections. One line (known as a leg) powers one section of the home and the other line powers the other side. To get the total power usage in my house, I put an AC clamp on both legs and added the measurements together."
It seams that in my home I can put a clamp over one wire and measure all electricity consumption in the house and so if you have similar wiring to what I have you should be fine with one.
As for voltage yes you can certainly measure it at one outlet, I dont think you would want to measure it in the breaker box... I have been using a standard step down AC to AC transformer pluged in to one of the house outlets to measure voltage recently, something I intend to write up here as soon as I can. Maybe if you want have a go at the current measurment first and add the voltage measurment later?
Trystan

Hi there First off, let me

Hi there

First off, let me say that this is my new favourite site on the net!

I would really appreciate it if you guys could help me out. I am a total newbie when it comes to electronics.

I have a CT which is very similar (if not identical) to this one: http://www.magnelab.com/catalog/sct_0750.php.
It's a 150 Amp CT which outputs 0.33 Vac at rated amps instead of current. I got it from a friend, so I thought I would try it out with my shiny new Arduino. :)

How would I be able to hook this up to the Arduino? Would I need to install a bridge rectifier to turn the Vac output to DC? Does it then still need to be biased up?

If so, could anybody help me out with a circuit diagram to explain?

Any help would be much appreciated.

Louis

Hey Louis Im glad this wesite

Hey Louis
Im glad this wesite is useful to you, thanks!
If you look at the circuit schematic above your CT sensor is like the one I have but with the resistor that is paralel to the CT in the circuit above included in your CT. You will still need the biasing resistors to keep the input voltage to the arduino in range. Once you have that built, try and run the sampler program so that you can see the analog input waveform. You may find that the voltage waveform has a very small amplitude since your CT will give 0.33Vac at 150Amps, mine is currently configured at 0.33Vac at 5Amps. But have a go and let me know what you get and we can go from there.
Trystan

Hi Trystan When I compile the

Hi Trystan

When I compile the VISampler program, I get the following:

Note: GCanvas.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.

Then, when I take a sample, it looks like this: http://i914.photobucket.com/albums/ac345/lbeetge/Screenshot-PowerSampler...

I used your circuit without the parallel resistor. After I tested the VISampler program, I uploaded the normal energymon sketch to arduino and ran the ArduinoComm program. I get Amp readings like these:

Before plugging in the CT:
0.88
0.86
0.78 etc

After plugging in the CT:
0.98
1.01
0.96 etc

So the CT is definitely picking up the current. The power I am monitoring is for my desktop PC. Sorry for the long post, but maybe this will help other newbies like me. Any further help you can give me is much appreciated

Kind Regards
Louis

Hey Louis, The screenshot is

Hey Louis, The screenshot is very helpful thanks! It looks like your getting something but its not quite what one would expect, your looking to get something like the blue line in the screenshot on the VIsampler page when you have a PC connected and something more sinusoidal if you have say a few incandescent light bulbs connected.
I suspect it might be a problem with the output of the CT being too small, could you try with something bigger like an electric heater?
The only other thing I can think of is is your CT measuring the current flowing through the live wire only?
good work getting this far!
Trystan

Hi Trystan Ok, just to put my

Hi Trystan

Ok, just to put my mind at ease. My CT has two connectors. One red and one black. I connect the red one via a 100ohm resistor to the Analog 0 input and the black one to the voltage divider. Is that correct?

Also, my ct is clamped to the electrical wire same as your pic. Insulation is stripped and the ct is hooked up to the brown wire.

I don't have a heater to hook up to. My only way to get more current through the ct, would be to clamp it around the mains cable in my db, which I am a little bit hesitant to do seeing as I am a complete newbie. ;)

My CT's datasheet does say that the CT is only reliable from about 10% of 150Amp, which is 15Amps upwards. Any idea what would push 15 Amps. I think probably only the mains wire. Correct?

Hey Louis Your circuit setup

Hey Louis
Your circuit setup sounds good to me. I think the 15Amps upwards is going to be your problem, most appliances use less than 13Amps or so. An electric kettle or a heater is often around 13Amps while a 60W lightbulb in the uk is about 0.25Amps. I guess even if you do measure something its unlikely to be useful for domestic power monitoring so it might be better to see if you can get a CT that can measure reliably up from 0Amps? What do you think?
Trystan

Hi Trystan I hooked up a

Hi Trystan

I hooked up a kettle and got this graph from VISampler.

http://i914.photobucket.com/albums/ac345/lbeetge/Powersampler2.png

You can just start seeing a bit of amplitude on the graph. So the CT is definitely not sensitive enough for home use. I'll see if I can get an Efergy CT.

Thnx for all your help so far.

Louis

Hey Louis, im sorry I did not

Hey Louis, im sorry I did not see your post there. Sounds like a good plan. Let me know how it goes

Hi Thnx for your reply. I

Hi

Thnx for your reply. I will try your suggestion and see what happens. Is it possible to upload screenshots here?

Kind Regards

Louis

This is not a comment but

This is not a comment but more like a question. I don’t know much about electronics. My question is related to current sensor used in the circuit. I got Taehwatrans’s “TC1L” current sensor. Detail about this current sensor can be seen on
http://www.taehwatrans.com/bbs/board.php?bo_table=product_02&wr_id=13
Please guide me if I can use this current sensor for this purpose or prescribe any current sensor that one can get easily of the shelf. I will really appreciate any help and guidance in this regard.

Hello Mehroze, sorry for

Hello Mehroze, sorry for taking a while to reply, Ive been away for a week, with no access to the computer. The TC1L looks like a good choice if your interested in measuring household energy use. What is the range of current you hope to measure? If you already have the TC1L place a 56Ohm resistor across its terminals and then measue the voltage with a multimeter set in AC mode with a few different loads say a 100W lightbulb and then 200W and 300W, let me know the results. Otherwise have a look at the links to current sensors above.

Hi TrystanLea, sorry this

Hi TrystanLea, sorry this time I was away for few days without an Internet connection. I will get back to you in a day or two. Thanks a lot for your help and guidance.
Mehroze

Step 1 thru Step 11 images

Step 1 thru Step 11 images and also schematic image not showing up on page, but looks like a nice project to try out.

Thanks for letting me know

Thanks for letting me know MarkC :) Should be back up now...

The text says "it doesn't

The text says "it doesn't require any breaking of the mains wire", however in the image the power cable actually looks broken.

So is this the usual method of breaking up the live and neutral wire as every cheap current clamp ammeter requires to do or does this really NOT require breaking the cable (i.e. putting the sensor around both / all three wires)?

Hey Andre What I mean by

Hey Andre
What I mean by breaking the mains wire is actually wiring up the electronics directly to the mains electrics, this method doesnt do that. The CT sensor just clips around the live wire and measures the magnetic field that surrounds the wire. In other words there is no conductive contact.
So yes it is "usual method of breaking up the live and neutral wire as every cheap current clamp ammeter requires to do" if the wires are bundled together and covered in outer sheathing (like in the case of the powerstip above) but for wires that are already seperate like the wires that come in to the avarage house you just clip is straight on and no sheathing needs to be removed.
The main thing is there is no conductive contact - no bare mains wiring. 
Trystan

I too am a bit concerned

I too am a bit concerned about guessing that the peak of the voltage waveform corresponds with the peak current.

If both the current and voltage are pure sine waves won't this mean that the estimated power factor is always one irrespective of the actual phase angle? So is what you are measuring just the effects on the non-linear current draw of things like the switched-mode power supply which is presumably what your laptop uses?

It would be interesting to compare measurements of you technique vs your known accurate meter on a more traditional reactive load. Might I suggest trying it on your fridge with the compressor running?

Hey Ed, just replied below

Hey Ed, just replied below about this :)
Like you say it would be interesting to compare measurements of the technique vs your known accurate meter on a more traditional reactive load.
and I will get back to you with the results as I describe below.
Thanks
Trystan

Just to update on the test of

Just to update on the test of a more traditional reactive load. I tested a fridge and a washing machine today, synthesising the voltage waveform does not work for these loads as expected. Im writting up about it at the moment and will upload the results and analysis once I finish :)
Trystan

Nice work. Energy monitoring

Nice work. Energy monitoring and control seems to be reaching a critical mass.

I try to rationalize via math.

v(t) = VM*cost(wt + phase v)
i(t) = IM*cost(wt + phase i)

p(t) = v(t)*i(t)

crunch and applying some trig identities

p(t)= VM*IM/2 [cos( phase v - phase i) + cos(2wt + phase v + phase i)]

integrating p(t) from to to to+T (one period) we see that the first cosine is a constant since it is time invariant. The other cos term is zero via inspection since the average value of a cosine is 0.

For computing the apparent power, we need to look at the Irms and Vrms. P = Vrms*Irms*cos( phase v - phase i) => Power Factor = Average Pwr/Apparent power

Irms = SQRT[1/T*integral(i(t)*i(t) dt] from to-to+T (one period)
ditto for Vrms...just replace i(t) with v(t)

The implementation of your code aligns with the math. I am struggling with the impact of synthesizing the voltage.

I was planning on measuring both current and voltage...current via CT and voltage via a step down transformer. I am going to ignore phase delays in the measuring devices and corresponding circuitry and assume they are much smaller that phase delays resulting from the actual load. The apparent power calculation via RMS approach shall include Phase of I and Phase of V. Lead/Lag for inductive or capacitive circuits cause current or voltage phase to shift relative to each other.

I am not getting how synthesizing the voltage signal and measuring current yields the correct apparent power. If the phase angles are low then the model is approximated by a resistive circuit. For larger phase angles I am not sure if synthesizing the voltage is accurate. A synthesized voltage always leads to a 0 value for the voltage phase angle. I have to think about what kind of errors this introduces.

Hey thanks for your

Hey thanks for your comment!
When you say you are not getting how synthesizing the voltage signal and measuring current yields the correct apparent power
do you mean that you dont get how it yields the correct value for real power? If Apparent power = Vrms * Irms then the phase difference between voltage and current waveforms dont matter for calculating apparent power right?
 
I can understand if you are wondering how it yields a correct value for real power since like you say if the actual voltage waveform was 90 degrees out of phase with the current waveform it would have a very different result (for real power) than the result that would be given by a synthesised voltage that tries to be as in phase as possible with the current.
 
Reading my description above I think it probably needs a bit of clarification. The real power value it calculates is very much an approximation but its an approximation that seems to work well for of course resistive loads like incadecents and electric heaters but it also works well for appliaces that have switched more power supplies like laptops,mobile phone chargers, some low energy lighting which usually give a power factor of around 0.5. It also seems to work well for a food mixer I have...
 
The voltage synthesis code works by aligning the voltage waveform peak with the current waveform peak and so for the:
 
Resistive loads such as a heater or incadecent light the current waveform is sinusoidal, the peak of the current waveform is detected by the program and the program sets the voltage waveform peak to coincide with the current waveform which gives two in phase sinusoidal waveforms as we would expect if we were to measure the voltage directly.
 
For the switched mode power supplies that are often used for laptops, chargers, low energy lighting the current waveform is not sinusoidal it has a characteristic spike that happens at the voltage waveform peaks and so the program detects this current spike peak and sets the synthesised voltage waveform peaks to again coincide with the current waveform peaks. This yields a good value for real power and power factor (power factors that are less than 1) and apparent power- very similar to the values measured if measuring voltage directly.
 
However I imagine if one were to connect it up to a purley reactive load the results would not be so good specificaly when the current wavform peaks do not happen at the same instant as the voltage waveform peaks. I read that motors are meant to have large reactive components. With current and voltage waveforms that are not in phase. I tested a food mixer briefly and it gave good results.. however it was tested very briefly... I actually tested a turntable briefly for the first time today and the real power value calculated was significantly different from the real power value calculated by a meter that measured voltage and current directly.
 
So when I get a moment I will have another look at the turntable, mixer and also a washing mashine to check whether the voltage synthesis method only works for loads like lights, heaters, laptops.
 
Maybe my mixer gave good results because it has some sort of compensation...
I came across this article on switched mode power supplies and power factor which talks about how switched mode powersupply voltage and current waveforms are in phase but have lower than 1 power factors and this lower than one power factor can not be described as leading or lagging.. interesting article: http://www.ecnasiamag.com/article-26246-understandingpowerfactorandinputcurrentharmonicsinswitchedmodepowersupplies-Asia.html
 
I will get back to you with the results of the washing machine and turntable.
 
Let me know your thoughts on the above
Thanks
Trystan 
 

I just wanted to comment on

I just wanted to comment on the power factor calculations. For house loads, i.e. non-industrial, power factors should be lagging for almost 100% of the time. The power factor can be calculated by measuring the time difference between the zero crossings of the voltage and current wave forms. This time delta, based on 60 Hz ( or 50 in Europe) can be converted to an equivalent angle and thus the power factor. That should provide a more accurate value of watts. With the Arduino running at 20 MHz, it should be fast enough to do the measurement.
Now on to "how to measure the zero crossing".

Thanks Hendrik, we have been

Thanks Hendrik, we have been discusing zero crossing here http://openenergymonitor.org/emon/arduinocomm, I think it would certainly worth giving the method a go at some point.

It is difficult to convey the

It is difficult to convey the message without a sketch of waveforms. Average Power at a load operating at an AC steady state is

P = Vrms*Irms*cos( phase v - phase i) as perhaps not so clearly stated by me earlier. Yes, the Vrms*Irms is the apparent power.

In a purely resistive load, phase v and phase i are 0 thus Apparent power = real power. In a purely reactive load there will be no real-power. Not going to happen in home at the AC panel.

Here is what is required for accurate power measurement
1. Not assuming a clean fundamental sinusoidal waveform.
2. Not ignoring the impact of harmonics
3. Not assuming that the voltage and current are on phase

So far only one of the three is not assumed. What are the impacts of 1 and 2? I think the secret sauce lies in the crest factor => peak to RMS ratio. So this is where true RMS claims are made. They navigate the murky waters of crest factors.

Back to RMS current...

Irms = SQRT[1/T*integral(i(t)*i(t) dt] from to-to+T (one period)

This is just an time dependent view of P = I^2R

We are looking for a DC equivalent to current that when pass through R will yield the same power.
We can approximate the integral calculus by using high sampling rate (>> greater than nyquist frequency) and compute Irms by Sum( I[n] ^2 ) / N where n = sample 1 to N.

Now we don't care about the phase of current or voltage. We just need to ensure that v[n] and i[n] are measured at same point in time to compute Vrms and Irms to get the apparent power. We get the average power via p(t)= VM*IM/2 [cos( phase v - phase i) + cos(2wt + phase v + phase i)].

This reduces to the sum of product( V[n]*I[n] )/N in our digital world. Ration between Apparent and Average PWR is the power factor. All is simple.

I will attempt to rationalize your way so that math makes sense in my head.

Aligning the voltage peak with the peak of I is shifting the voltage by Phase I.
ELI/ICE makes no difference in our case since we only care about absolutes. We are not going to state a leading or lagging power factor. All is good so far. So we could set phase V to 0 and just seed off of phase I. e.g. cos(45)=cos(-45)

If it is not a purely resistive load then there will be attenuation of the current due to capacitance or induction. What remains consistent is the time at current peak is proportional to Phase I. Given this, your calculations would be ok given the sinusoidal assumption.

What about harmonics and crest factors? Again let us assume that the main power is driven by the fundamental frequency which is the 50/60 hz component. Should your home be optimized to be driven by the higher order harmonics then you are not living in a home but rather than in a well define lab. So that excludes this scenario from this solution. Remember this project was based on measuring power at the panel and not a device under test. Also it was implied for home and no an industrial plant.

What about UPSs? If you have 100 PCs connect to UPSs then maybe the crest factor my play into it. For all “normal” homes, your assumptions seem ok within the operating conditions.

As for my approach, I will still measure the voltage and current, low pass filter, and sample at 1khz or more...this will allow a larger range of measurements to occur albeit within certain operating parameters.

Peter

Thanks for your reply Peter

Thanks for your reply Peter and the detailed analysis, its really hepful to see your mathematical rationalization.

How are you measuring voltage and current with your approach?

I had a look at using a power adapter for voltage measurement but I had trouble with heating effects: when the power adapter warms up when started the Vrms measurment whent up 40V. I can still get a good phase measurement off it but for the magnitude of the voltage waveform shape its not so useful. Do you have any thoughts on this?

Thanks

Trystan