[SOLVED] ACS712 Voltage & Amps -- Ghost Readings!

these are my calculations based on the datasheet:

PARAMETERS:
vcc: 4.5 - 5.5V
icc: 13 - 15mA
zero current output voltage: vcc × 0.5 (2.5 V)

SENSITIVITY:
± 5A: 185mv/A (sensor theoretically can measure ±13A @ 5V; ± 8.6A @ 3.2V)
±20A: 100mv/A (sensor theoretically can measure ±25A @ 5V; ±16.0A @ 3.2V)
±30A: 66mv/A (sensor theoretically can measure ±37A @ 5V; ±24.2A @ 3.2V)

theoretical resolution for 5V analog pin:
(arduino resolution: 5mV)
5A: 26.4mA
20A: 48.8mA
30A: 74.0mA

error @ 25c: ±1.5 %

you should try setting a higher threshold value. these sensors are not close to nasa precision :slight_smile:

unrelated to this problem, but also, i see that you’re measuring ac mains, and you’are calculating power (watts): multiplying amperes X volts.

my question, so, how are you dealing with power factor?

this is what i assume your false triggers are (you should edit the filter cap):

“The ACS712 module has quite a high level of noise - around 130mA. But that’s with the 10nF noise filter capacitor fitted as standard. Increase that capacitor to 470nF and the noise level drops significantly.”

1 Like

PF is taken as 1 :slight_smile:
The AC amps does use 50Hz sampling and rms though :slight_smile:

I’ll take a look at the noise filter stuff and let you know how it goes.

based on the video, it definitely should help. also, i recommend to average those values, do not allow a trigger based on a single measurement. average at least 10 or more readings.

if power factor is always 1, how about inductive loads, like motors, and most mains psu (smps), they all have quite a power factor…

The 50HZ sampling is based on a “huge” number of samples.

It’s not, hence the smiley.

In theory I was expecting 512 to be the threshold but the code produces the value of 793.
It’s almost there but still with some ghost readings as per the OP, hopefully a cap swap will help.

i’ve found the article about the arduino analog read. it is not for the wemos, and mainly it discussing the atmel analog multiplexer. but it has some very interesting info about how all this stuff works. (see the water tank analogy)

https://www.quora.com/Why-is-a-little-delay-needed-after-analogRead-in-Arduino#

WeMos analogue port is known to have issues too. I can’t remember if it was hardware or software related though. Will check the GitHub thread in due course,

I could not figure it out how to add daily power consumption

I 've tried alternate this section

energyCostpermonth = 24.0 * 30.0 * (WH / 1000.0) * (energyTariff / 10000.0);
to
energyCostperday = 24.0 * (WH / 1000.0) * (energyTariff / 10000.0);

nothing happening

@speed57 assuming you have worked out the energy cost for 2 seconds you just keep adding another 2 second cost.

costfor2seconds = ?*/:;xi@~;
costforday = costforday + costfor2seconds;

@Costas I put kHW price

unsigned int energyTariff = 21;

21 is energyTariff cost per hour. Am I doing wrong?

Probably.

I have:

unsigned int energyTariff = 1437; // http://www.energysavingtrust.org.uk/about-us/our-calculations

1437 gets converted to 0.1437 when divided by 10000 in the formula.
0.1437 represents 14.37 pence / £0.1437 per KWH (for UK)

in my country it is 21 per kHW. in $ is $0.065 kHW

Can you able to illustrate with code, cost for day?

You have the Tenge ₸ currency, right?

To prevent integer overflow keep:

unsigned int energyTariff = 21;

but anywhere you see:

(energyTariff / 10000.0)

use just:

energyTariff

That is correct. Thanks for input.

Is this right way to calculate daily usage of Wh?

void dailyCalculator() {
dayCalc = (WH / energyTariff);
Blynk.virtualWrite(15, dayCalc);
}

if I use 40 Wh soldering iron for 3 hours a day. How can I calc daily WH usage?
the code zeros out and also constantly changing its Wh after I unplug soldering iron it wont save previous usage

(40 WH / 1000 ) X 3 Hours X 21 ₸ / KWH = 2.52 ₸

The /1000 is to convert WH to KWH.
I will leave you to do the coding.

my problem is I cant save previous hourly/daily usage of Wh/kWh or more precisely could not figure out how to code this part. :frowning:

Are you using a 2s timer loop to read the present W from the ACS?

If not 2s, how frequently are you reading the sensor?

yes