ACS712-5A current sensor

I am working with ACS712- 5A current sensor module. I connected two different loads{in series} one is of 200W bulb and other is immersion heater of 1000W to detect the current value. The supply voltage is 240V for both loads. A multimeter is also connected in the series to validate the current that is being displayed in the Arduino serial monitor. When with no-load it is displaying 0.14 A and whereas bulb is connected as load the current displayed in the multimeter is 0.76 A and in Arduino serial monitor is 0.79 A . When immersion heater is connected as load the current displayed in multimeter is 4.26 A and in serial monitor it is 3.8 A. What may be the reason that I am not getting correct values of current with Arduino. Is there any wrong with my code or am I missing something in hardware connection or any information related to sensor from the datasheet. Is it possible that the sensor might not be accurate[The ACS712-5A has sensitivity of 0.185V/A as mentioned in the datasheet.]

void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);

  // analogReference(INTERNAL);

}



void loop() {
  // put your main code here, to run repeatedly:
  float slope= 0.185, Voffset= 2.5,vref=5.0;
  int adcmax= 0, adc_value;

  int samples= 10000;

  for(int i= 0; i< samples; i++){

    adc_value= analogRead(A1);

    if(adc_value > adcmax)
      adcmax= adc_value;

  }

  float Vmax= (((float) adcmax/1023) *vref) - Voffset;
  float Imax= ((float)Vmax) /slope;
  float Irms= (((float)Imax) / (2* pow(2, 0.5)));

  Serial.print("Irms: ");
  Serial.println(Irms);

}


to measure AC currents I tend to use a none-invasive clamp such as the SCT-013
available in a range of currents from 5amp to 100amp
clamp it around ONE of the supply leads

The 0.79A current in no load is the zero error of your ACS sensor. To get the accurate value in output you need to subtract this error value in the code itself.

Try this:

Serial.println(Irms - 0.79);

You will get the correct value.

Your code is a very simple way to measure AC current. In a first try I used also your way of measuring but I kept also the adcmin value. Testing with a power meter it turned out that I could better use 177 mV/A. I have better experience with using a filter library. But also then I see that the Acs712 is not very accurate. Using filters is also better when using dimmers which causes that the current is not a real sinus wave. My code:

// This code (each 1 second ampere measurement) works with Acs712 5A current sensor
// For connection see https://peppe8o.com/current-sensor-acs712-with-arduino-uno-using-the-hall-effect/

#include   <Filters.h>              // See: https://github.com/JonHub/Filters/tree/master/src has RunningStatistics for calculating current 

#define ACS_Pin A0                  // Sensor data pin on A0 analog input

float zeroAmpereOffset = -0.06;     // Based on calibration testing 
float multiplyFactor = 0.0275;      // Depends on type of Acs712, based on calibration testing with Cresta RCE-1106 

RunningStatistics runningStatistics;

void setup() 
{
  Serial.begin( 9600 );    
  pinMode(ACS_Pin,INPUT);  

  runningStatistics.setWindowSecs(1);     
}

void loop() 
{
  float measuredAmpere = GetMeasuredAmpere();

  Serial.print("Measured ampere: ");
  Serial.println(measuredAmpere);
}

float GetMeasuredAmpere()
{
  unsigned long startMillis = millis();
  unsigned long curMillis = startMillis;
  while( curMillis - startMillis <= 1000 )
  {   
    int analogValue = analogRead(ACS_Pin);  
    runningStatistics.input(analogValue);          
   
    curMillis = millis();   // update time
  }

  return zeroAmpereOffset + multiplyFactor * runningStatistics.sigma();
}

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.