INA219 Zerø-Drift, Bidirectional Current/Power Monitor With I2C Interface
Updated: May 13
In this short article we will take a look at the functionality of the Flowcode Component to communicate with the INA219 Current Sensor,We will use the INA219 Breakout board for our Practical experiments.(available for Adafruit or Sparkfun .etc)
The INA219 Break Out Board
The INA219 based Current sensor module is an I2C interface based zero drift and bi-directional current/power monitoring module. It can sense shunt voltage, current, and power at the same time and submit the data via I2C protocol. It has 0.1 Ohms, a 1% shunt resistor to fulfill the requirement of current measurements. It has a powerful 12-bit ADC that converts the current sensed by a precision amplifier. The current sensing range is ±3.2A with a resolution of 0.8mA.(Advanced users can change the Shunt resistor and measure higher current Values as you will see later in the article)
INA 219 Interface Connections
The INA219 board already has the I2C pull up resistors installed on the board,If you interface to an INA219 on a custom board include the I2C resistors shown in the below schematic as optional.
Pin Description INA219
Features of INA219 Current Sensor Module
Power Input: 3.0V- 5.5V
Up to +26V target voltage
0.1 ohm 1% 2W current sense resistor
Up to ±3.2A current measurement, with ±0.8mA resolution
Senses Bus Voltages from 0 to 26 V
I2C- or SMBus-compatible interface
Up to 128 samples can be averaged to achieve filtering in noisy environments.
Setting the Module I2C Address
If more than one INA219 breakout board is used, each board must be assigned a unique address. This is done with the address jumpers on the right edge of the board. The I2C base address for each board is 0x40. The binary address that you program with the address jumpers is added to the base I2C address.
To program the address offset, use a drop of solder to bridge the corresponding address jumper for each binary '1' in the address
Up to 4 boards an be connected. Addressing is as follows:
Board 0: Address = 0x40 Offset = binary 00000 (no jumpers required)
Board 1: Address = 0x41 Offset = binary 00001 (bridge A0 as in the photo above)
Board 2: Address = 0x44 Offset = binary 00100 (bridge A1)
Board 3: Address = 0x45 Offset = binary 00101 (bridge A0 & A1)
The INA219 support many advanced settings for various shunt Resistor values with various PGA and ADC resolution settings which allow advanced users to calibrate the device to various situations and special needs.
However the device support a basic configuration (default) which most users are most likely will use for their applications .
These settings are.
PGA/8 shunt resistor voltage Range -320mV To 320mV
ADC Resolution 12 bits
Sample Rate Continuous sampling of Shunt and DC bus voltage
DC Bus Voltage 0 - 32V
Current Range depending on the Shunt Resistor Value (use shunt resistors in in powers of 10)
a 100 mOhm Shunt allows for a current of maximum 3.2A (per our test board)as at 3.2A the Shunt voltage value is at it maximum 320mV if we use 50 mOhm the we have a current range 6.4A .Take care that the Power rating of the shunt is ample for the current you want to measure.
The Device returns the Shunt Voltage and Bus voltage over I2C to the user Application.
The Flowcode Component supports all the above with macros,as shown below.
the the included example how to use these macro's
The Component macro "getPower" calculates the power by supplying the Current and DC bus Voltage to the Component as parameters it returns the power in Watt .
A basic example Flowchart shown below.
The Data is send over Serial USB to a Plotter application and Plotted as shown in the below Plot.
Simulation In Flowcode.
The Component has several Slider Indicators which is configurable(Range) in the Component Properties, They are used to display the data from the INA219 during simulation,The component supports SCADA simulation therefore when running the SCADA simulation the data is displayed in the Displays (Sliders).
The Component works with most micro-controller Families ,the Component was tested on PIC,Arduino and ESP32.
We can implement the advanced features of the INA219 for a advanced user if needed please use the contact page to contact us for consultations.