Two measured, two worked out
The INA219 measures two voltages: the millivolts across the shunt and the volts on the load side of it. Current and power are arithmetic on those two, using a resistance your sketch tells the chip about. Get that number wrong and the voltages stay perfect while the current is off by exactly the same ratio.
Two measurements
The chip has one converter and two things to point it at. The first is the voltage between its two inputs, which are the two ends of the shunt: the shunt voltage, in steps of 10 µV. The second is the voltage from the load side of the shunt down to ground: the bus voltage, in steps of 4 mV.
Those are the only two things it measures. Each has its own register, and both are right from the moment the chip powers up, with no setup at all.
Two sums
Current is the shunt voltage divided by the shunt's resistance. The chip does not know the resistance, so a sketch writes a number into its calibration register, worked out from the resistance and the size of one count. Until that is written, the current register reads zero.
Power is the bus voltage times the current, which the chip also works out for you. It inherits the current's calibration, so if the current is wrong the power is wrong by the same ratio.
With a 100 mΩ shunt and 0.1 mA a count, TI's formula gives a calibration of 0.04096 ÷ (0.0001 × 0.1), which is 4096. That is the number the Adafruit library's default calibration writes, and it is right for this board.
Why it matters which is which
When a reading looks wrong, the two measurements tell you where to look.
If the bus voltage agrees with a meter and the current does not, the wiring is fine and the number in the sketch is not. If the bus voltage is wrong as well, the fault is on the board or in the wires.
The supply is a little higher
The bus voltage is measured at LOAD +, after the shunt. That is what your load actually receives, and it is lower than the supply by the shunt's drop.
The sketch in The first reading adds the shunt voltage back on to show the supply's own voltage beside it.
When it does not work
The calibration register has not been written. The chip leaves its current and power registers at zero until it is told the shunt, and it forgets after every power cut. With the Adafruit library, begin() writes it; if you drive the registers yourself, write it in setup() every time.
That is the signature of a wrong shunt value: the chip divides the right millivolts by the wrong resistance. The Adafruit calibrations assume 0.1 Ω, which is what this board has. Code written for a board with a different shunt, or a calibration number copied from one, scales the current by the ratio of the two.
Because it is measured at LOAD +, after the shunt. At 1 A the shunt takes 100 mV, so a 5.00 V supply reads 4.90 V. That is the voltage your load actually gets. Add the shunt voltage back on for the supply's own voltage.
The gain setting: what the four ranges buy and what they cost.
Four ranges, one step →Edit this page — content/books/ina219/two-measured-two-worked-out.mdx
Questions about this product
See what other owners have asked, and read their solutions.
TK119 INA219 Current and Voltage Monitor
Loading discussions…
Discuss this article
Ask about this page. The answer stays here, on the page it belongs to, for whoever hits the same wall next.