For 90% of DC microcontroller projects, the INA219 I2C shunt sensor is the default pick due to its 12-bit ADC, built-in programmable gain amplifier (PGA), and direct digital output. For non-invasive AC mains monitoring, the SCT-013-030 split-core current transformer is the standard. If you are still using the analog ACS712 Hall-effect sensor for new 3.3V ESP32 designs, you are likely clipping your ADC and introducing unnecessary noise. This guide breaks down the exact physics, wiring, and raw-to-unit math to get accurate amp readings on your workbench.

The Physics: Hall-Effect vs. Shunt Sensing

Hall-effect sensors (like the ACS712 or ACS724) pass the load conductor over a silicon Hall element inside the IC. The current generates a proportional magnetic field, which the silicon converts into an analog voltage. This architecture provides galvanic isolation—the high-voltage load path is physically separated from the low-voltage logic pins—making it inherently safe for AC mains or high-voltage DC. However, Hall sensors suffer from temperature drift, require a stable VCC for their offset voltage, and are highly susceptible to external magnetic interference from nearby transformers or switching MOSFETs.

Shunt-based sensors (like the INA219 or INA226) measure the voltage drop across a precision milliohm resistor (e.g., 0.1Ω) using an internal differential amplifier and ADC. They share a common ground with the load, meaning there is no galvanic isolation, but they offer vastly superior DC accuracy, zero magnetic drift, and direct digital I2C output. Because the shunt resistor is physically in the current path, they introduce a tiny voltage drop to the load, which is negligible for most 12V/24V systems but must be accounted for in low-voltage, high-current logic rails.

Decision Tree: Which Current Sensor to Buy

Use this decision matrix to select the exact part number for your build. Do not default to the cheapest option; mismatched sensor types are the leading cause of blown microcontroller GPIO pins in power-monitoring projects.

Application Condition Recommended Sensor Specific Part / Module Output Type
DC, <26V, need high precision (Battery/Solar) Low-Side/High-Side Shunt Adafruit INA219 (Product 904) Digital (I2C)
DC, 26V to 60V, high precision (E-bike/48V Solar) High-Voltage Shunt INA226 Breakout Board Digital (I2C)
AC Mains (120V/240V), non-invasive Current Transformer (CT) SCT-013-030 (30A/1V output) Analog (AC Voltage)
DC, bidirectional, low budget, low precision Hall-Effect ACS724 (3.3V logic compatible) Analog (Ratiometric)
The Default Recommendation: Buy the INA219 for DC battery/solar monitoring, and the SCT-013-030 for home AC energy monitoring. Stop using the ACS712 for new designs; its strict 5V requirement and noisy analog output make it obsolete for 3.3V ESP32 logic without bulky voltage dividers.

Wiring and Pinout Reference

Correct wiring is critical. Shunt sensors must be placed in series with the load, while Hall sensors and CTs clamp around or pass through a single conductor. Below is the pinout and supply range reference for the three most common maker modules.

Module VCC / Supply Range Logic Level Load Connections Microcontroller Pins
INA219 3.0V to 5.5V 3.3V or 5V (matches VCC) Vin+ to Power, Vin- to Load SCL, SDA, GND
ACS724 3.0V to 5.5V Ratiometric to VCC IP+ to Power, IP- to Load OUT to ADC, GND
SCT-013-030 N/A (Passive) N/A Clamp around ONE AC wire (Line OR Neutral, never both) Tip to ADC, Sleeve to GND/Bias

Note on the SCT-013-030: Unlike the SCT-013-000 (which requires you to add an external burden resistor), the -030 variant has an internal 62Ω burden resistor and outputs 0-1V AC. However, because microcontroller ADCs cannot read negative voltages, you must bias the signal to VCC/2 using a voltage divider (two 10kΩ resistors) before feeding it to the ESP32 or Arduino analog pin.

Output Signal Math: Raw ADC to Amps

A sensor is useless if you cannot convert the raw output into physical units. Here is the exact math and scaling required for each sensor type.

1. INA219 (Digital Shunt)

The INA219 handles the math internally. The TI INA219 datasheet specifies a shunt voltage register and a current register. Using the standard Adafruit library, scaling is abstracted, but under the hood, the chip calculates current using Ohm's Law:

I = V_shunt / R_shunt

The default Adafruit module uses a 0.1Ω shunt. If you modify the board to use a 0.01Ω shunt for higher current ranges (up to 32A), you must update the calibration register in your code:

// Adafruit_INA219 library calibration for custom shunt
ina219.setCalibration_32V_1A(); // Base calibration
// Override shunt resistance if you soldered a custom 0.01 ohm resistor
float shuntResistance = 0.01; 
float maxExpectedCurrent = 10.0; // Amps
ina219.setCalibration(shuntResistance, maxExpectedCurrent);

2. ACS724 (Analog Hall-Effect)

The ACS724 outputs a ratiometric analog voltage. At zero current, the output sits at VCC / 2. The sensitivity for the 10A bidirectional version is typically 200 mV/A. If powering the sensor at 3.3V:

  • V_offset: 1.65V (3.3V / 2)
  • Sensitivity: 0.200 V/A

When using an ESP32, avoid the deprecated analogRead() which suffers from severe non-linearity. Use analogReadMilliVolts() available in ESP32 Arduino Core v2.x+ to get calibrated millivolt readings directly from the eFuse calibration data.

const int sensorPin = 34;
const float vOffset_mV = 1650.0; // Half of 3300mV
const float sensitivity_mV_per_A = 200.0;

void loop() {
  // Read average of 64 samples to reduce noise
  long sum = 0;
  for(int i = 0; i < 64; i++) {
    sum += analogReadMilliVolts(sensorPin);
  }
  float vOut_mV = sum / 64.0;
  
  // Raw to Unit Math
  float current_A = (vOut_mV - vOffset_mV) / sensitivity_mV_per_A;
  Serial.printf("Current: %.2f A\n", current_A);
  delay(100);
}

3. SCT-013-030 (AC Current Transformer)

Because this outputs AC, you must calculate the Root Mean Square (RMS) current. You cannot just read the peak voltage. Furthermore, you must subtract the DC bias voltage you added during wiring. According to OpenEnergyMonitor's CT interfacing guide, the algorithm requires sampling the wave over at least one full AC cycle (20ms for 50Hz, 16.6ms for 60Hz), squaring the samples, averaging them, and taking the square root.

For the SCT-013-030, the internal burden resistor and turns ratio yield a direct 1V output at 30A. Therefore, the scaling factor is simply 30.0 A / 1.0 V. If your biased ADC reads a peak-to-peak swing of 0.5V (after subtracting the 1.65V bias), the RMS voltage is 0.5 / (2 * sqrt(2)) = 0.176V. Multiply by 30 to get 5.28 Amps.

Interference, Noise, and Calibration Fixes

Current sensing is notoriously noisy. If your readings are jumping by ±0.5A at idle, you are experiencing one of the following interference modes.

Hall-Effect Magnetic Interference

Hall sensors like the ACS712/ACS724 will pick up magnetic flux from nearby step-down transformers, inductors, and even the Earth's magnetic field if the IC is rotated. The Fix: Keep the sensor at least 2 inches away from buck converters and relay coils. If you must mount it nearby, apply a mu-metal shield over the IC, or implement a software low-pass filter averaging 100+ samples. Never use a Hall sensor to measure micro-amp standby currents; the noise floor (typically 20-50mA) will swallow the signal.

Shunt Common-Mode Voltage Violations

The INA219 has a maximum common-mode voltage rating of 26V. If you place the shunt on the high-side of a 48V solar array, the voltage at the Vin+ and Vin- pins will exceed the silicon's breakdown voltage, instantly destroying the I2C bus and potentially backfeeding 48V into your ESP32's 3.3V regulator. The Fix: For systems above 26V, you must use the INA226 (rated to 36V) or the INA228 (rated to 85V). Alternatively, move the INA219 to the low-side (between the load and ground), though this breaks the ground reference for the load and can cause erratic behavior in sensitive analog circuits.

ADC Ground Loops and ESP32 Non-Linearity

When measuring high-current DC loads, the ground wire carrying the return current will experience a voltage drop (V = I * R_wire). If your ESP32 shares this same ground path back to the power supply, the microcontroller's ground reference will bounce relative to the sensor's ground, injecting massive errors into analog readings. The Fix: Use a star-ground topology. Run a dedicated, thick-gauge ground wire from the power supply negative terminal directly to the load, and a separate, thin ground wire from the power supply directly to the ESP32 and sensor logic grounds. For analog sensors on the ESP32, always use the analogReadMilliVolts() function to bypass the chip's notorious ADC non-linearity curve below 0.1V.

Safety Caveat for AC Mains: When using split-core CTs like the SCT-013 on 120V/240V panels, never open the CT clamp while it is wrapped around a live, current-carrying wire. An open-circuited CT under load acts as a step-up transformer and can generate lethal high-voltage spikes across the secondary terminals. Always power down the circuit or short the CT leads before removing the clamp from the conductor.