Hi everyone
i am trying to mesure the curent of a 12v DC motor using an arduino nano. i usedthe diagram attached and this code
void setup() {
Serial.begin(9600);
}void loop() {
float average = 0;
for(int i = 0; i < 1000; i++) {
average = average + (.044 * analogRead(A0) -3.78) / 1000;//5A mode, if 20A or 30A mode, need to modify this formula to
//(.19 * analogRead(A0) -25) for 20A mode and
//(.044 * analogRead(A0) -3.78) for 30A modedelay(1);
}
Serial.println(average);
}
instead of having the right value 12.92ma (measured by amperemeter) i am havung wrong negative values
Somebody can help me please