Back to Sensors & Actuators Series

Current Sensor: ACS712

July 21, 2025 Wasil Zafar 8 min read

ACS712 deep dive — Hall-effect current sensing, analog interfacing, zero-offset calibration, complete code, and real-world power monitoring applications.

Contents

  1. Working Principle
  2. Electrical Characteristics
  3. Interfacing with MCU
  4. Calibration
  5. Code Example
  6. Real-World Applications
  7. Limitations

Working Principle

The ACS712 from Allegro MicroSystems is an integrated Hall-effect current sensor. A low-resistance copper conduction path runs through the IC package; current flowing through this path generates a magnetic field, which a linear Hall element detects. An on-chip amplifier outputs an analog voltage that is linearly proportional to current, centered at VCC/2 (2.5 V at 5 V supply) for bidirectional measurement.

Electrical Characteristics

ACS712 Key Specifications

Parameter5A Variant20A Variant30A Variant
Sensitivity185 mV/A100 mV/A66 mV/A
Supply Voltage4.5–5.5 V DC
Zero-Current OutputVCC/2 (~2.5 V)
Bandwidth80 kHz
Internal Resistance1.2 mΩ1.2 mΩ1.2 mΩ
Isolation2.1 kV RMS (galvanic)
Total Output Error±1.5% (typical)

Interfacing with an MCU

The ACS712 breakout has 3 pins: VCC (5 V), GND, and OUT (analog voltage). Connect OUT to an ADC pin. For 3.3 V MCUs, use a voltage divider (e.g., 10 kΩ + 6.8 kΩ) to scale the 0–5 V output to 0–3.3 V range, or use an op-amp buffer.

Calibration

At zero current, the output should be exactly VCC/2 (2.500 V). In practice, offset varies ±25 mV unit-to-unit. Calibrate by reading the ADC with no load and storing the offset value. For AC current measurement, sample at ≥10× the AC frequency and compute RMS from the sample set.

Code Example

// ACS712 (5A) current sensor — DC measurement on Arduino
#include <Arduino.h>

#define ACS_PIN     A0
#define SENSITIVITY 0.185  // V/A for 5A variant
#define V_REF       5.0
#define ADC_STEPS   1023.0
#define SAMPLES     200

float zero_offset = 2.5;  // Calibrated at startup

void setup() {
    Serial.begin(115200);
    delay(1000);  // Let sensor stabilize

    // Calibrate zero point (NO current flowing!)
    float sum = 0;
    for (int i = 0; i < SAMPLES; i++) {
        sum += analogRead(ACS_PIN) * (V_REF / ADC_STEPS);
        delayMicroseconds(500);
    }
    zero_offset = sum / SAMPLES;
    Serial.print("Calibrated zero offset: ");
    Serial.println(zero_offset, 4);
}

void loop() {
    float sum = 0;
    for (int i = 0; i < SAMPLES; i++) {
        sum += analogRead(ACS_PIN) * (V_REF / ADC_STEPS);
        delayMicroseconds(500);
    }
    float voltage = sum / SAMPLES;
    float current = (voltage - zero_offset) / SENSITIVITY;

    Serial.print("V="); Serial.print(voltage, 3);
    Serial.print("V  I="); Serial.print(current, 3);
    Serial.println("A");
    delay(500);
}

Real-World Applications

Solar Panel Maximum Power Point Tracking

MPPT charge controllers use Hall-effect current sensors like the ACS712 to continuously monitor panel output current and voltage. By perturbing the operating point and measuring the resulting power change, the controller finds the maximum power point — extracting 20–30% more energy than simple PWM controllers.

Solar EnergyPower ElectronicsMPPT

Limitations

  • 5 V only: The ACS712 requires a 5 V supply; not natively compatible with 3.3 V MCUs without level shifting.
  • Noise floor: ~20 mV peak-to-peak noise limits accuracy below ~100 mA. Use oversampling and averaging.
  • Temperature drift: Sensitivity changes ~0.012%/°C. For precision, use the INA219 (digital, I2C) instead.
  • No AC RMS: Raw analog output is instantaneous; computing RMS for AC requires high-frequency sampling and math in firmware.