abouabdelmajid
New Member
Hi everyone
i am trying to mesure the curent of a 12v DC motor using Acs712 and arduino nano. i used this diagram
i used this code
instead of having the right value 12.92ma (measured by my amperemeter) i am having wrong negative values
Somebody can help me please
i am trying to mesure the curent of a 12v DC motor using Acs712 and arduino nano. i used this diagram
i used this code
C:
/*
Measuring Current Using ACS712
*/
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 / 1024.0) * 5000; // Gets you mV
Amps = ((Voltage - ACSoffset) / mVperAmp);
Serial.print("Raw Value = " ); // shows pre-scaled value
Serial.print(RawValue);
Serial.print("\t mV = "); // shows the voltage measured
Serial.print(Voltage,3); // the '3' after voltage allows you to display 3 digits after decimal point
Serial.print("\t Amps = "); // shows the voltage measured
Serial.println(Amps,3); // the '3' after voltage allows you to display 3 digits after decimal point
delay(2500);
}
instead of having the right value 12.92ma (measured by my amperemeter) i am having wrong negative values
Somebody can help me please