Interfacing Allegro ACS754 with Arduino

I have this little code:

#include <LiquidCrystal.h>

LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

const int voltPin = 1;
const int ampPin = 3;
int A = 0;

void setup() {
lcd.begin(16, 2);
}

void loop() {

float volt = (analogRead(voltPin) + 1) * .00488;
lcd.setCursor(1,0);
lcd.print(volt);
lcd.setCursor(8,0);
lcd.print("Volt");

A = (analogRead(ampPin)-512);
lcd.setCursor(1,1);
lcd.print(A);
lcd.setCursor(8,1);
lcd.print("mA");
delay(200);
}

My goal is to read voltage and mA on a 16x2 LCD.
The part of the voltave is done, but I can't solve the part of interfacing with ACS754.

The main charateristics of the current sensor is:
Vcc =5.0v
Zero current = 2/Vcc = 2.5v (at output pin = analogRead 3)
Sensitivity = 13.3 mV/A = 0.0133v

Can some one help me and explain the math for this divider, and make this thing work :slight_smile:

The A/D gives you a reading of 1023 for 5V input
So for a given reading R you have a voltage of:-
V = R * (5/1023)
With the current sensor you have half way biased signal so a voltage reading of:-
V = (R-511) * (5/1023)
at 13.3 mV per Amp
you have
Amps = V / 0.0133

This gives you a resolution of 367mA per reading increment. Given that you always get plus or minus one on a digital to analogue converter your accuracy will approximately be to the nearest half an amp. (734mA)