+ Post New Thread
Results 1 to 2 of 2
  1. #1
    Newbie level 1
    Points: 1,155, Level: 7

    Join Date
    Dec 2011
    Location
    India
    Posts
    2
    Helped
    0 / 0
    Points
    1,155
    Level
    7

    AC Current measurement ranging from 100mA to 5 A using ACS712

    Hello guys, i am working on IoT project in which i need to measure AC current of Home appliances.Mains power supply voltage is 240 V 50HZ. Smallest load is drawing 100 m Amps. and highest load is drawing 5 Amps.I am using ACS712 hall effect for current sensor. I have 8 channel relay board,at each relay contact i have connected ACS712. At lower range i am not able to differentiate between noise and current output.I don't precise current measurement.I am using 12bit ADC of Wemos Lolin 32 for measurement.

    How can i measure AC current as small as 200 mA? also is there any other integrated that i can use instead of ACS712.

    Code:
    const int sensorIn = A0;
    int mVperAmp = 100; // use 100 for 20A Module and 66 for 30A Module
    double Voltage = 0;
    double VRMS = 0;
    double VRMS1 = 0;
    double AmpsRMS = 0;
    
    
    void setup() 
    {
    Serial.begin(115200);
    }
    
    void loop() 
    {
      Voltage=getVPP();
      VRMS=(Voltage/2.0)*0.707;
      AmpsRMS=(VRMS*1000)/mVperAmp;
      Serial.print(AmpsRMS);
      Serial.println(" Amps RMS");
      // put your main code here, to run repeatedly:
    
    }
    
    float getVPP()
    {
    float result;
    int readValue;
    int maxValue=0;
    int minValue=4095;
    uint32_t start_time=millis();
    
      while((millis()-start_time)<1000) //sample for 1 sec
      {
        readValue=analogRead(sensorIn);
       
      
        if(readValue>maxValue)
        {
          maxValue=readValue;
        }
    
        if(readValue<minValue)
        {
          minValue=readValue;
        }
      }
      //maxValue = 4095-maxValue;
      //minValue=4095-minValue;
      result=((maxValue-minValue)*3.3)/4095.0;
    Serial.println(maxValue);
    Serial.println(minValue);
    return result;
    }
    Last edited by KlausST; 2nd March 2018 at 11:41. Reason: corrected tags

    •   Alt2nd March 2018, 11:15

      advertising

        
       

  2. #2
    Super Moderator
    Points: 60,133, Level: 59
    Achievements:
    7 years registered
    Awards:
    Most Frequent Poster 3rd Helpful Member

    Join Date
    Apr 2014
    Posts
    12,292
    Helped
    2845 / 2845
    Points
    60,133
    Level
    59

    Re: AC Current measurement ranging from 100mA to 5 A using ACS712

    Hi,

    Mains current measurement has been discussed many times here .. and more often in the internet.
    Use the search function to get more informations.

    Code:
    Voltage=getVPP();
    VRMS=(Voltage/2.0)*0.707;
    AmpsRMS=(VRMS*1000)/mVperAmp;
    This is the worst method to measure AC current.
    This method is only useful for clean, noise free, pure sine wave without distortion. A mains application usally can not guarantee this.
    Any noise, and any voltage peak generates huge error/noise in output value.

    --> use true RMS calculation software.
    If you find this too difficult, the use software to "rectifiy" the input signal and calculate the average from this. Multiply it by 1.11 to get RMS value. (Pi / (2* sqrt(2) = 1.11)
    This is not as good as true RMS, but much better than peak method.

    Klaus
    Please don´t contact me via PM, because there is no time to respond to them. No friend requests. Thank you.



--[[ ]]--