Bad Readings with ACS723

Hey All - I have an ACS723]hooked to a redboard (providing 5V and common ground) which is then reading the current of a 12V DC source.

Using this code, the values are essentially the same

const int analogInPin = A0; // VOUT from sensor
// Number of samples to average the reading over
// Change this to make the reading smoother... but beware of buffer overflows!
const int avgSamples = 10 ;

int sensorValue = 0;

float sensitivity = 100.0 / 500.0; //100mA per 500mV = 0.2
float Vref = 2500; // Output voltage with no current: ~ 2500mV or 2.5V

void setup() {
  // initialize serial communications at 9600 bps:
  Serial.begin(9600);
  Serial.println("Initializing");
}

int LED = A5;

void loop() {
    sensorValue = 0;
  digitalWrite(LED, LOW);  // Turn off the LED in case it is on for some reason
  // read the analog in value:
  for (int i = 0; i < avgSamples; i++)
  {
    
    sensorValue += analogRead(analogInPin);

    // wait 2 milliseconds before the next loop
    // for the analog-to-digital converter to settle
    // after the last reading:
    delay(2);

  }

  sensorValue = sensorValue / avgSamples;

  // The on-board ADC is 10-bits -> 2^10 = 1024 -> 5V / 1024 ~= 4.88mV
  // The voltage is in millivolts
  float voltage = 4.88 * sensorValue;

  // This will calculate the actual current (in mA)
  // Using the Vref and sensitivity settings you configure
  float current = (voltage - Vref) * sensitivity;
  Serial.println(voltage);
  digitalWrite(LED, HIGH);
  delay(100);  // wait for a .5 second
}

Output

2449.76
2449.76
2454.64
2459.52
2449.76
2454.64
2459.52

Using a Voltmeter on the DC source I see it go from 0 - 12V.

Using a voltmeter on Vout and Ground on the ACS723 I see a fluctuation of 0.01v. So essentially nothing.

This is NOT the low current model, this is the ACS723 located here: https://www.sparkfun.com/products/13679

The source I am monitoring is on a car, the 12v wire going from the blinker relay to the lights. I have tried the same code on a Redboard and a Pro Micro C with the ACS723 with the same results.

Any help would be greatly appreciated.

Thanks!

-Joe

What is the actual current, as measured using a multimeter?

I would first test the sensor setup with an accurately known, stable current on the bench, for example a 12 Ohm 15-20 W resistor or equivalently a 12V, 12 W incandescent light bulb, connected to a 12V battery or power supply capable of providing over 1 Ampere.

Get rid of the blinker & Redboard and test the sensor by itself using a plain load. An automotive 12V incandescent brake/signal light bulb would be great.

Perform your testing with a variable power supply; it’s easier to change the current at the supply than at the load.

https://www.sparkfun.com/products/13679

Edit: Ha, what he said!

Ah yes, sorry I should have stated I tested with a bench top power supply and get the same results, the only way to get the voltage to change is to remove power or ground from the sensor.

Cheers,

-Joe

I tested with a bench top power supply

What was the power supply voltage and load resistance?

the only way to get the voltage to change is to remove power or ground from the sensor.

That makes no sense. Please post a photo of your setup, and a hand drawn diagram of the circuit.

The data you posted above showing normal noise fluctuations around 2.5V is the expected behavior of the sensor with no current flowing.

I replaced the ACS723 with an Adafruit INA260 and everything works so I will no longer troubleshoot this.

Thanks for the help folks.

-Joe