The INA219 datasheet provides an example calibration workflow, but doesn’t really explain how some of the equations and constant values are derived. This article tries to fill in some of the gaps that weren’t obvious to me when I first read the datasheet.
Overview
“The INA219 is a highside current shunt and power monitor with an I2C interface. The INA219 monitors both shunt drop and supply voltage, with programmable conversion times and filtering. A programmable calibration value, combined with an internal multiplier, enables direct readouts in amperes. An additional multiplying register calculates power in watts. The I2C interface features 16 programmable addresses.”
The INA219 calculates the current flowing through the “Current Shunt” sense resistor by first measuring the voltage across the resistor, and then applying Ohm’s law,
Bus voltage is measured directly on the load side of the shunt resistor ().
Power is then calculated by multiplying these two sampled values,
Shunt and Bus Voltage Measurements
When measuring the shunt voltage, the internal ADC converts the analog voltage into a digital value which is stored in binary representation in the Shunt Voltage Register. The INA219 uses a 12bit ADC, meaning it can resolve the analog voltage into (4096) discrete digital values. The ADC can measure voltages in the range of ±40mV (± for bidirectional current measurement). In order to extend this range, the INA219 has a PGA in front of the ADC that can be configured to divide the input voltage by a factor of 1, 2, 4, or 8. This gives the INA219 an effective range of ±40mV, ±80mV, ±160mV, or ±320mV respectively.
The Shunt Voltage Register is a signed 16bit register, so you may be wondering how the 12bit ADC can generate 16 bits of information? It turns out that the INA219 can be configured to average 2128 samples to generate an average shunt voltage measurement. This averaging operation can provide additional resolution in the lowest 1, 2, or 3 bits when the shunt voltage range is set for ±80mV, ±160mV, or ±320mV respectively.
Similarly, the ADC converts the analog bus voltage () into a digital value and stores the result in the Bus Voltage Register. The fullscale BRNG can be selected between 16V and 32V (default), and there are 13 bits in the Bus Voltage Register that can be used for storing the bus voltage value. When using the 32V BRNG setting, the bus voltage is divided by 2 in the PGA before being sampled by the ADC. In this mode, the lowest bit may provide additional resolution if averaging is enabled.
The LSB step size specified in the data sheet can be verified as follows,
The raw values in the voltage registers can be converted to real voltage values by multiplying by the LSB step size,
This is generally applicable to all measurement registers in the INA219. The real world quantities that are represented by the register values can be obtained by simply multiplying the register value by the LSB step size,
Calibrating the INA219
Since the device cannot detect the value of , the Calibration Register is used to inform the power measurement engine about the shunt resistance value. However, instead of specifying the value of directly, for the same value, the Calibration Register can be programmed differently depending on the type of result that is desired in the Current and Power Registers. From the datasheet,
“The Calibration Register can also be selected to provide values in the Current and Power Registers that either provide direct decimal equivalents of the values being measured, or yield a round LSB number.”
The power management engine calculates the Current and Power Register values according to the following equations,
Therefore, the Calibration Register value is simply a systemdependent scaling factor that converts the shunt voltage into current.
Starting with the equation for the shunt current,
Ohm’s law can be used to rearrange the equation for the Current Register,
Substituting for ,
Setting both Current Register equations equal to each other, it’s possible to solve for the Calibration Register,
Programming the Calibration Register
The INA219 datasheet provides a couple examples of how to program the Calibration Register. This example follows the same procedure described in the datasheet, where general equations are , and followed by specific examples:

Determine the maximum bus voltage () for the system and configure BRNG based upon this value (16V or 32V):
(BRNG = 0)

Determine the maximum shunt voltage () for the system and configure PGA gain based upon this value (÷ 1, ÷ 2, ÷ 4, or ÷ 8):
(PGA = ÷ 1)

Determine the value of the shunt resistor ():

Based only on the values selected in the first three steps, calculate the maximum current that could possibly flow through the sense resistor:

Based on expected system performance, determine the actual expected maximum current where .
For this system, let’s assume that it’s expected to draw up to 1A of current,

The Current Register is 16 bits wide, but since the device can measure bidirectional current, the MSB is used to indicate the sign in two’s compliment representation. Therefore, the remaining 15 bits can be used to represent the entire current range. Since the ADC resolution is 12 bits, it is desirable to choose the Current Register resolution between 1215 bits, ideally as close to the 15bit resolution as possible.
Calculate the minimum current LSB (15bit resolution):
Calculate the maximum current LSB (12bit resolution):
Choose a current LSB value, where ^{1} ^{2}. From the data sheet,
“Note that the results will have the most resolution when the minimum LSB is selected. Typically, an LSB is selected to be the nearest round number to the minimum LSB value.”
Let’s choose .

Compute the Calibration Register value:

The digital designers of the INA219 designed the power management engine to calculate the Power Register value according to the following equation^{3},
Substituting for each register variable,
Simplify,
Cancel the terms and take the reciprocal to obtain the equation,
Calculate the power LSB:

Compute the maximum current before overflow:
Since ,

Compute the maximum shunt voltage before overflow:
Since ,

Compute the maximum power:

Optionally compute the corrected fullscale calibration based on measured current:
Revision History
Revision  Date  Description 

1  07/06/2014  Initial release 
2  08/19/2014  Fixes for Kramdown syntax 
3  11/01/2014  Minor clarifications and fixes 
Footnotes

If , then the Current Register cannot express the fullscale range required by the maximum expected current (due to the 15bit limitation). For example, if and , then , which will result in an overflow condition for any valid current in the range to . ↩

If , the Current Register resolution decreases below 12bits. For example, if and , the resolution decreases to 11bits . ↩

http://e2e.ti.com/cfsfile.ashx/__key/telligentevolutioncomponentsattachments/0014010000239546/power_5F00_LSB_5F00_INA219.pdf ↩