Problem measuring power using Current Only code

Hi, I'm doing energy monitoring project using arduino uno. Recently I encounter problem getting power value, the readings shown on the serial monitor is way too far from actual power. For example: I'm measuring a 100W lamp and the value shown in the serial monitor is 150-170 when it's ON and it doesn't drop to zero when it's OFF. Another problem is when I switch to another equipment(eg: 50W Fan) the value show in the serial monitor remains at 100+. Appreciate if anyone could solve my problem

Here's my code:

// EmonLibrary examples openenergymonitor.org, Licence GNU GPL V3

#include "EmonLib.h"                   // Include Emon Library
EnergyMonitor emon1;                   // Create an instance

void setup()
{  
  Serial.begin(9600);
  
  emon1.current(A4,55);             // Current: input pin, calibration.
}

void loop()
{
  double Irms = emon1.calcIrms(1480);  // Calculate Irms only
  
  Serial.print(Irms*230.0);	       // Apparent power
  Serial.print(" ");
  Serial.println(Irms);		       // Irms
}

See if your current sensor if producing reasonable values by itself. It makes NO sense to pass the data to some other library until you KNOW that the data is good.

Hi,
What is your local mains voltage, 240, 230 220, 110, 120 vac?

Tom... :slight_smile:

Hi. Thanks for the reply. Local voltage is 230V

Done a series of sensitivity test on SCT013 current sensor. It works fine. So I can’t figure out where goes wrong.
Anyway appreciate for all the replies

annasun:
Hi, I'm doing energy monitoring project using arduino uno. Recently I encounter problem getting power value, the readings shown on the serial monitor is way too far from actual power. For example: I'm measuring a 100W lamp and the value shown in the serial monitor is 150-170 when it's ON and it doesn't drop to zero when it's OFF. Another problem is when I switch to another equipment(eg: 50W Fan) the value show in the serial monitor remains at 100+. Appreciate if anyone could solve my problem

Can you show your schematic and link to what the energy monitor library expects for its circuit?

For example if the energy monitor library is expecting your CT to be biased at VCC/2 but you are biasing it from GND, then it would calculate the wrong Irms.

Hi. Here’s the link that my teacher ask me to refer to for my project.
https://openenergymonitor.org/emon/buildingblocks/measuring-voltage-with-an-acac-power-adapter
And the attach photo is the circuit diagram that I came up with.
Thank you for helping me with my problem.

I don't know the turns ratio for your CT so I can't check if you calculated your calibration factor correctly, but your basic circuit seems to be OK (although I'm not sure what you're doing with R3/R4 on Tx of the HC-05...but that's a different part of the circuit).

Do you have any way to measure the actual RMS current? Using the Watts rating on your loads isn't that good of a way to verify your Arduino's measurement of Volt-Amps (which is what you are getting when multiplying your RMS current by your RMS voltage).

For example your 50W fan is going to be a highly inductive load so it will draw a lot more current than 50W/230Vrms = 0.217Arms. The current won't be in phase so it won't deliver power over the entire line cycle.

Your 100W lamp, however, I would expect to be drawing close to a pure in-phase sine wave if you're talking about the incandescent type. If you're talking about a CFL, LED, or something else that might not be true however and you'll find that Irms * Vrms != Watts.

Hopefully this helps. Your CT circuit and your code seem to be fine, so all it seems that it can be is you are trying to test with loads that do not have a unity power factor. The way to prove this would be to compare your Irms measurement to the actual Irms.

Hi,

I'm measuring a 100W lamp and the value shown in the serial monitor is 150-170 when it's ON and it doesn't drop to zero when it's OFF

What does it drop to when it is OFF.

Can you measure your Vcc voltage?
Can you measure the DC voltage between GND and the junction of the two 10K resistors?

Then;
Remove the wire through the current sensor and check the current reading, it should be zero.

Can you post a picture of your project, in particular how you have the 230Va wiring around the current sensor.

emon1.current(A4,55); // Current: input pin, calibration.

What does this line mean?
Calibration?

Thanks.. Tom... :slight_smile:

DC voltage between GND and junction of two 10k resistors is 2.45V
When I OFF the equipment the value drop from approximately 140 to 120 which is not significant

CT ratio is 100:0.05 and I have changed the calibration value to 60.6 after calculate

The values show on serial monitor remains at 90-100 when I switch from 100W lamp to 50W Fan or 12W handphone charger. I'm not sure where goes wrong

Hi,

emon1.current(A4,55); // Current: input pin, calibration.What

What does the 55, calibration do?

double Irms = emon1.calcIrms(1480); // Calculate Irms only

What does the 1480 mean/do?
Thanks… Tom… :slight_smile:

Hi,
Without a wire through your current transformer, what reading do you get?

Tom... :slight_smile:

calibration value provides a more accurate readings.
For that 1480 I'm not sure, as this code is provided in the Emonlib in Arduino

Thank you guys for been so patient with me.

Even if i remove the wire, the value does not change over time, it continue running at the same value approx 100+

annasun:
calibration value provides a more accurate readings.
For that 1480 I'm not sure, as this code is provided in the Emonlib in Arduino

Thank you guys for been so patient with me.

1480 is the number of readings for the library to take before it calculates your RMS value.

Your circuit can't be hooked up the same as your schematic.

Could you write a sketch that just reads the analog values and prints them to the serial port as quickly as they can be taken?