ACS712 Current Sensor Module

ACS712 5A Current Sensor Module
Hall-Effect Based AC/DC Current Measurement for Arduino Projects
Introduction
The ACS712 is a hall-effect based current sensor that can measure both AC and DC currents up to ±5A. It provides analog output proportional to the measured current, making it ideal for energy monitoring, motor control, and over-current protection applications.
Key Features
Bidirectional
Measures both AC and DC currents
Easy Interface
Analog output (66mV/A sensitivity)
Isolated
2.1kV RMS voltage isolation
Low Noise
80mA output noise typical
Technical Specifications
Current Range | ±5A |
---|---|
Sensitivity | 185-190mV/A (typical) |
Zero Current Output | VCC/2 (2.5V at 5V supply) |
Operating Voltage | 4.5V – 5.5V DC |
Bandwidth | 80kHz |
Isolation Voltage | 2.1kV RMS |
Accuracy | ±1.5% at 25°C |
Dimensions | 31mm × 13mm × 10mm |
Pin Configuration
Pin | Function | Arduino Connection |
---|---|---|
VCC | Power Supply (5V) | 5V |
GND | Ground | GND |
OUT | Analog Output | A0 |
IP+ | Current Input + | Load positive |
IP- | Current Input – | Load negative |
Warning: Do not exceed 5A current or connect directly to mains voltage
Wiring Diagram
1 2 3 4 5 6 |
// Basic Connections: // VCC → 5V // GND → GND // OUT → A0 // IP+ → Load positive // IP- → Load negative |
Basic Current Measurement
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
const int sensorPin = A0; const float mVperAmp = 185.0; // Sensitivity for 5A model const float vRef = 5.0; // Arduino reference voltage const int adcResolution = 1023; // 10-bit ADC void setup() { Serial.begin(9600); } void loop() { float voltage = (analogRead(sensorPin) * vRef) / adcResolution; float zeroVoltage = vRef / 2; // 2.5V at no current float current = (voltage - zeroVoltage) * 1000 / mVperAmp; Serial.print("Voltage: "); Serial.print(voltage, 3); Serial.print("V\tCurrent: "); Serial.print(current, 2); Serial.println("A"); delay(1000); } |
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 |
const int samples = 200; float offset = 2.5; // Zero current voltage (VCC/2) void setup() { Serial.begin(9600); // Calibrate zero offset float sum = 0; for(int i=0; i<samples; i++) { sum += analogRead(A0); delay(1); } offset = (sum / samples) * (5.0 / 1023.0); } void loop() { float maxI = 0, minI = 0; for(int i=0; i<samples; i++) { float voltage = (analogRead(A0) * 5.0) / 1023.0; float current = (voltage - offset) * 1000 / 185.0; if(current > maxI) maxI = current; if(current < minI) minI = current; delay(1); } float peakToPeak = maxI - minI; float rmsCurrent = peakToPeak / (2 * sqrt(2)); Serial.print("RMS Current: "); Serial.print(rmsCurrent, 2); Serial.println("A"); } |
Advanced Features
Current Threshold Alert
1 2 3 4 5 6 7 8 9 |
void checkOverCurrent() { float current = getCurrent(); if(current > 4.0) { // 4A threshold digitalWrite(13, HIGH); // Alert LED Serial.println("OVER CURRENT!"); } else { digitalWrite(13, LOW); } } |
Power Calculation
1 2 3 4 |
float calculatePower(float voltageSupply) { float current = getCurrent(); return voltageSupply * current; } |
Moving Average Filter
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
#define FILTER_SIZE 10 float filterBuffer[FILTER_SIZE]; int filterIndex = 0; float filteredCurrent(float rawCurrent) { filterBuffer[filterIndex] = rawCurrent; filterIndex = (filterIndex + 1) % FILTER_SIZE; float sum = 0; for(int i=0; i<FILTER_SIZE; i++) { sum += filterBuffer[i]; } return sum / FILTER_SIZE; } |
Troubleshooting
Zero Current Output Not 2.5V
- Check power supply voltage (must be 5V)
- Allow sensor to warm up for 5 minutes
- Calibrate zero offset in software
Noisy Readings
- Add 0.1μF capacitor between VCC and GND
- Implement software filtering (moving average)
- Keep wires short and away from noise sources
Incorrect Current Values
- Verify sensitivity value (185mV/A for 5A model)
- Check load connections (current must flow through IP+ to IP-)
- Ensure proper ground connections