in my project i'm using a current sensor ACS712 30A, for measuring current, i tested on proteus 8.6 sp3 and works ok, but in practice (using protoboard) the sensor it's accusing current without any loads connected. here's the part of my code that deals with the ACS712 obs: i'm measuring AC current and arbritering 220 V as voltage

```
while(1)
{
char ACS[15];
char Corrente [15];
pino1 = 0;
for (i = 0; i < samples; i++)
{
pino1 = pino1+ ( ADC_Read(0) - 511.95 );
}
current = pino1;
current = current / samples;
current = current * current;
current = sqrt(current);
current = current / 8.6f;
FloatToStr(current, Corrente);
potencia = ( current * 220 );
FloatToStr(potencia, ACS);
Lcd_Cmd(_LCD_CLEAR);
Lcd_Cmd(_LCD_CURSOR_OFF);
Lcd_Out(1, 1, "AMP =");
Lcd_Out(1, 7, Corrente);
Lcd_Out(2, 1, "P =");
Lcd_Out(2, 5, ACS);
Lcd_Out(2, 16, "W");
}
```

## Best Answer

If ADC_Read(0) is 0 or not, pino1 = samples × -511.95. This will account for your numbers, which should equal 59.5A (assuming ADC_Read(0) = 0).

Additionally:

So

current = current * current;andcurrent = sqrt(current);do nothing.I'll assume

current = current / 8.6f;, factors out the -511.95.