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


Simply put, I wanted to start using the ACS712 (30amp) in some of my code, so I thought I’d que it up to run alone just to get a feel for it. I used the code found in a post by @Jamin to sample the device.

Link: 2 Way Lighting

Right now I have it configured, the red power light is on and it’s “Out” is plugged into A0. Why am I getting Voltage Readings of 3530.27 and Amps of 15.61 with nothing running across the bus terminals? If no AC line voltage is connected across the terminals wouldn’t you expect to get something close to “0” ??


Here is my code. Simple as it may be:

**#include <Blynk.h>**
**#include <ArduinoOTA.h>**
**#include <ESP8266WiFi.h>**
**#include <BlynkSimpleEsp8266.h>**
**#include <SimpleTimer.h>**

#define BLYNK_PRINT Serial
#define SERIAL_EN  //comment out if you don't want any serial output
#ifdef SERIAL_EN
#define SERIAL_BAUD   115200
#define DEBUG(input)   {Serial.print(input);}
#define DEBUGln(input) {Serial.println(input);}
#define SERIALFLUSH()  {Serial.flush();}
#define DEBUG(input);
#define DEBUGln(input);
#define SERIALFLUSH();

//***********  Blynk Instructions ****************************

char auth[] = "023a64434af9***********************";
const char* ssid = "********************";
const char* password = "*************";


int mVperAmp = 66; // use 100 for 20A ACS712 Module and 66 for 30A ACS712 Module
int ACSoffset = 2500;
double Voltage, Amps;

SimpleTimer ACcheck;

void setup() {

  // ***************** COMMUNICATIONS PARAMETERS *********

#ifdef SERIAL_EN
  Serial.println("Serial Comm's Started");
  Blynk.begin(auth, ssid, password);
  while (Blynk.connect() == false) {}


  Serial.print("\tAssigned Local IP:\t\t");
  if (WiFi.status() == WL_CONNECTED) {
    Serial.println("\tWiFi  C O N N E C T E D !!!.");
    Serial.println("\tWifi Started");
  else {
    Serial.println("\tWiFi  P R O B L E M" );
  Serial.println("\tOTA Starting");

  ArduinoOTA.begin();  // is there a way to verify this is running?

  Serial.println("\tACcheck Starting");

  ACcheck.setInterval (2000L, readACS712);

  Serial.println("\tComm's Complete");

  Serial.print("\tVoltage  ");
  Serial.print("\tAmps  ");


void loop() {



void readACS712() {
  Voltage = (analogRead(A0) / 1024.0) * 5000;
  if (Voltage <= 2500) {
    // detected nothing
    Blynk.virtualWrite(V1, 0); // update LED widget state when detecting current
    Voltage = 2500;
    Amps = 0;
  } else {
    // detected current
    Blynk.virtualWrite(V1, 255); // update LED widget state when detecting current
    Amps = ((Voltage - ACSoffset) / mVperAmp);
    Blynk.virtualWrite(V2, Amps); // report Amps, because why not monitor power usage too?

I don’t have one on hand to test this… but I would suspect it is similar to how the analog pins on an Arduino will give false & fluctuating readings until actually hooked up to something that gives a solid ground reference when off.

In other words, your readings will be random and/or false until actually hooked up to the AC line, even if no voltage is present, it will at least be referenced to ground.

@Gunner, i do not think this is the case.
i use these sensors, and they have separate gnd pin, what you have to hook up to the mcu gnd, so they are not floating, even when no wires at all are connected to the hall sensor.

@Lane0138, you didn’t specified what proto board are you using, but what you should consider, that acs712 sensors are 5v devices, but esp is 3.3v

so, this can be the first problem. the second, that acs712 can measure current in both direction, and the output range is 0-5v. so, when no current flowing, it should be around 2.5v (0-2.5v is one direction, 2.5-5v is other direction)

maybe you should post a photo or link with your acs module, but i’m pretty sure you are trying to use a 5v version with 3.3v mcu…

I was referring to the sensor end of the device, it is magnetically isolated from MCU ground… but your catch of the 3.3v power source makes more sense :+1: I am too used to 5v devices and sensors… must get out more :stuck_out_tongue_winking_eye:

here is a detailed video about acs712:

That’s funny… that was one of the videos I re-watched when I saw this post. Julian Ilett is one of my favorite subscribed channels… I particularly like his “Postbag!!” videos… he buys all the cheap China toys I can’t :smiley:

And has fun reading the chinglish instructions :wink:

i also watch some of his videos. this one is really useful regarding the presentation of the acs712 module and working principle, however the code seems a bit over complicated to me…

i use this:

  for arduino uno
  testing sketch for the ACS712 current sensor module

  vcc: 4.5 - 5.5 v
  icc: 13 - 15 ma
  zero current output voltage: vcc × 0.5 (2.5 v)

  +- 5 a: 185 mv/a (+-13513 mamper @ 5v)
  +-20 a: 100 mv/a (+-25000 mamper @ 5v)
  +-30 a:  66 mv/a (+-37878 mamper @ 5v)

  theoretical resolution for 5v analog pin:
  (arduino resolution: 4.8828 mv)
   5a: 26.4ma
  20a: 48.8ma
  30a: 74.0ma

  error @ 25c: +-1.5 %

  module -> arduino
  vcc    -> 5v
  gnd    -> gnd
  out    -> analog pin (a0)

#define ACS          A0
#define SENSITIVITY  66    // acs712 model SENSITIVITY in mv
#define SAMPLING    100.0  // set samples before averaging

void setup() {
  pinMode(ACS, INPUT);

void loop() {
  float avgAmps;

  for (int i = 0; i < SAMPLING; i++) {
    int rawACS = analogRead(ACS);
    float mv = rawACS / 1023.0 * 5000.0;
    float rawAmps = (mv - 2500.0) / SENSITIVITY;  // set sensor calibration here
    avgAmps += rawAmps;

  float Amps = avgAmps / SAMPLING;

  delay(1);                                       // delay between analog reads for value stability

This make sense. It needs something to chew on.



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?

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.


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:
    ___  __          __
   / _ )/ /_ _____  / /__
  / _  / / // / _ \/  '_/
 /____/_/\_, /_//_/_/\_\
        /___/ 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