jremington:
Good eye, Tom:
I couldn't read the markings on the IC without that hint. That must be the ACS758 sensor. The PCB looks nicely made.
Here is the data sheet http://www.allegromicro.com/~/media/Files/Datasheets/ACS758-Datasheet.ashx
Looking at the data sheet, I realized I had misread the ebay advert. The sensitivity of the unidirectional 200 amp sensor is 20 mV/amp, not 26.6
@jason: I hope you got the bidirectional variety rather than the unidirectional. I was assuming unidirectional when I suggested a scaling approach. If bidirectional (which you need for the battery to take into account charge/discharge), the output of the ADC will correspond to about 1/2 of the sensor supply voltage for 0 amps and then increase or decrease from there as the current is positive or negative. Also the bidirectional and unidirectional current sensors have different sensitivities.
So, something like:
// convert 50 amp bidirectional sensor reading into amps
float volts = ((float) adcvalue)*5.0/1023.;
float amps = (volts-2.5)/0.040; //will probably have to adjust the 2.5 offset value for 0 amps
hm ok, well i have tried your code, and modified it slightly to suit me, but i just cans seem to get it to read correctly.
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
}
void loop() {
// convert 50 amp bidirectional sensor reading into amps
int sensorValue = analogRead (A1);
float voltage = ((float) sensorValue)*5.0/1023;
float amps = (voltage-2.558)/0.040; //will probably have to adjust the 2.5 offset value for 0 amps
Serial.print (amps);
Serial.println ("A");
delay (1000);
}
am i correct that the 2.5 value is just the assumed vcc/2 of the vref pin? as it should be 5v, but mine is only 4.91 so 4.91/2=2.455V
i have tried to modify the 2.5 value, and to get my sensor as close to "zero" as possible, (i could only get it as close as -0.04A) i ended
up with 2.558. when i tried the 2.455 i ended up with 2.53A with no load on the serial output.
but, my output with my 6A load is 2.4A (this is back to the 2.558 value in the code), which is the MV/A offset for the 6A load. i just cant get it to read 6A. i have tried to move the 0.040 around, and i get readings that are wrong.
im sure that the code is correct, just i think that the math is wrong somewhere. i just cant see where. as in my mind, the sequence of flow of the math is correct, but even with a calculator, i dont get a reading thats even close to whats been reported.
or is there something super simple that i am overlooking?
cheers
Jason