Project Overview
Arduino Nano + ACS712 current sensor: In this project, you will wire an ACS712 Hall-effect current sensor module to an Arduino and measure AC or DC current up to 30A using the Arduino ADC.
The ACS712 measures current by sensing the magnetic field around the current-carrying conductor and outputs a proportional analog voltage centered around 2.5V at 0A, which an Arduino can read directly. It is available in 5A / 20A / 30A variants, and it is a common choice when you want AC and DC current measurement with galvanic isolation from the measured line.
- Time: 30 to 60 minutes
- Skill level: Beginner to Intermediate
- What you will build: An Arduino sketch that reads ACS712 voltage, calibrates the zero offset, and reports DC current or AC RMS current.
Parts List
From ShillehTek
- Arduino Nano V3.0 - reads the ACS712 analog output via the ADC.
- ESP32 WROOM Dev Board - optional if you want WiFi logging later (the wiring and concept still apply).
- WCS1700 Current Sensor - a higher-current Hall-effect alternative (up to 70A).
- INA219 Sensor - a precise I2C shunt-based alternative for DC current measurement.
- LCD1602 Display - optional for live readouts without the Serial Monitor.
External
- ACS712 module (5A, 20A, or 30A variant) - the current sensor module used in this guide.
- DC or AC load (motor, heater, lamp) - something to draw measurable current.
- Multimeter - used to validate readings and help with calibration.
- Jumper wires and a breadboard (optional) - for easier prototyping.
Note: The ACS712 variant matters. ACS712-05B sensitivity is 0.185 V/A, the 20A variant is 0.100 V/A, and the 30A variant is 0.066 V/A. Also, treat mains/high-current wiring as hazardous: use proper enclosures and fusing, and double-check wiring before powering anything.
Step-by-Step Guide
Step 1 - Choose the right current sensor (ACS712 vs INA219 vs WCS1700)
Goal: Pick the correct sensor type for your use case (AC vs DC, precision vs current range).
What to do: Use these quick differences to choose:
- ACS712 (5A / 20A / 30A): Hall effect, measures AC and DC, analog output, galvanically isolated.
- WCS1700: Hall effect, up to 70A, hole-through design for heavier cables.
- INA219: shunt-based, DC only (or full-wave rectified AC), I2C output, higher precision (down to about mA resolution).
Pick ACS712 for typical hobby AC/DC monitoring up to 30A. Pick INA219 when you need precision DC current in the mA range. Pick WCS1700 for higher-current battery packs and similar projects.
Expected result: You confirm the sensor and variant you are using and note the correct sensitivity constant for your code.
Step 2 - Wire the ACS712 module to the Arduino
Goal: Connect the sensor's signal pins to the Arduino and place the screw terminals inline with your load.
What to do: Wire the 3-pin header for power and signal, then route the load current through the ACS712 screw terminals.
Wiring map:
ACS712 module Arduino Nano
VCC -> 5V
GND -> GND
OUT -> A0
Load wiring:
Power source (+) -> ACS712 IN1
ACS712 IN2 -> Load (+)
Power source (-) -> Load (-)
The current-carrying screw terminals go inline with your load; the 3-pin header is the analog signal side.
Safety note: The sensor is designed for galvanic isolation, but wiring mistakes can still create dangerous situations. Use proper fusing and an enclosure for anything above low current levels, and do not let mains wiring touch your Arduino circuitry.
Expected result: The module powers from 5V/GND, and OUT is connected to A0 with the load current routed through IN1/IN2.
Step 3 - Read DC current in Arduino
Goal: Convert the analog reading to voltage, then to current using your module's sensitivity and a calibrated zero offset.
What to do: Start with a basic sketch that prints current to the Serial Monitor. Use the sensitivity constant that matches your ACS712 variant.
Code:
const int SENSOR = A0;
const float SENSITIVITY_5A = 0.185; // V per Amp for ACS712-05B
// 20A variant = 0.100, 30A variant = 0.066
float zeroOffset = 2.5; // will calibrate later
void setup() { Serial.begin(9600); }
void loop() {
int raw = analogRead(SENSOR);
float voltage = raw * 5.0 / 1023.0;
float current = (voltage - zeroOffset) / SENSITIVITY_5A;
Serial.print(current, 3);
Serial.println(" A");
delay(500);
}
Important: If you use a 20A or 30A ACS712, update the sensitivity constant to match your part number, or the current reading will be wrong.
Expected result: The Serial Monitor prints a current value in amps that changes as your DC load changes.
Step 4 - Calibrate the zero-point offset (0A level)
Goal: Measure the true no-load sensor output voltage so the current reads near zero when no current is flowing.
What to do: With no current through the sensor, the output should be near 2.5V, but real modules and ADCs vary (for example 2.45V or 2.53V). Calibrate like this:
- Disconnect the load side so there is no current through the sensor terminals.
- Print the raw voltage using:
voltage = raw * 5.0 / 1023.0; - Take the average over 100 samples.
- Update
zeroOffsetto that averaged voltage.
Expected result: After calibration, no-load current should read very close to 0A (typically under about 5 mA in this guide's setup).
Step 5 - Read AC current using RMS sampling
Goal: Compute RMS current for AC loads by sampling many points of the waveform and calculating the RMS value.
What to do: The ACS712 output for AC is a sine-like waveform centered around the calibrated zero offset. Use an RMS calculation over a time window that covers at least one full mains cycle.
Code:
float readAcRms(int pin, unsigned long window_ms = 200) {
unsigned long start = millis();
double sumsq = 0;
int n = 0;
while (millis() - start < window_ms) {
int raw = analogRead(pin);
float v = raw * 5.0 / 1023.0 - zeroOffset;
float i = v / SENSITIVITY_5A;
sumsq += i * i;
n++;
}
return sqrt(sumsq / n);
}
Sample for at least one full mains cycle (20 ms for 50 Hz, 16.7 ms for 60 Hz). A 200 ms window gives 10+ cycles of averaging for smoother readings.
If readings are noisy, you can average more samples in software. A common hardware approach is adding a 10 ยตF capacitor between OUT and GND.
Expected result: Your AC load produces a stable RMS current value that is more meaningful than instantaneous samples.
Step 6 - Apply the readings to real projects
Goal: Understand practical ways to use the current measurement in your builds.
What to do: Use the measured current as an input signal for monitoring and automation, for example:
- Power monitoring: measure load current and log usage over time.
- Motor stall detection: a spike in current can indicate a stalled motor; cut power via a relay to protect hardware.
- Appliance state sensing: if current is above a threshold (for example > 500 mA), treat the appliance as "running."
- Battery monitoring: track DC current into/out of a battery bank to estimate charge/discharge behavior.
- Heater duty cycle monitoring: observe ON/OFF cycling to spot abnormal behavior.
- EV charging monitor: pair with a WiFi-capable board to publish a simple dashboard.
Expected result: You can map current readings to meaningful states, alerts, or logs in your project.
Conclusion
You wired an ACS712 to an Arduino, calibrated the 0A offset, and computed both DC current and AC RMS current from the module's analog output. This makes the ACS712 a practical choice for power monitoring, motor state detection, and appliance sensing without directly tapping into the measured line electrically.
Want the exact parts used in this build? Grab them from ShillehTek.com. If you want help customizing this project or building something for your product, check out our IoT consulting services.
Credit: This guide was inspired by "Simplified Arduino AC Current Measurement Using ACS712 Hall Effect Sensor" on Instructables.




Top comments (0)