1

I am using an Arduino Uno. analogRead(A0) (or whichever channel I use) returns 0 when it is grounded with Arduino Gnd, and 1023 when connected to Arduino 5v. But when I connect it to a current sensor (ACS712) it is always fluctuating like this:

0, 0, 0, 0, 0, 0, 1023, 1023, 1023, 1023, 1023, 441, 446, 0, 0, 0, 0, 1023, 1023...

I also tried it with a potentiometer (10K) and analog joystick: the results are the same. I tried changing different power supplies (both Arduino's and the sensor's (ACS712, potentiometer, joystick)). I even tested it on an Arduino Mega, but no luck. Such extreme fluctuation are making no sense to me. Kindly help me what could be the issue.

My wiring diagram is attached to this post. And I use an external supply to the ACS712. Is it possible that Static electricity is causing this issue?

Code:

void setup() {
  Serial.begin(9600);
}

void loop() {
  float value = analogRead(A0);
  Serial.print("Raw:");
  Serial.println(value);
  delay(500);
}

Thanks.

enter image description here

  • 1
    please add a schematic of your connections – jsotola Jan 7 '18 at 17:34
  • You say you are supplying the ACS712 from an external supply. Do you have the Arduino ground and the external supply ground connected? A full schematic would be more useful because possibly the problem is not in the part shown. – Mark Smith Jan 7 '18 at 17:43
  • 2
    Maybe you are just measuring an AC current, in which case the “fluctuations” are normal and expected. – Edgar Bonet Jan 7 '18 at 17:45
  • @Mark Smith I am not using Arduino Gnd ACS712 is using Gnd from External PowerSupply....From Arduino I am only using its Analog Pin 0 – Hassaan Shah Jan 7 '18 at 17:46
  • @Edgar Bonet I am using DC supply as current source to ACS712 – Hassaan Shah Jan 7 '18 at 17:48
3

You need to connect together the grounds from your external power supply and the Arduino.

At the moment the two devices are floating - there's no commonly-agreed 0v point.

| improve this answer | |
  • You are awesome...Thanks for your help much appreciated. Solved my problem – Hassaan Shah Jan 7 '18 at 18:00
0

I had a similar issue with fluctuating values. Make sure you are setting in your code the analog PIN as INPUT pin. On some boards you have to specify it explicitly, like this:

pinMode(A1, INPUT);
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.