# AC Current Measure Circuit

Thread Starter

#### Liboni

Joined May 11, 2021
7
May someone assist in creating a current measuring circuit to measure AC current that is being consumed by home appliance.

I have tried using ACS712 but the current reading I was getting was not stable. Hence would like circuit which can measure accurately the power consumption

#### Papabravo

Joined Feb 24, 2006
16,107
May someone assist in creating a current measuring circuit to measure AC current that is being consumed by home appliance.

I have tried using ACS712 but the current reading I was getting was not stable. Hence would like circuit which can measure accurately the power consumption
I kind of doubt that the problem was the ACS712. Can you elaborate on what you mean by "the current reading...was not stable". Stability has a fairly precise meaning and it involves "remaining finite" as opposed to "diverging to infinity". Now I'm pretty sure we are not talking about diverging to infinity. Let's explore your meaning of "was not stable".

#### crutschow

Joined Mar 14, 2008
27,190
You understand that just measuring the current may not give an accurate power reading if the load is somewhat inductive or capacitive, or the appliance has a switching supply.
For that you must also measure the phase-angle (power factor) between the voltage and current.

Unless you are doing something with a computer with that reading, using a power meter such as the Kill-A-Watt is the easiest way to measure appliance power.
You just plug the meter into the wall and the appliance into the meter.

Thread Starter

#### Liboni

Joined May 11, 2021
7
I kind of doubt that the problem was the ACS712. Can you elaborate on what you mean by "the current reading...was not stable". Stability has a fairly precise meaning and it involves "remaining finite" as opposed to "diverging to infinity". Now I'm pretty sure we are not talking about diverging to infinity. Let's explore your meaning of "was not stable".
On the stability is the values changes drastically for the same appliance when switch off the whole circuit and on again. At one moment I connect a 9W light bulb it was giving me 120mA ranges of values and in my country or mains power is 220V. Then when i switched on the system back on again i was now getting around 230mA range

I'm using an ESP32 chip and the library I'm using for the ACS712 is https://github.com/RobTillaart/ACS712 by Rob Tillart. I will send in the Code I'm using
C:
#include "ACS712.h"
#include <HTTPClient.h>
#include <WiFi.h>
const char* ssid = "laptop";
const char* password = "12345678";

String serverName = "[URL]https://192.168.43.38:5001/api/Values[/URL]";
ACS712  ACS(33, 5.0, 4095, 100);
void setup()
{
Serial.begin(9600);

ACS.autoMidPoint();
Serial.print("MidPoint: ");
Serial.print(ACS.getMidPoint());
Serial.print(". Noise mV: ");
Serial.println(ACS.getNoisemV());
WiFi.begin(ssid, password);
Serial.println("Connecting");
while(WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.print("Connected to WiFi network with IP Address: ");
Serial.println(WiFi.localIP());
Serial.println("Timer set to 5 seconds (timerDelay variable), it will take 5 seconds before publishing the first reading.");
}

void loop()
{
int mA = ACS.mA_AC();
Serial.print("mA: ");
Serial.println(mA);

Serial.print(". Form factor: ");
Serial.println(ACS.getFormFactor());
if(WiFi.status()== WL_CONNECTED){
HTTPClient http;
Serial.print(". Form factor: ");
Serial.println(ACS.getFormFactor());
String serverPath = serverName + "?Current="+mA+"&&Voltage="+220+"&&HouseHoldId="+1+"&&FormFactor="+ACS.getFormFactor();
http.begin(serverPath.c_str());
int httpResponseCode = http.GET();
if (httpResponseCode>0) {
Serial.print("HTTP Response code: ");
Serial.println(httpResponseCode);
String payload = http.getString();
Serial.println(payload);
}
else {
Serial.print("Error code: ");
Serial.println(httpResponseCode);
}
http.end();
}
else {
Serial.println("WiFi Disconnected");
}
}
Moderator edit: Added code tag like this [code]your code...[/code]

Thread Starter

#### Liboni

Joined May 11, 2021
7
You understand that just measuring the current may not give an accurate power reading if the load is somewhat inductive or capacitive, or the appliance has a switching supply.
For that you must also measure the phase-angle (power factor) between the voltage and current.

Unless you are doing something with a computer with that reading, using a power meter such as the Kill-A-Watt is the easiest way to measure appliance power.
You just plug the meter into the wall and the appliance into the meter.
My main agenda is to for now be able to get the current readings which are accurate whether the system is inductive or capacitive. Want to be able to have the readings so that I can calculate the Power for the appliance in my project I'm doing. The system is meant to identify appliance by the pattern of consumption the appliance does hence current is one of the crucial parameters i want, i presume.

#### andrewmm

Joined Feb 25, 2011
1,466
Two things,
can you share a photo of your setup please ?
can you share a print out of the values your seeing, I would be interested to see how mA changes over time.

Then,
If you have a computer connected to the usb port,
a suggestion, do away with the wifi / server parts till you have the numbers your expecting, just use the terminal in arduino,

Also,
have look at the docs for the library your using,
just wondering do you have to do some initalisation more than autoMidPoint ?

#### crutschow

Joined Mar 14, 2008
27,190
Want to be able to have the readings so that I can calculate the Power for the appliance in my project I'm doing. The system is meant to identify appliance by the pattern of consumption the appliance does hence current is one of the crucial parameters i want, i presume.
Depends upon how accurately you need to know the power.
You can't accurately calculate the power without measuring both voltage and current, and the phase-shift between them (power factor).

#### andrewmm

Joined Feb 25, 2011
1,466
Re Power,
Ok, you have strange readings, which I think we need to look at

As to phase / voltage question
I agree with @crutchow,

To know power accurately, you need to know all three,
and probably compensate the sensor for temperature,

BUT

I guess you dont want to know the power that accurately ,
certainly not more accurate than the electricity meter of the property

So you can assume voltage is constant,
the temperature has zero effect,
The phase angle is going to be near to "zero" and so has little effect.

One thing I have seen on similar for my home monitor,
is that fluorescent lamps are "very" none sinusoidal, so you need to average over a good few cycles,

lets see picture of the setup,
and a print out of the readings over time on a load

Thread Starter

#### Liboni

Joined May 11, 2021
7
Two things,
can you share a photo of your setup please ?
can you share a print out of the values your seeing, I would be interested to see how mA changes over time.

Then,
If you have a computer connected to the usb port,
a suggestion, do away with the wifi / server parts till you have the numbers your expecting, just use the terminal in arduino,

Also,
have look at the docs for the library your using,
just wondering do you have to do some initalisation more than autoMidPoint ?

I have attached the current values I'm getting and also the pic layout.

Looking into the documentation on the Noise part thanks

#### Attachments

• 10.9 KB Views: 0
Thread Starter

#### Liboni

Joined May 11, 2021
7
Depends upon how accurately you need to know the power.
You can't accurately calculate the power without measuring both voltage and current, and the phase-shift between them (power factor).
Alright thanks, let me get the voltage sensor as well, into the circuit and update when i have bought and integrated it

#### crutschow

Joined Mar 14, 2008
27,190
Alright thanks, let me get the voltage sensor as well, into the circuit and update when i have bought and integrated it
It you can get instantaneous readings of both current and power over a complete cycle waveform (say sampling at 1kHz) then you can multiply each of the instantaneous current and voltage samples together to get the power at each point, and then average them over a cycle period (or more) to get the real power.
That will then include the effects of the power factor.

Thread Starter

#### Liboni

Joined May 11, 2021
7
Re Power,
Ok, you have strange readings, which I think we need to look at

As to phase / voltage question
I agree with @crutchow,

To know power accurately, you need to know all three,
and probably compensate the sensor for temperature,

BUT

I guess you dont want to know the power that accurately ,
certainly not more accurate than the electricity meter of the property

So you can assume voltage is constant,
the temperature has zero effect,
The phase angle is going to be near to "zero" and so has little effect.

One thing I have seen on similar for my home monitor,
is that fluorescent lamps are "very" none sinusoidal, so you need to average over a good few cycles,

lets see picture of the setup,
and a print out of the readings over time on a load

The current I'm getting is attached to the files and the file name describes the values from where i was testing

#### Attachments

• 120.9 KB Views: 1
• 57.1 KB Views: 1
• 138 KB Views: 1
• 83.2 KB Views: 1
Thread Starter

#### Liboni

Joined May 11, 2021
7
Alright thanks, let me get the voltage sensor as well, into the circuit and update when i have bought and integrated it
However, i dont want it to be very accurate but just values to work with

#### andrewmm

Joined Feb 25, 2011
1,466
View attachment 238347

I have attached the current values I'm getting and also the pic layout.

Looking into the documentation on the Noise part thanks
Can you show us picture of the current clamp / sensor please as the IC can only read what its feed.
Are you using a current clamp around all three wires in the AC cord ?

#### andrewmm

Joined Feb 25, 2011
1,466
Just looked at your numbers,
what strikes me is the range of form factors your receiving,
If I remember, this is used to "correct" for none sinusoidal waves,
so with changing form factor, you get changing power.

Look at your sensor / clamp

Similar threads