Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

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

Status
Not open for further replies.

keen bm

Newbie level 2
Newbie level 2
Joined
Dec 21, 2011
Messages
2
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Location
India
Activity points
1,298
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 a moderator:

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
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top