Yes, the ACS712 can absolutely measure AC current. Because it uses a Hall-effect sensor to detect the magnetic field generated by the current passing through the internal copper conduction path, it tracks both positive and negative half-cycles of an AC wave perfectly.

However, because AC current constantly changes direction and magnitude (typically a 50Hz or 60Hz sine wave), reading it with an MCU ADC requires a different approach than reading DC.

Here is how it behaves and how to handle it:

1. The AC Waveform Output

When measuring AC, the ACS712 output voltage will mirror the AC waveform, riding on top of the $2.5\text{ V}$ baseline:

  • No current: A flat line at exactly $2.5\text{ V}$.
  • AC current flowing: A sine wave oscillating above and below $2.5\text{ V}$. For example, if the peak current causes a $0.5\text{ V}$ swing, the output voltage will swing between $3.0\text{ V}$ (positive peak) and $2.0\text{ V}$ (negative peak).

If you simply take a single random ADC read, you will just get a snapshot of a single point on that sine wave, which is useless for calculating power consumption.


2. How to Read AC with your ADC

To get a meaningful measurement (like RMS current), your microcontroller needs to sample the waveform rapidly over a set period (usually covering at least one or two full AC cycles).

  1. Sample Rapidly Over a Time Window Loop and read the ADC as fast as possible for a specific duration—usually $20\text{ ms}$ (for a 50Hz wave) or $16.7\text{ ms}$ (for a 60Hz wave) to capture at least one full cycle.

  2. Find the Peak-to-Peak Voltage Track the absolute maximum value ($V_{max}$) and the absolute minimum value ($V_{min}$) recorded during that sampling window. Subtract them to find the total peak-to-peak voltage: $$V_{pp} = V_{max} - V_{min}$$

  3. Calculate Peak Voltage Divide the peak-to-peak voltage by 2 to get the peak amplitude relative to the zero-current baseline: $$V_{peak} = \frac{V_{pp}}{2}$$

  4. Convert Voltage to RMS Voltage For a pure sinusoidal wave, calculate the Root Mean Square (RMS) voltage by multiplying the peak voltage by $0.707$ (which is $1 / \sqrt{2}$): $$V_{rms} = V_{peak} \times 0.707$$

  5. Calculate RMS Current Divide the calculated $V_{rms}$ by your specific sensor model's sensitivity (e.g., $0.185\text{ V/A}$ for the 5A model) to get the true AC RMS current: $$I_{rms} = \frac{V_{rms}}{\text{Sensitivity}}$$

3. Alternative Method: True RMS Calculation

If your AC load isn't a perfect sine wave (e.g., switching power supplies, dimmed lights), the peak-to-peak shortcut above will be inaccurate. In those cases, you need to calculate the mathematical True RMS directly in code:

  1. Take a sample and subtract the $2.5\text{ V}$ offset to get the instantaneous voltage delta.
  2. Square that delta value ($V_{delta}^2$) and add it to a running total.
  3. Repeat this for a few hundred samples over a full cycle.
  4. Divide the running total by the number of samples taken (finding the average/mean).
  5. Take the square root of that mean to get $V_{rms}$, then divide by the sensor sensitivity.

ref