AC Current Measurement using ACS712

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?

  1. What is AC Current?
  2. 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.

ACS712 Arduino Circuit
ACS712 Arduino Circuit for AC Current measurement

Arduino Code for AC Current Measurement

AC Current Measurement Result

Open Serial terminal to see the Current readings. Read more on DC current measurement.

AC Current measurement using ACS712
AC Current measurement using ACS712

5 thoughts on “AC Current Measurement using ACS712

  1. 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

    1. 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)

  2. 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?

Leave a Reply

Your email address will not be published. Required fields are marked *