# Why my ACS712 current sensor accuracy so bad and scale non linear?

Below is my circuit diagram for ACS712 5A current sensor using peak detector circuit.

Currently I facing 2 problems.

i)zero cross dc voltage keep changing

ii)The current scale is non linear and not accurate

For problem (i), I verified by measuring the voltage from VIOUT every time power on tend to be different even the input voltage stay almost the same(5.01V to 4.95V), I be getting output lets say in the range (2.57V to 2.43V). I replaced a new current sensor and got almost the same result. Each time after taking load current measurement, I turned off supply to the load and recheck the VIout, it tend to be different from the voltage during power on which mean the zero cross voltage changed. I'm using a 4 channel relay module and aware relay module can be power consuming so I using dual supply, one for relay module and another one for microcontroller, reference voltage and Opamp. As a result, the input voltage feeding to microcontroller, voltage reference and Opamp voltage is more stable as compare to using single supply to power all unit but that does not solve my zero cross dc voltage shifting issue. Below picture shown the relay module I currently using.

For problem(ii) my peak detector voltage does not have much changes but the measured current can be quite different? It does not scale linearly according to the 0.185mV/A formula.In term of accuracy, it is bad but reading stability is good.

Below are the pseudocode I use to calculate the current.

   pseudocode
{  void init()
__delay_ms(8000); \\ delay 8 sec on each power on for the capacitor to reach stable value

void Current()
{
PeakCurrent=0;
AveragePeakCurrent=0;
for(int u=0;u<300;u++)
{
AveragePeakCurrent=AveragePeakCurrent+PeakCurrent;
}
AveragePeakCurrent=(AveragePeakCurrent/300);
PeakCurrent=((AveragePeakCurrent-InitialCurrent)*0.009775)*4.2;

\\lastly, the differeces is times by (1/0.185)*0.7071=3.822 but i put 4.2 to offset it    to match a load measured at around 1A current but it scale non linear when measure load with different current,example 0.3A,0.8A.
PeakCurrent=fabs(PeakCurrent);
}

• You might like to compare with my ACS712 calibration results: raspberrypi.stackexchange.com/questions/94403/…. Jun 23 at 14:29
• To be honest I haven't read yet, I looked at the schematic first and first thing I saw was an SSR in series with a LED + 10.0k resistor supplied from 5V (return pulled low) and without looking at the SSR part number I doubt that's sufficient current. Jun 23 at 14:35
• Note that magnetic shields must be used ... Jun 24 at 16:58