The ACS712 measures current in two directions. It means that if we sample fast enough and long enough, we sure to find the peak in one direction and the peak in another direction as the ACS712 have 5 μs output rise time in response to step input current. We are measuring AC current of 50Hz i.e. 20mSec per cycle and we get around 4000 Samples in one cycle.
With both peaks known, it is a matter of knowing the shape of the waveform to calculate the current. In the case of line or mains power, we know that waveform to be a SINE wave. Knowing that allows us to apply a basic electronic formula to yield a decent result.
RMS Current = root(2) * Peek Current
What you will learn?

What is AC Current?

How to measure AC Current using ACS712?
Circuit Connection for AC Current Measurement
Circuit for the AC Current Measurement is same as we used for DC current except the load and source are AC.
Arduino Code for AC Current Measurement
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 
/* Measuring AC Current Using ACS712 www.circuits4you.com */ const int sensorIn = A0; int mVperAmp = 185; // use 100 for 20A Module and 66 for 30A Module double Voltage = 0; double VRMS = 0; double AmpsRMS = 0; void setup(){ Serial.begin(9600); } void loop(){ Voltage = getVPP(); VRMS = (Voltage/2.0) *0.707; //root 2 is 0.707 AmpsRMS = (VRMS * 1000)/mVperAmp; Serial.print(AmpsRMS); Serial.println(" Amps RMS"); } float getVPP() { float result; int readValue; //value read from the sensor int maxValue = 0; // store max value here int minValue = 1024; // store min value here uint32_t start_time = millis(); while((millis()start_time) < 1000) //sample for 1 Sec { readValue = analogRead(sensorIn); // see if you have a new maxValue if (readValue > maxValue) { /*record the maximum sensor value*/ maxValue = readValue; } if (readValue < minValue) { /*record the minimum sensor value*/ minValue = readValue; } } // Subtract min from max result = ((maxValue  minValue) * 5.0)/1024.0; return result; } 
AC Current Measurement Result
Open Serial terminal to see the Current readings. Read more on DC current measurement.
Thanks for taking time to explain this.
Where I got lost is why are we tracking this code with :
uint32_t start_time = millis();
while((millis()start_time) < 1000)
You passe the value of milli() function into a variable and subtracted the same value from it self Isn't that = 0?
Why not just say:
While( 0 maxValue)
{
/*record the maximum sensor value*/
maxValue = readValue;
}
if (readValue < minValue)
{
/*record the minimum sensor value*/
minValue = readValue;
}
}
// Subtract min from max
result = ((maxValue – minValue) * 5.0)/1024.0;
return result;
}
Please I am really a learner, I learn from professionals like you.
Please correct me where I am wrong.
Regards
Ajiri
Millis gives you time from controller started and it always running so you will never get zero
uint32_t start_time = millis(); //Current Time
while((millis()start_time) < 1000) //Current Time  Previous Time (start_time time is always running forward)
Why are we measuring the maximum and minimum current values?
So, does your code need to be changed for 120v AC? When I run it on my setup–
ACS174, 30a
120v AC
40w lamp “ON”
I get this output–
0.39 Amps RMS
If it multiply known 120v by .39 I get 47W (not 40)
With the lamp turn off sketch output is .13 (15W)
Suggestions?
What is the maximum current this sensor can handle?