INA219 Current Sensor Module Primer

I got a couple of INA 219 modules from an online seller overseas. I was looking for a different dc current sensor module to start a small battery charger project, so I welcomed them.

INA219 Chip Data

The INA219 chip at the core of the dc current sensor module is a current shunt and power monitor with an I2C or SMBUS compatible interface. It features 16 programmable addresses. The chip uses a single 3 to 5.5V supply, drawing a maximum of 1mA of supply current. The INA219 chip can monitor both the shunt voltage drop and the bus supply voltage, with programmable conversion times and filtering. A programmable calibration value, combined with an internal multiplier, enables direct readouts of current in amperes. An additional multiplying register calculates power in watts (https://www.ti.com/lit/ds/symlink/ina219.pdf). Voila!

INA219 Module Intro

Following is an excerpt from the seller’s product description:

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. The breakout module can handle high-side of the current measuring up to +26V DC, even though it is powered with 3V or 5V. 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. It will also notify back the high-side of the voltage, which is excellent for tracking battery life.

Specification

0.1 Ω, 1%, 2 W current sense resistor

Target voltage up to +26V

Up to ±3.2A current measurement with ±0.8mA resolution

I2C 7-bit addresses 0x40, 0x41, 0x44, 0x45

INA219 Module – Serial Interface

The INA219 operates only as a slave device on the I2C bus and SMBus. Connections to the bus are made through the open-drain I/O lines SDA and SCL. The SDA and SCL pins feature integrated spike suppression filters and Schmitt triggers to minimize the effects of input spikes and bus noise. The INA219 supports the transmission protocol for fast (1- to 400-kHz) and high-speed (1-kHz to 2.56-MHz) modes. All data bytes are transmitted with the most significant byte first.

To communicate with the INA219, the master must first address slave devices through a slave address byte. The slave address byte consists of seven address bits, and a direction bit indicating the intent of executing a read or write operation. The INA219 has two address pins, A0 and A1.

The table below describes the pin logic levels for each of the 16 possible addresses. The state of pins A0 and A1 is sampled on every bus communication and should be set before any activity on the interface occurs. The address pins are read at the start of each communication event.

It is worth noting there are many models of the INA219 modules online. The following session shows the I2C address of the four different INA219 Chinese breakout boards/modules, and what solder pads have to be bridged to set a particular address.

  • No Bridge → 0x40 (default)
  • A0 Bridge → 0x41
  • A1 Bridge → 0x44
  • A0+A1 Bridge → 0x45

INA219 Module – My Pick

This is my INA219 module. Note that the input section (sense lines) has a footprint of a screw terminal block that can be soldered.

Now to its pin description:

  • VIN+ → Sense Input +
  • VIN- → Sense Input –
  • VCC → Module Power Input (+3 to 5V)
  • GND → Ground Rail (0V)
  • SDA → I2C Serial Data
  • SCL → I2C Serial Clock

And, its schematic for your reference:

INA219 Module & Arduino – First Test

Admittedly, there is nothing new or special about the INA219 module as there are countless tutorials/projects out there that exploit its ability to measure both dc current and voltage. I wanted to use INA219 modules in a couple of small projects for certain reasons. So, I decided to make some pre-flight tests myself. You can follow the steps below to test your INA219 module using an Arduino Uno microcontroller.

First of all, setup your hardware as shown in the below diagram:

Next, upload the following code to your Arduino Uno. Since the code is based on an Adafruit library, you should download (and install) it through the GitHub link given below. Note that this new version (1.1.0) of Adafruit INA219 library requires additional libraries and flash memory, but does not offer any extra features at this time!

Adafruit INA219 https://downloads.arduino.cc/libraries/github.com/adafruit/Adafruit_INA219-1.1.0.zip

[code]

#include

#include

Adafruit_INA219 ina219;

void setup(void)

{

Serial.begin(115200);

while (!Serial) {

delay(1);

}

uint32_t currentFrequency;

Serial.println(“INA219 Quick Test…”);

if (! ina219.begin()) {

Serial.println(“Failed to find INA219!”);

while (1) { delay(10); }

}

Serial.println(“Measuring Voltage and
Current with INA219 …”);

}

void loop(void)

{

float shuntvoltage = 0;

float busvoltage = 0;

float current_mA = 0;

float loadvoltage = 0;

float power_mW = 0;

shuntvoltage = ina219.getShuntVoltage_mV();

busvoltage = ina219.getBusVoltage_V();

current_mA = ina219.getCurrent_mA();

power_mW = ina219.getPower_mW();

loadvoltage = busvoltage + (shuntvoltage /
1000);

Serial.print(“Bus Voltage:” “); Serial.print(busvoltage);
Serial.println(“V”);

Serial.print(“Shunt Voltage: “);
Serial.print(shuntvoltage); Serial.println(“mV”);

Serial.print(“Load Voltage:” “); Serial.print(loadvoltage);
Serial.println(“V”);

Serial.print(“Current:” “); Serial.print(current_mA);
Serial.println(“mA”);

Serial.print(“Power: “); Serial.print(power_mW);
Serial.println(“mW”);

Serial.println(“”);

delay(2000);

}

[/code]

I picked an Arduino Proto Shield to rig up my quick test prototype. You can see a casual photo of that build here.

Next you can route the power supply (J1) of your load (J2) through the INA219 module (JP1) as shown in the hardware setup diagram. Remember to keep an eye on the dc power supply polarities and the common ground (GND) rail connection – the GND should also be in common with the ground for the load if voltage is being measured.

I used a 12VDC green LED plate with its power supply to conduct my first test. Below is a casual snap of that setup.

This is a snip of my Arduino Serial Monitor readout (yes, it worked quite well):

You see from this little primer that measuring current and voltage with the INA219 module in combination with an Arduino Uno is easy. Now you know the basic functionality of the INA219 module, but if you are interested in further exploration of the INA219 sensor, watch this page frequently. If you have any questions about this primer, use the comment box to drop your questions. I will answer them as quickly as possible.

Leave a Comment