2

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

dda
1,5951 gold badge12 silver badges17 bronze badges
asked Jan 7, 2018 at 17:22
5
  • 1
    please add a schematic of your connections Commented Jan 7, 2018 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. Commented Jan 7, 2018 at 17:43
  • 2
    Maybe you are just measuring an AC current, in which case the "fluctuations" are normal and expected. Commented Jan 7, 2018 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 Commented Jan 7, 2018 at 17:46
  • @Edgar Bonet I am using DC supply as current source to ACS712 Commented Jan 7, 2018 at 17:48

2 Answers 2

4

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.

answered Jan 7, 2018 at 17:49
1
  • You are awesome...Thanks for your help much appreciated. Solved my problem Commented Jan 7, 2018 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);
answered Aug 15, 2020 at 21:11

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.