ACS712

/*
* http://arduspot.blogspot.in/p/acs712.html
*/

const int analogIn = A0;
int mVperAmp = 185; // use 100 for 20A Module and 66 for 30A Module
int RawValue= 0;
int ACSoffset = 2500;
double Voltage = 0;
double Amps = 0;

void setup()
{
 Serial.begin(9600);
}

void loop()
{
 RawValue = analogRead(analogIn);
 Voltage = (RawValue / 1023.0) * 5; // Gets you mV
 Amps = ((Voltage - ACSoffset) / mVperAmp);
 
 Serial.print("Raw Value = " );
 Serial.print(RawValue);
 Serial.print("\t V = ");
 Serial.print(Voltage,3);
 Serial.print("\t Amps = ");
 Serial.println(Amps,3);
 delay(1000);
}

No comments:

Post a Comment