ACS714 current sensor

Hello, I am working with the ACS714 to measure a 12V supply to a Pololu DRV8835. I am using an Arduino Uno operating independently of the DRV8835 and its Raspberry Pi. I am connecting the proper pins on the ACS714 to 5V, GND and in my case A0 on the Arduino Uno. Here’s my sample code:

[code]const int analogInPin = A0; // Analog input pin that the potentiometer is attached to
int sensorValue = 0; // value read from the pot
int outputValue = 0; // value output to the PWM (analog out)
int increment = 0;
void setup() {
// initialize serial communications at 9600 bps:
Serial.begin(9600);
}

void loop() {
// read the analog in value:
sensorValue = analogRead(analogInPin);
outputValue = (((long)sensorValue * 5000 / 1024) - 2500 ) * 1000 / 66;
Serial.print(increment);
Serial.print("," );
Serial.print(sensorValue);
Serial.print("," );
Serial.println(outputValue);
delay(10000);
}[/code]

I am getting negative readings for mA on the output. Here’s a sample:

0,504,-606 0,502,-742 0,502,-742

Can you tell me what’s I’m doing wrong? Thanks!
Jay

Hello, Jay.

The ACS714 current sensors can read a negative current (e.g. when to sensor is installed with reverse polarity). You can account for this in your code, or reverse the way the sensor is installed.

-Derrill

[quote=“Derrill”]Hello, Jay.

The ACS714 current sensors can read a negative current (e.g. when to sensor is installed with reverse polarity). You can account for this in your code, or reverse the way the sensor is installed.

-Derrill[/quote]

Thanks! This was exactly the fix. I thought I had checked it prior to wiring the circuit, but found this to be the case.