i am trying to mesure the curent of a 12v DC motor using an arduino nano. i used this diagram
i used this code
Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
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 mode
delay(1);}
Serial.println(average);}
instead of having the right value 12.92ma (measured by amperemeter) i am havung wrong negative values
Sadly, I think we can't help.
* We don't know the measurement range of your system (to calculate the multiplier. In your case: 0.044A/LSB)
* and we don't know the zero_current_offset of your system. (to calculate the subtractor. In your case: 3.78A)
if it is an ACS712 , offset is arround VCC/2
and with a scale of 30Amps, no chance to measure 12.92 mAmps !
Event with a scale of 5Amps..
This kind of sensor dose'nt cover all the scale
ie: for 5 Amps scale AC712 sensor
you have 185mV/Amps so with ADC10 bits 5V => 37.88 points / amps
so +-512 poinst => +-13.5 Amps for +-2,5V,
it is not fo +-2,5Amps!