The Core Question: What Sensors Actually Measure Current?
When builders ask what sensors to use for tracking power consumption or monitoring motor loads, the answer always narrows down to two distinct physical principles: the Hall effect and the shunt resistor. The ACS712 (specifically the ACS712-20A variant) relies on the Hall effect. It routes your load current through an internal copper conductor that generates a magnetic field proportional to the current. A Hall element inside the chip detects this field and outputs an analog voltage. Because the current path is physically isolated from the sensor's logic circuitry, it provides galvanic isolation, making it a popular choice for higher-voltage or noisy environments where you don't want your microcontroller's ground tied directly to the load.
On the other side of the workbench sits the shunt-based monitor, with the INA219 being the undisputed king of hobbyist I2C current sensing. Instead of magnetic fields, the INA219 measures the tiny voltage drop across a precision shunt resistor (typically 0.1Ω on breakout boards) placed in series with your load. An internal programmable gain amplifier (PGA) and analog-to-digital converter (ADC) digitize this drop, calculate the current using Ohm's law, and hand the result to your microcontroller over I2C. This digital approach eliminates the analog noise floor, offering vastly superior resolution for low-current DC measurements.
Hardware Specs and Wiring Pinouts
Before you solder headers, you need to match the sensor to your microcontroller's logic levels and power budget. The table below breaks down the exact supply requirements and pin mappings for both modules when interfacing with a standard 5V Arduino Uno or a 3.3V ESP32.
| Specification | ACS712-20A Module | INA219 Breakout Board |
|---|---|---|
| Sensing Type | Hall Effect (Analog) | Shunt Resistor (Digital I2C) |
| Module Supply Range | 4.5V to 5.5V (Strictly 5V for rated accuracy) | 3.0V to 5.5V (Safe for 3.3V ESP32 logic) |
| Load Voltage Limit | 2.1 kV RMS (Galvanic isolation) | 26V DC maximum (Common-mode limit) |
| Measurement Range | -20A to +20A | 0A to +3.2A (with standard 0.1Ω shunt) |
| Output Type | Analog Voltage (Ratiometric to VCC) | Digital (I2C Registers) |
| Wiring Pins | VCC, GND, OUT | VCC, GND, SCL, SDA, A0/A1 (Address) |
The INA219 must be wired on the high side (between the positive supply and the load). The IN- pin connects to your power supply positive, and the IN+ pin connects to the load's positive terminal. If you wire it on the low side (near ground), the common-mode voltage will drop near zero, but you risk ground loop errors and the INA219's internal ADC may saturate or read inaccurately due to how the shunt voltage is referenced to the chip's GND pin.
Translating Raw Data: The Output Signal Math
The most common point of failure in embedded current sensing isn't the wiring; it's the math. Analog and digital outputs require entirely different scaling approaches. Let's break down the raw-to-unit conversion for both.
ACS712: Analog Voltage to Amperes
The ACS712-20A has a sensitivity of 100 mV/A. Because it measures bidirectional current, the zero-current resting state is exactly half of the supply voltage (2.5V assuming a 5.0V VCC). The output is an analog voltage that you read via the microcontroller's ADC.
For a 10-bit ADC (like on the Arduino Uno) with a 5.0V reference, the analogRead() function returns a value between 0 and 1023. Here is the exact C++ math to convert that raw integer into Amperes:
const float V_REF = 5.0;
const float SENSITIVITY = 0.1; // 100mV/A for the 20A model
const float ZERO_OFFSET = 2.5; // VCC / 2
int rawADC = analogRead(A0);
float voltage = (rawADC * V_REF) / 1024.0;
float current_A = (voltage - ZERO_OFFSET) / SENSITIVITY;
Note on Scaling: Because the ACS712 output is ratiometric, any noise or droop on your Arduino's 5V rail directly corrupts your reading. If your USB voltage sags to 4.8V, your zero-offset is no longer 2.5V, it's 2.4V, introducing a 1A phantom error. Always measure your actual VCC with a multimeter and hardcode that exact value into V_REF and ZERO_OFFSET.
INA219: I2C Registers to Milliamperes
The INA219 handles the analog-to-digital conversion internally. You don't read a raw voltage; you read a 16-bit signed integer from the Current Register (Address 0x04) via I2C. The Adafruit INA219 library abstracts this, but understanding the underlying physics is critical for calibration.
The chip calculates current based on the shunt resistor value. On standard breakout boards, this is a 0.1Ω surface-mount resistor. The internal PGA is typically set to a gain of /8, meaning the maximum shunt voltage it can read before clipping is 320mV. Using Ohm's Law (I = V/R), a 320mV drop across a 0.1Ω shunt equals 3.2A maximum.
#include
Adafruit_INA219 ina219;
void setup() {
ina219.begin();
// Calibrate for the specific shunt and max expected current
ina219.setCalibration_16V_400mA(); // Use this if max load is < 400mA for higher resolution
}
void loop() {
float shuntvoltage = ina219.getShuntVoltage_mV(); // Raw physics measurement
float current_mA = ina219.getCurrent_mA(); // Calculated by library
}
If you are building a custom PCB with a different shunt (say, 0.01Ω for a 32A range), you must recalculate the calibration register value using the formula provided in the Texas Instruments INA219 datasheet, otherwise the library's getCurrent_mA() output will be scaled incorrectly.
Real-World Interference and Calibration Gotchas
Datasheets assume perfect conditions. On a crowded breadboard or inside a motor-control enclosure, interference will wreck your readings if you aren't prepared.
- Magnetic Cross-Talk (ACS712): Hall effect sensors are inherently magnetic antennas. If you mount an ACS712 within two inches of a stepper motor, a relay coil, or a transformer, the external magnetic fields will induce a false current reading. I once saw a 3A phantom spike on an ACS712 every time a nearby 12V relay clicked. Fix: Keep Hall sensors at least 5cm away from inductive components, or switch to the INA219 for dense boards.
- Thermal Drift (INA219): Shunt resistors heat up under load. A standard 1% tolerance 0.1Ω shunt has a temperature coefficient (tempco) of around 100 ppm/°C. If you push 2A continuously through the INA219 breakout, the shunt dissipates 0.4W (I²R). It will get hot, its resistance will climb, and your current readings will artificially inflate by 1-2% over ten minutes. Fix: For continuous loads above 1.5A, solder a beefier external shunt (like a 5W 0.01Ω Kelvin resistor) across the INA219's input pads and recalibrate in software.
- ADC Noise Floor (ACS712): The ACS712 has a noise bandwidth of 80 kHz. If you sample it with an Arduino without a low-pass filter, you will see ±0.2A of jitter on the serial monitor. Fix: Add a simple RC low-pass filter (e.g., 1kΩ resistor in series with the OUT pin, and a 100nF ceramic capacitor to GND) to cut the noise bandwidth down to ~1.5 kHz, then average 20 samples in your code.
FAQ: Answering the Long-Tail "What Sensors" Questions
What sensors to use for measuring AC mains current safely?
Never use a standard ACS712 module for direct AC mains (120V/240V) measurement unless it is housed in a fully insulated, UL-rated enclosure with proper strain relief—the exposed screw terminals on cheap breakout boards are a severe shock and fire hazard. For AC mains, use a split-core Current Transformer (CT) like the SCT-013-030. It clamps around the insulated hot wire, providing total galvanic isolation and outputting a safe, low-voltage AC signal that you can bias to 2.5V and read with an Arduino using the EmonLib library. Alternatively, look at isolated I2C monitors like the ADE9000, but CT clamps remain the safest and most practical choice for DIY home energy monitors.
What sensors work best for microamp sleep current on battery projects?
Neither the ACS712 nor the standard INA219 will work here. The ACS712's noise floor is hundreds of milliamps, and the INA219's 0.1Ω shunt drops too much voltage at microamp levels, potentially browning out your sleeping ESP32. For sleep current profiling (typically 10µA to 500µA), you need a specialized high-side monitor with a larger shunt and higher PGA gain, such as the INA226 paired with a 1Ω or 10Ω shunt, or dedicated power profilers like the Nordic PPK2 or the Otii Arc. If you are strictly budget-constrained, you can measure the voltage drop across a 10Ω resistor using a high-resolution external ADC (like the 24-bit ADS1115), but you must account for the 10Ω voltage drop in your battery supply calculations.
What sensors to choose when measuring bidirectional motor current?
If you are driving a DC motor with an H-bridge (like the L298N or DRV8871) and need to measure current flowing in both directions to detect stalling or regenerative braking, the ACS712 is the easiest analog choice because its 2.5V zero-point naturally handles positive and negative swings. However, for higher precision, the INA219 (and its higher-voltage sibling, the INA226) natively supports bidirectional measurement. The INA219's current register is a signed 16-bit integer; when current reverses, the shunt voltage polarity flips, and the register simply returns a negative value. Just ensure your motor's back-EMF voltage spikes don't exceed the INA219's 26V common-mode limit, or you will fry the I2C bus.






