December 5, 2026

INA219 Current Sensor: Measuring Power, Calibrating the Registers, and Logging Without Missing the Spikes

A current sensor breakout wired between a battery and a small circuit

A battery-powered gadget idles at 100 milliamps and wakes for 10 milliseconds once a second to draw 900. Its true average is 108 mA. A data logger reading an INA219 current sensor once a second, exactly in step with that rhythm, can report 100 mA forever, or 900 mA forever, depending only on when it started. The INA219 itself is accurate; the way it gets read decides whether the numbers mean anything. Everything below comes from the Texas Instruments datasheet, the Adafruit breakout documentation and library source, and Python calculations that reproduce the chip’s register math and the sampling problem.

Video: Julian Ilett on YouTube

What the INA219 measures

Two voltages, one chip

The INA219 datasheet from Texas Instruments describes a chip that senses bus voltages from 0 to 26 V and the voltage across a small current-sense resistor, called a shunt, then reports the results over I2C. Current comes from Ohm’s law: the voltage across a known resistance gives the current through it. Power is the bus voltage times that current.

The chip does the multiplication itself. Read the right registers and it hands back current in amps and power in watts, once it has been calibrated.

The breakout most people use

Adafruit’s INA219 guide describes its board: a 0.1 Ω, 1 percent sense resistor, an amplifier input range of ±320 mV, and therefore a measuring range of ±3.2 amps. It can measure on the high side of a circuit up to +26 V while the chip itself runs from 3 or 5 V.

High side and why it matters

High-side sensing puts the shunt in the positive supply line, between the power source and the load. The load’s ground stays connected to the real ground, so nothing downstream sees its reference shift. Low-side sensing, with the shunt in the ground return, is simpler for some chips but lifts the load’s ground by the shunt’s voltage drop, which can confuse anything else that shares that ground.

A close-up of a circuit board

The numbers on the datasheet

Ranges and resolution

The datasheet’s figures:

Item Value
Bus voltage range 0 to 26 V
Shunt voltage ranges (PGA setting) ±40, ±80, ±160, ±320 mV
Shunt voltage register LSB 10 µV
Bus voltage register LSB 4 mV
ADC 12-bit (9, 10 or 11 also selectable)
Conversion time at 12-bit 532 µs
Averaging Up to 128 samples, 68.10 ms
I2C addresses 16 selectable

The programmable gain setting, PGA, chooses how large a shunt voltage the chip accepts. Adafruit’s guide states the resolution at the full ±3.2 A range as 0.8 mA.

Picking the range

A smaller range reads finer but saturates sooner. With the 0.1 Ω shunt, the ±40 mV setting tops out at 0.4 A. The emulation of the chip’s math showed what that means for a 1.5 A load: on the ±40 mV range the reading pinned at 0.4 A, a wrong answer with no error flag. Choosing the range for the largest current the circuit ever draws, including motor startup or a capacitor charging at power-on, matters more than squeezing out resolution.

Accuracy

The datasheet lists a maximum error of 0.5 percent at 25°C, widening to 1 percent across −25°C to 85°C for bus voltage. That is the chip’s own error. The shunt resistor’s tolerance, 1 percent on the Adafruit board, adds to it. For better current accuracy, a measured shunt value can be written into the calibration math in place of the nominal 0.1 Ω.

Calibration: making the registers read in amps

The formula

The INA219 doesn’t know what shunt is attached. A calibration register tells it. The datasheet describes the calculation using a fixed internal constant, 0.04096, and Adafruit’s library source spells out the formula in its comments:

Cal = trunc(0.04096 / (Current_LSB * RSHUNT))

Current_LSB is the value, in amps, that one count of the current register will represent. The datasheet adds that the power register’s LSB is fixed at 20 times the current LSB.

The worked example

Adafruit’s INA219 library uses these values in its 32 V, 2 A setup:

Setting Value
Current_LSB 0.0001 A (100 µA per count)
Calibration register 4096 (0x1000)
Power_LSB 0.002 W (2 mW per count)
Maximum before overflow 3.2767 A

The overflow limit follows from the register size. The current register is a signed 16-bit number, so its largest positive value is 32,767 counts, which at 100 µA per count is 3.2767 A.

Checking the arithmetic

The Python emulation fed a 0.25 A current through the 0.1 Ω shunt. The shunt register read 2,500 counts of 10 µV, which is 25 mV. With the calibration set to 4096, the current register came out at 2,500 counts, and 2,500 × 100 µA is 0.25 A. With that calibration, the current register and the shunt register read the same number, which makes it easy to spot a wrong setting: if they disagree, the calibration isn’t what the code thinks it is.

Adafruit’s source contains one more lesson. Its comments state the power LSB as 2 mW, while the code a few lines later sets a multiplier commented as 1 mW per bit. Library comments are documentation written by people, and they can drift from the code. The datasheet rule, 20 times the current LSB, settles it.

A multimeter sitting on top of a wooden floor

Logging: where the readings go wrong

The aliasing trap

Back to the gadget that idles at 100 mA and bursts to 900 mA for 10 ms every second. A Python model sampled it once a second for a minute, 200 times over with a random start time, two ways:

Sampling method True average Logged averages (range across 200 runs)
One 12-bit conversion (532 µs) per second 108 mA 100 mA to 900 mA
128-sample average (68.1 ms) per second 108 mA 100 mA to 220 mA

When the logging rate matches the load’s rhythm, every reading lands at the same point in the cycle. A run that starts during idle reads 100 mA for the entire minute. A run that starts during a burst reads 900 mA for the entire minute. Averaged over all 200 runs, the single-conversion results came out near the right answer, but any individual log was wrong by up to eight times.

Averaging helps, a little

The chip’s built-in averaging spreads each reading over 68 ms, so a burst inside that window gets partly counted. The error shrank, but a 10 ms burst once a second still falls outside the window most of the time. Averaging only fixes what it covers.

What works

  • Sample faster than the shortest event that matters, and average in software.
  • Avoid logging intervals that are a neat multiple of the load’s cycle; an odd interval such as 0.37 s walks through the cycle over time.
  • For battery-life estimates, log energy instead of instantaneous current: sum power × time between samples, so every reading counts for the time it represents.
  • When bursts matter, use the INA219’s continuous conversion mode and read at the conversion rate, or move to a sensor designed for fast power profiling.

Wiring and practical limits

Connections

The board sits in series with the load’s positive supply: power in on one side of the shunt, load on the other. The chip’s own supply and I2C lines connect to the microcontroller. Every INA219 needs the load’s ground and the microcontroller’s ground tied together, or the bus voltage reading floats.

The 16 selectable I2C addresses mean up to 16 sensors can share one bus, which is enough to monitor every rail of a small project on two wires.

The shunt costs voltage

The shunt is a resistor in the power path, so it drops voltage and makes heat. At 2 A through 0.1 Ω, the drop is 0.2 V and the shunt dissipates 0.4 W. A 3.3 V device fed through it sees 3.1 V. For high-current loads, a smaller shunt reduces the loss at the cost of resolution, and the calibration formula above adapts to any value.

What to buy

Breakout boards make the INA219 usable without surface-mount soldering. One option:

As an Amazon Associate I earn from qualifying purchases. A commission may be earned if you buy through this link, at no extra cost to you.

Generic INA219 modules use the same chip, often with the same shunt value, but checking the resistor marking before trusting the default calibration is worth the thirty seconds. A board with a different shunt and an unchanged calibration reports confidently wrong numbers. The chip measured exactly what was in front of it; the software just believed the wrong resistor.

Computer cables

Sources

  • INA219 datasheet, Texas Instruments: https://www.ti.com/lit/ds/symlink/ina219.pdf
  • Adafruit INA219 Current Sensor Breakout, Adafruit Learning System: https://learn.adafruit.com/adafruit-ina219-current-sensor-breakout
  • Adafruit_INA219 library source (Adafruit_INA219.cpp), GitHub: https://raw.githubusercontent.com/adafruit/Adafruit_INA219/master/Adafruit_INA219.cpp

755 Posts

Peter Kalafatis writes and edits X9M8. He holds a bachelor's degree from LIU Post and a master's in Media Studies from The New School, with academic work in the philosophy of science, human behavior, AI, and memetics.

View All Posts

Leave a Reply

Your email address will not be published. Required fields are marked *