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

This make sense. It needs something to chew on.

Thanks

@wanek,

I am using a Wemos D1 Mini. But… I thought the D1 had a 5v output that should provide the required juice. Correct?

I just threw a VoltMeter on it the Wemos D1 Mini 5v pin is outputting 4.82v DC to the ACS board. Is that enough or just so short that it matters?

no, sorry. i think you do not understand.
the acs sensor indeed needs 5v for vcc. but this is only one part.

this module outputs a signal between 0 and 5 volts, depending on the current flowing through (it will output 2.5v when no current flowing in any direction). but the wemos analog pin awaits a maximum input of around 3.3v. this is why you will not receive accurate results (at least this is what i think, i can not test this right now, but maybe tomorrow i can do a test)

my theory is, that you should feed 5.0vcc in the module, but reduce the output with an appropriate voltage divider, from 5.0v to around 3.3v, or whatever the wemos waits.[quote=“Lane0138, post:9, topic:12143”]
I just threw a VoltMeter on it the Wemos D1 Mini 5v pin is outputting 4.82v DC to the ACS board. Is that enough or just so short that it matters?
[/quote]

this is correct. practically the 5v pin on the wemos is hooked up directly to the 5v on the usb, so it is supplied from pc usb port. the usb 2.0 standard says, that all usb ports should be able to provide at least 0.5ampers. the wemos consumes around 75ma.
this gives: 500ma - 75ma = ~425ma. so, as long as you not exceed the 425ma current consumption, you can hook up anything you want on the wemos 5v pin. (the measured 4.82v is acceptable, could be less if you are using a very long or low quality usb cable).

@wanek ,

Great idea.

I was only thinking of the flow from Wemos>ASC but your saying , try feeding the ACS 5v direct. Then, using a divider of R1 5 ohms and R2 of 10 Ohms giving us an output of 3.333v from the ACS Data Signal Out, over to A0 on the Wemos.

Simple, but Genius !!! I’ll give it a go!!

Thanks Again

Googling ACS712 and 3.3v found some interesting posts.

Here is another source of inspiration in the level shifting option.

And this one seems to get into the nitty gritty’s. Also seems to imply that this device will run equally well on 3.3v? I guess you can always try and see if a software calibration solution is possible on that lower voltage.

DO NOT DO THAT!!!

the theory is ok, but the resistor values you have chosen are way too low.

lets do the math: 5 ohms + 10 ohms = 15 ohms, at 5volts. using ohms law, you can calculate the current: 5v / 15 ohms = 0.333amper

this means you will have a current consumption of 0.333amper on your voltage divider!!!
beside that gives 0.333a x 5v = 1.66w heat generated on the resistors, it will also put an unnecessary stress on your usb port.

for voltage dividers we always use a much higher resistor values. this is one thing. and the other, that the wemos, unfortunately has a incorporated voltage divider too on the analog pin, further complicating the calculations…

this is why i always use a simple solution regarding voltage dividers: a trimpot! you can choose a value between 4.7k and 10k (or even more).

this is my theory:

  • hook up the acs sensor to the wemos 5v pin and gnd, with absolutely no current flowing on the input

  • hook up wemos gnd and acs sensor output to the 2 side pins of the trimpot (doesn’t matter which is which side)

  • multimeter gnd goes to wemos gnd, and multimeter input to trimpot middle pin (viper). set dmm to dc voltage measurement

  • now turn the trimpot screw until you will get around 3.3 / 2 = 1.65v on the viper

  • hook up wiper to the wemos analog pin, and serial print the analog pin raw value to the display. now fine tune the trimpot until you get 512 on the screen. this way you converted the 5v signal to 3.3v but also calibrated the acs module output to null.

probably you will loose some resolution / precision converting from 5v to 3.3v, but it should be usable for hobby. i assume you do not work for nasa…

also, it is easy to check the accuracy of the system, if you hook up your dmm in series with acs module, and compare the values (after mapping the raw values to the actual amperes of course on the wemos)

the official datasheet clearly says vcc min 4.5v, max 5.5v

i think it is always good idea to remain between the manufacturer reccomendation…

Good point… but is he monitoring a house lamp or a nuclear reactor? (you never know nowadays :wink: ) The device is cheap enough to play around with if it works. If it doesn’t, then fiddle with the level shifters.

I know it’s an old thread but I checked my ACS712’s with 3.3V and they don’t appear to work. I started with 5V on a Leonardo and it was fine but when you drop down to the Leonardo’s 3.3V the LED lights on the ACS712 board but doesn’t appear to give any data.

I checked the datasheets for the voltage drop on the board but couldn’t find it. When running at 5V if you put a meter between the data pin on the ACS712 and GND you will get around 3V. This is from an actual Leonardo voltage, per the meter, of 5.07V.

I find that the 5V pin on the WeMos is generally around 4.8V and the ACS712 data pin to GND is around 2.4V. This is all well within the 3.3V to 5.0V tolerance of the WeMos data pins, depending which literature you read.

So providing you are not working with a single WeMos and have a 6 week lead time for a replacement then it should be fine to use the 5V ACS712 with the WeMos.

We have had one running for 24 hours and all is fine.

Depending what libraries you use and whether you are reading AC or DC you might find some strange behaviour. Like it’s recommended you boot the device with no current connected to the ACS712. That’s OK if you are just checking a few devices in your property but not feasible for whole house metering.

The other think some of the guides mention is “current leak” whatever that is.

In my project it reads the sensor every second and only prints to Serial Monitor if it detects a current.
Over the last 9 hours (32400 readings) it has detected a current 6 times when the connected device is OFF. So 99.98% accurate as far as detecting the current but I need to do much more testing to check the actually accuracy of the Amps it reports.

@Gunner and @wanek what’s all this current leak about?

  • if you could share some links about the docs with the current leak, it would be helpful…

  • i also studied quite a lot these senors, and found that if you do the math, if 2.5v == 0 amps, and you take the sensors max ampere rating, it will never reach 5v or 0v, it remains way much overhead. i do not know why it is done this way, maybe to protect the analog pins, or what?

but depending on what is the max current you wish to measure, sometimes one can safely use a wemos with the 3.3v analog pin. just power the sensor from 5v, to provide stable working voltage. if i will get to my pc, i can provide more calculations for various sensors.

even if sometimes there will be spikes higher than 3.3v, the wemos probably will survive.

for the false readings you mention, there can be several reasons:

  • do not forget, this is hall efect sensor. so it can measure any current flowing around, not just what is flowing through it. if you put a cable near the sensor with current flow, it will measure. also, it is sensible to rf. and wemos has rf… you could test this false triggers with 2 wemos. one with wifi on, and one with wifi off, on serial monitor. then after lots of hours compare the results.

  • false trigger also can depend on what is the minimal threshold you set? maybe it is too low and the cable you connected to the sensor collects rf noise, or has some minimal current flow. i also heard somewhere that the analog pin on esp8266 can be influenced by the wifi activity.

  • i’m not sure how the analog pin works on the wemos, but on atmega mcus there are known issues regarding the analog measurements. definetly helps a lot if you understand how it works. i have found a very good article explaining this.
    i will post if i find again.

Found the current leak reference again at https://github.com/rkoptev/ACS712-arduino/blob/master/examples/Wattmeter/Wattmeter.ino

During the 9 hours I received the 6 “false” readings I was on the beach :slight_smile:
Now I am back in the office I am seeing many more false readings.
Nothing get’s turned off in the office when we are out.

but what is the treshold you set?

Based on the code I have and zero normally being 512 (midway between analogue 0 and analogue 1023) the automatic zero comes up at 793. See below the 95 and 96 are number of seconds since reboot (millis() / 1000) and are not false readings.

Calibrated with zero at 793
[5753] Connecting to GargoyleTest
[6754] Connected to WiFi
[6754] IP: 192.168.10.167
[6754] 
    ___  __          __
   / _ )/ /_ _____  / /__
  / _  / / // / _ \/  '_/
 /____/_/\_, /_//_/_/\_\
        /___/ v0.4.8 on Arduino

[6760] Connecting to blynk-cloud.com:8442
[7005] Ready (ping: 75ms).
AC current is 0.1429 Amps and power is 34.30 WH at 95
AC current is 0.1429 Amps and power is 34.30 WH at 96

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.