INA219 monitor/The numbers/07. Four ranges, one step
The numbers · 07 of 11

Four ranges, one step

The INA219 has four gain settings, which span ±40, ±80, ±160 and ±320 mV across the shunt: 0.4, 0.8, 1.6 and 3.2 A on this board. One count is 0.1 mA on all four. What the narrow ranges buy is a smaller zero error, and what they cost is the headroom above it.

Four ranges

Four ranges, one step
reads 1.20 A
Range
Real current1.20 A
Full scale
3.2 A
One count
0.1 mA
Zero error
± 2.00 mA
The reading follows. 1.20 A is inside the 3.2 A range, and the reading tracks it in steps of 0.1 mA. A narrower range does not make a count smaller, it is 0.1 mA at every setting; what it shrinks is the zero error, ± 1 mA at /1 against ± 2 mA at /8.

The chip's gain setting, called the PGA, picks how many millivolts across the shunt count as full scale. Across 100 mΩ each one becomes a current:

SettingShunt rangeCurrent rangeZero error, maximum
/1±40 mV±0.4 A±1 mA
/2±80 mV±0.8 A±1.25 mA
/4±160 mV±1.6 A±1.5 mA
/8±320 mV±3.2 A±2 mA

/8 is what the chip starts in, and what the Adafruit library's default uses.

The step does not change

It is natural to expect a narrow range to measure in smaller steps. It does not. The shunt register counts in 10 µV at every setting, which on this board is 0.1 mA whether the range is 0.4 A or 3.2 A.

What does change is the zero error: how far from zero the chip may read with no current at all. TI's maximum is 100 µV at /1 and twice that at /8, so the narrow range halves the error that matters most at small currents.

Above the range

Above full scale the reading stops. A load drawing 600 mA reads 400 mA on the narrowest setting, and the reading does not move however much more it draws. A reading sitting exactly at full scale is the only sign, which is what makes it easy to miss.

So pick the widest range the load could reach, including the moment it starts, and only narrow it for a load you know stays small.

The three calls in the library

CallRangeBus rangeOne count of current
setCalibration_32V_2A()3.2 A32 V0.1 mA
setCalibration_32V_1A()about 1.3 A32 V0.04 mA
setCalibration_16V_400mA()0.4 A16 V0.05 mA

Only the last one uses the narrow range, and it also drops the bus range to 16 V. The middle one keeps /8, so its zero error is the widest setting's.

For the narrow range on a rail above 16 V, write the config register after the library's calibration: 32 V bus range, /1, 12-bit, both measured continuously.

ina.setCalibration_32V_2A();          // 0.1 mA a count
Wire.beginTransmission(0x40);
Wire.write(0x00);                     // config register
Wire.write(0x21);                     // 32 V, gain /1
Wire.write(0x9F);                     // 12-bit, continuous
Wire.endTransmission();               // now +-0.4 A

When it does not work

The current stops at a round number and will not go higher.

The reading has reached the top of the range it is set to, and above that it pins. On setCalibration_16V_400mA that is 400 mA; on setCalibration_32V_1A it is about 1.3 A, where the current register runs out. Use setCalibration_32V_2A, the default, which reaches 3.2 A.

I chose the 400 mA calibration and my 24 V reading went wrong.

That call changes two things. As well as the narrow current range, it sets the bus voltage range to 16 V, so a rail above that cannot be read. For the narrow current range with the 32 V bus range, write the config register yourself, as the last section shows.

Does the 1 A calibration make the reading more precise?

It makes each count of the current register 40 µA instead of 100 µA, but the shunt voltage underneath is still measured in 10 µV steps, which is 0.1 mA here. The extra digits are arithmetic, not measurement, and the range drops to about 1.3 A.

Where this goes next

The error in a reading, in milliamps, and when it matters.

How far off a reading is

Edit this page — content/books/ina219/four-ranges.mdx

Community

Questions about this product

See what other owners have asked, and read their solutions.

Ask a question ↗

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.

Browse Modules and blocks on the forum