INA219 DC Power Sensor
Updated: 24Aug2024 21:30:55 UTC 2024-08-24T21:30:55Z
Rating: (0 reviewsThis article has not been rated yet)
The INA219 ICIntegrated Circuit is a high-side current and voltage monitor chip using an external shunt resistor. It can measure voltage, current, and power consumption in an external circuit. This hardware overview of the INA219 IC and Modules covers specs, board layout, pinout, and operation.
INA219 IC
The INA219 ICIntegrated Circuit is a high-side current and voltage monitor chip with an I2CInter-Integrated Circuit. Also referred to as IIC or I2C. interface that operates from a single 3V to 5.5V DC supply. It has a Programmable Gain Amplifier (PGAA Programmable Gain Amplifier (PGA) is an electronic amplifier whose gain can be controlled by external digital or analog signals.) and 12-Bit ADCAnalog-to-Digital Converter (ADC, A/D, or A-to-D) for continuous or trigger operation. It also has programmable calibration, gain, filtering, and ADC resolution.
The INA219 measures the voltage, current, and power consumption of a circuit using an external shunt resistor. It can output the following measurements on an external load circuit:
- Bus Voltage [Volts]
- Shunt Voltage [Volts]
- Current [Amps]
- Power [Watts]
The load supply voltage can also be computed by summing the shunt and bus voltages: VLOAD = VSHUNT + VBUS. The INA219 measures bus voltage on the load side instead of load power supply according to the INA219 Datasheet (PDF). These voltages are shown in the figure below.
Inside the INA219 IC the PGA and ADC measures the differential voltage VIN = VIN+ - VIN- across an external shunt resistor. Using internal switching this device monitors both the shunt voltage drop and the bus voltage VBUS = VIN- - GND on an external load. In order to calculate the current and power values, the user must program the resolution of the Current Register and value of the shunt resistor.
Specs
Feature | Description |
---|---|
IC Info | INA219 High-Side Current/Power Monitor by Texas Instruments (TI) |
Voltage Supply (VS) | 3.0V to 5.5V single supply |
Interface |
I2C 2-Wire (SCL, SDA)
|
Analog Inputs Differential (VIN+ - VIN-) |
±26V |
Analog Inputs Common-Mode (VIN+ + VIN-)/2 |
-0.3V to 26V |
ADC Resolution | 12-Bit (15-Bit Averaging) |
Offset Voltage |
|
Offset Voltage Drift | 0.1μV/°C |
Max Shunt Voltage |
|
Operating Temperature | -40°C to 125°C |
PGA Gain & Range
The PGA configuration sets the gain and Full-Scale Range (FSR) of voltage across the shunt resistor. The PGA gain settings in the table below can be found in Table 4 of the INA219 Datasheet (PDF).
PGA Gain | FSR |
---|---|
1 | ±40mV |
1/2 | ±80mV |
1/4 | ±160mV |
1/8 | ±320mV |
Resolution & Sampling
The ADC resolution settings adjust the number of ADC bits or number of samples used when averaging results for the Bus Voltage Register and Shunt Voltage Register. Higher ADC resolution or sampling requires longer conversion times. The ADC resolution settings in the table below can be found in Table 5 of the INA219 Datasheet.
Bit/Samples | Conversion Time |
---|---|
9-Bit / 1 Sample | 84µs |
10-Bit / 1 Sample | 148µs |
11-Bit / 1 Sample | 276µs |
12-Bit / 1 Sample | 532µs |
12-Bit / 2 Samples | 1.06ms |
12-Bit / 4 Samples | 2.13ms |
12-Bit / 8 Samples | 4.26ms |
12-Bit / 16 Samples | 8.51ms |
12-Bit / 32 Samples | 17.02ms |
12-Bit / 64 Samples | 34.05ms |
12-Bit / 128 Samples | 68.10ms |
Registers
The INA219 has six 16-bit registers for Configuration, Shunt Voltage, Bus Voltage, Power, Current, and Calibration. You can read or write to the configuration and calibration registers.
The configuration register includes Reset, ADC resolution, gain, and bus range. The calibration register contains a scale factor used for adjusting the current resolution. The Shunt Voltage, Bus Voltage, Power, and Current registers are read-only the provide measured or calculated data.
Register | Hex Address |
Read/Write |
---|---|---|
Configuration | 0x00 | Read/Write |
Shunt Voltage | 0x01 | Read-Only |
Bus Voltage | 0x02 | Read-Only |
Power | 0x03 | Read-Only |
Current | 0x04 | Read-Only |
Calibration | 0x05 | Read/Write |
Chip Versions
The INA219 IC comes in a SOIC-8 (3.91mm x 4.90mm) or SOT-23 (1.63mm x 2.90mm) package. There are two versions of the INA219 chip: A and B. The A version has a ±1% total max current measurement error over the entire operating temperature range and the B version has a ±0.5% total max current measurement error over the entire operating temperature range, but the overall functionality is otherwise the same. The markings on the chip indicate whether its the A or B version.
INA219 Modules
Breakout board modules are available for INA219 that have pin through holes with 0.1" (2.54mm) spacing so you can easily attach it to a breadboard and 3.5mm terminal plug mount holes so you can easily connect your load.
Most INA219 modules have a 0.1Ω 1% shunt resistor that can measure up to 3.2A with ±0.8mA resolution. The module power supply can be in the range of 3V to 5.5V and the load supply voltage can be in the range of 0V to 26V DC.
There are two common INA219 modules: the Adafruit (PID 904) module and a generic module. Both modules have a 0.1Ω 1% shunt resistor that can measure up to 3.2A with ±0.8mA resolution. The Adafruit board has a small size of 25.6mm x 20.4mm (1.0in x 0.8in) and the generic boards usually have a size about 25.5mm x 22.3mm (1.0in x 0.9in). The main difference between these modules is the Adafruit module has STEMMA QTSTEMMA QT ('cutie') connectors are Adafruit's name for 4-pin JST SH connectors with 1.0mm pitch. These connectors were implemented on Adafruit boards to make it easy to plug-n-play various sensors and devices without soldering and wiring. The STEMMA QT (JST SH) are a smaller connector than the STEMMA (JST PH) that do not fit on smaller boards. STEMMA QT is cross-compatible with SparkFun Qwiic connectors. connectors for I2C and an onboard power LEDLight Emitting Diode.
Adafruit INA219 Module
The Adafruit board comes with a 6-pin header and a 3.5mm terminal plug for the load. On each side of the board are STEMMA QTSTEMMA QT ('cutie') connectors are Adafruit's name for 4-pin JST SH connectors with 1.0mm pitch. These connectors were implemented on Adafruit boards to make it easy to plug-n-play various sensors and devices without soldering and wiring. The STEMMA QT (JST SH) are a smaller connector than the STEMMA (JST PH) that do not fit on smaller boards. STEMMA QT is cross-compatible with SparkFun Qwiic connectors. connectors for supplying power VCC to the INA219 chip and the two I2C lines (SCLSerial Clock (SCL) is the output clock signal line from the master device. Also referred to as SCK, SCLK, or CLK. and SDASerial Data Line ).
On the back of the board are A0 and A1 solder jumpers that can be bridged with solder to change the I2C address to the list below.
- Default = 0x40
- A0 soldered = 0x41
- A1 soldered = 0x44
- A0 and A1 soldered = 0x45
There is also an LED jumper that can be cut to disable the board's power LED if you want to reduce power consumption.
Adafruit provides a tutorial on the board, including pinout, assembly, Arduino code, CircuitPython code, schematic, and PCB. They provide an Arduino Library and CircuitPython Library on GitHub for communicating with the device over I2C.
Generic INA219 Module
The Generic INA219 modules are similar to the Adafruit module, with the same functionality, except they do not include the STEMMA QT connectors for I2C and the onboard power LED. A couple other minor differences are the power pin is labeled VCC instead of VIN and the I2C solder jumpers are on the front of the board instead of the back of the board.
Basic Hookup
The INA219 module can be powered from 3V to 5V. If you're using a microcontroller board or SBCSingle Board Computer, they often have a 3.3V/5V output pin that you can connect to the INA219 VCC, where the device ground GND must be connected to the INA219 GND.
The two I2C communication lines (SCLSerial Clock (SCL) is the output clock signal line from the master device. Also referred to as SCK, SCLK, or CLK. and SDASerial Data Line) also needs to be connected between the INA219 and the device. The INA219 modules usually have built-in 10kΩ pull-up resistors to VCC on both I2C lines. Since I2C bus drivers are open drain drivers, they can drive drive their output low, but cannot drive it high. For the line to be able to go high there has to be pull-up resistors.
The current needs to be measured on the high-side, so the load power supply is connected directly to the INA219 VIN+ pin and the VIN- pin is connected to the load resistor and then to ground. There are two ways of connecting the load, either through the terminal holes using a 3.5mm screw terminal plug or by using the pin through holes (PTH).
Calibration
By default the INA219 has an ADC setting with 12-Bit resolution and 1 sample, a gain setting of 320mV shunt full-scale range (PGA = 1/8), and a 32V bus full-scale voltage range, using continuous conversion of shunt and bus voltage.
These default settings use the largest range of input voltage and current, but with the lowest resolution. If the maximum current and bus voltage are known, these default settings can be changed to improve the resolution of voltage and current readings.
First the current LSBThe Least Significant Bit (LSB) in a binary number is the bit that represents the smallest place value carrying the lowest weight. It is also sometimes referred to as the low-order bit or right-most bit due to the convention in positional notation of writing less significant digits further to the right. needs to be determined from the maximum expected currently. The current register has a value in the range ±215. It is common to select a value for the Current_LSB to the nearest round number above this value to simplify the conversion of the Current Register and Power Register to amps and watts respectively.
The calibration register is calculated based on the current LSB (Current_LSB) and shunt resistance (RSHUNT). The constant 0.04096 is an internal fixed value used to ensure scaling is maintained properly.
The table below gives examples of rounded Current_LSB and Cal values for different maximum expected currents.
Max Expected Current |
Current LSB | Current LSB (Rounded) |
Cal |
---|---|---|---|
400mA | 0.012mA | 0.2mA | 20480 |
800mA | 0.024mA | 0.04mA | 10240 |
1.6A | 0.049mA | 0.05mA | 8192 |
3.2A | 0.098mA | 0.1mA | 4096 |
When the calibration register is supplied with the Cal value, the current register can compute the current value internally from the Shunt_Voltage_Register using the equation below.
The gain can be determined from max expected current by finding the minimum full-scale voltage range (40mV, 80mV, 160mV, 320mV) that is above the max expected shunt voltage (VSHUNT(Max) = Max_Expected_Current∙RSHUNT). For example, if Max_Expected_Current is 1A, where RSHUNT = 0.1Ω, then the max expected shunt voltage is 1A∙0.1Ω = 100mA, the minimum full-scale range > 100mA is 160mV, and the gain is 1/4.
Max Expected Current |
Max Expected Shunt Voltage |
Shunt Voltage Range |
Gain |
---|---|---|---|
I < 400mA | V < 40mV | 40mV | 1 |
400mA ≤ I < 800mA | 40mV ≤ V < 80mV | 80mV | 1/2 |
800mA ≤ I < 1.6A | 80mV ≤ V < 160mV | 160mV | 1/4 |
1.6A ≤ I < 3.2A | 160mV ≤ V < 320mV | 320mV | 1/8 |
The bus voltage is measured from VIN- to ground (VBUS = VIN- - GND) on an external load and its full-scale range can be set to either 0V to 16V or 0V to 32V. Using the smaller 16V range can improve the resolution of the bus voltage readings and also the power readings, since the Power Register is internally computed from the product of the current register and bus voltage register.
- 0V to 16V Bus Range:
- The bus voltage range is set from 0V to 16V using the hex address 0x0000.
- 0V to 32V Bus Range:
- The bus voltage range is set from 0V to 32V using the hex address 0x2000.
Readings
The voltage, current, and power values read from the registers need to be converted to a meaningful format. The table below gives the conversion factors for the Current_Register, Shunt_Voltage_Register, Bus_Voltage_Register, and Power_Register.
Reading | Register Conversion |
---|---|
Bus Voltage [V] | (Bus_Voltage_Register << 3) x 4 / 1000 |
Shunt Voltage [mV] | Shunt_Voltage_Register / 100 |
Current [mA] | Current_Register x Current_LSB x 1000 |
Power [mW] | Power_Register x Power_LSB x 1000 |
- Bus Voltage [V]:
- The Bus Voltage Register has an address of 0x02 and is internally measured at the VIN- pin to calculate the voltage level delivered to the load. The Bus Voltage register bits are not right-aligned; therefore, they must be shifted right by 3 bits. Multiply the shifted contents by the 4mV LSB to compute the bus voltage measured by the device in volts.
- Shunt Voltage [mV]:
- The Shunt Voltage Register has an address of 0x01 and is the voltage measured across the shunt resistor. The shunt voltage has an LSB of 10μV, which is 1mV/100. To get the shunt voltage in mV, the shunt voltage register must be multiplied by the 1mV/100 LSB.
- Current [mA]:
- The current register has an address of 0x04 and is the current through the shunt resistor that is internally computed from the shunt voltage register and calibration register (see Figure 13). The current register content is multiplied by the Current_LSB and converted from Amps to milliAmps by a factor of 1000.
- Power [mW]:
- The Power Register has an address of 0x03 and is internally computed from the product of the current register and bus voltage register. The Power Register content is multiplied by Power LSB which is 20 times the Current_LSB for a power value in Watts. To convert Watts to milliWatts, the power is multiplied by 1000.
These conversions are performed internally by libraries discussed in the next section.
Libraries
Arduino
The two most common libraries in Arduino code are the Adafruit_INA219 and INA219_WE. Both of these libraries can be found and installed using the Arduino IDEIntegrated Development Environment (IDE) is a software application that helps develop software code efficiently. Library Manager or they can be downloaded from GitHub. The Wire Library is also used to communicate over I2C and is already included in the Arduino IDE by default.
The Adafruit_INA219 library was created by Adafruit for their INA219 module, although the library also works with generic modules. The INA219_WE library was created by Wolfgang Ewald to provide more functionality and control over the INA219.
The Adafruit library is the easiest to use with three pre-calculated calibration options (32V 2A, 32V 1A, and 16V 400mA) and simple function commands to make measurements. The INA219_WE library has more functionality and control that allows you to set the gain and bus voltage range, choose between continuous or trigger measurement modes, set ADC mode resolution and conversion times, set a correction factor and shunt offset voltage, and check for overflow.
CircuitPython & MicroPython
The two most common libraries in Python are the Adafruit_CircuitPython_INA219 in CircuitPython and pyb_ina219 in MicroPython. Both of these libraries can be downloaded from GitHub.
The Adafruit CircuitPython library uses its own BusDevice Library and Register Library for communicating over I2C. The pyb_ina219 MicroPython library uses the I2C Class from the built-in Machine library.
The Adafruit library is the easiest to use with three pre-calculated calibration options (32V 2A, 32V 1A, and 16V 400mA) and simple function commands to read measurements. The pyb_ina219 library has more functionality and control that allows you to set the gain and bus voltage range, set ADC resolution/sampling, set wake or sleep modes, and check for overflow. Both libraries currently only support continuous reads of voltage and power, but not triggered reads.
Conclusion
This hardware overview of the INA219 IC and Modules covered specs, board layout, pinout, operation, basic hookup, and libraries in Arduino, CircuitPython, and MicroPython.
The output of the INA219 is an I2C digital communication interface that can be read using libraries. The Adafruit libraries in Arduino or CircuitPython are is the easiest to use with pre-calculated calibration options and simple function commands to read measurements, while the the custom made libraries in Arduino or MicroPython have more functionality to control of the INA219.
The INA219 has a wide input voltage of ±26V, and with a 0.1Ω shunt resistor it supports up to 3.2A with 0.8mA resolution. The programmable gain and ADC resolution allows you to lower the input range to 16V 400mA to improve the resolution to 0.1mA. The I2C interface makes it compatible with most microcontrollers and Single Board Computers (SBCs).
Products
Created:
21Oct2022 20:27:49 UTC
2022-10-21T20:27:49Z
Updated:
13May2024 00:25:43 UTC
2024-05-13T00:25:43Z
The INA219 IC measures the current and voltage drop across an external shunt resistor with high side sensing and also measures the bus supply voltage. The shunt current, shunt voltage, and bus voltage are output through an I2C interface.
(0) Comments
Sign in to leave a comment
Sign In