Cirkit Designer LogoCirkit DesignerYour all-in-one circuit design IDE Launch Cirkit Designer App

How to Use INA219: Examples, Pinouts, and Specs

Image of INA219Design with INA219 in Cirkit Designer

Introduction

The INA219 is a high-side current shunt monitor with an integrated I2C interface, designed for precise current, voltage, and power measurements. It is capable of measuring the voltage across a shunt resistor and the bus voltage, enabling accurate power monitoring. The INA219 is widely used in applications such as battery management systems, energy monitoring, and power optimization in embedded systems.

Explore Projects Built with INA219

Use Cirkit Designer to design, explore, and prototype these projects online. Some projects support real-time simulation. Click "Open Project" to start designing instantly!
Image of ESP32-Based Solar Power Monitoring System with MPPT and INA219: A project utilizing INA219 in a practical application
ESP32-Based Solar Power Monitoring System with MPPT and INA219

This circuit is designed to monitor the voltage and current of a solar panel using an ESP32 Devkit V1 microcontroller and an INA219 current sensor. The ESP32 reads data from the INA219 via I2C communication (using pins D21 and D22 for SDA and SCL, respectively) and reports voltage, current, and power measurements over a serial connection. The solar panel is connected to an MPPT solar charge controller, which is in turn connected to the INA219 for monitoring its output.

Open Project in Cirkit Designer

Common Applications:

Technical Specifications

The INA219 offers high accuracy and flexibility for power monitoring applications. Below are its key technical specifications:

Parameter Value
Operating Voltage (Vcc) 3.0V to 5.5V
Bus Voltage Range 0V to 26V
Shunt Voltage Range ±320mV
Current Measurement Range Configurable (depends on shunt resistor)
Communication Interface I2C (7-bit address, default: 0x40)
Resolution 12-bit ADC
Accuracy ±1% (typical)
Operating Temperature -40°C to +125°C

Pin Configuration

The INA219 is typically available in an 8-pin SOIC package. Below is the pinout description:

Pin Name Description
1 V+ High-side connection to the positive terminal of the shunt resistor.
2 V- Low-side connection to the negative terminal of the shunt resistor.
3 GND Ground connection.
4 SDA I2C data line.
5 SCL I2C clock line.
6 ALERT Optional alert output for overcurrent or other conditions (open-drain).
7 A0 I2C address selection bit 0.
8 A1 I2C address selection bit 1.

Usage Instructions

The INA219 is straightforward to use in a circuit, thanks to its I2C interface and built-in ADC. Below are the steps to integrate and use the INA219:

Circuit Connection

  1. Power Supply: Connect the Vcc pin to a 3.3V or 5V power source, and GND to the ground.
  2. Shunt Resistor: Place a shunt resistor between the load and the INA219. Connect the V+ pin to the high side of the shunt resistor and the V- pin to the low side.
  3. I2C Interface: Connect the SDA and SCL pins to the corresponding I2C pins on your microcontroller (e.g., Arduino).
  4. Address Configuration: Use the A0 and A1 pins to set the I2C address if multiple INA219 devices are used on the same bus.

Example Arduino Code

Below is an example of how to use the INA219 with an Arduino UNO to measure current, voltage, and power:

#include <Wire.h>
#include <Adafruit_INA219.h>

// Create an instance of the INA219 class
Adafruit_INA219 ina219;

void setup() {
  Serial.begin(9600); // Initialize serial communication at 9600 baud
  while (!Serial) {
    delay(10); // Wait for the serial monitor to open
  }

  // Initialize the INA219 sensor
  if (!ina219.begin()) {
    Serial.println("Failed to find INA219 chip");
    while (1) {
      delay(10); // Halt execution if the sensor is not found
    }
  }
  Serial.println("INA219 initialized successfully");
}

void loop() {
  float shuntVoltage = ina219.getShuntVoltage_mV(); // Shunt voltage in mV
  float busVoltage = ina219.getBusVoltage_V();      // Bus voltage in V
  float current_mA = ina219.getCurrent_mA();        // Current in mA
  float power_mW = ina219.getPower_mW();            // Power in mW

  // Print the measurements to the serial monitor
  Serial.print("Shunt Voltage: ");
  Serial.print(shuntVoltage);
  Serial.println(" mV");

  Serial.print("Bus Voltage: ");
  Serial.print(busVoltage);
  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(1000); // Wait 1 second before the next reading
}

Important Considerations:

Troubleshooting and FAQs

Common Issues and Solutions

  1. INA219 Not Detected on I2C Bus:

    • Ensure the SDA and SCL lines are correctly connected to the microcontroller.
    • Verify that pull-up resistors are present on the I2C lines.
    • Check the I2C address configuration (default is 0x40).
  2. Incorrect Current or Voltage Readings:

    • Verify the shunt resistor value and ensure it matches the value used in calculations.
    • Check for loose or incorrect connections to the shunt resistor.
  3. No Output on Serial Monitor:

    • Ensure the baud rate in the Serial Monitor matches the Serial.begin() value in the code.
    • Confirm that the INA219 is properly powered and initialized.
  4. Overcurrent or Overvoltage Alerts:

    • If using the ALERT pin, ensure it is configured correctly in your circuit.
    • Check the load and shunt resistor to ensure they are within the INA219's operating range.

FAQs

Q: Can the INA219 measure negative currents?
A: Yes, the INA219 can measure bidirectional currents if configured appropriately. Ensure the shunt voltage range is within ±320mV.

Q: What is the maximum current the INA219 can measure?
A: The maximum current depends on the shunt resistor value. For example, with a 0.1Ω shunt resistor, the maximum measurable current is ±3.2A.

Q: Can I use the INA219 with a 3.3V microcontroller?
A: Yes, the INA219 is compatible with both 3.3V and 5V systems.

Q: How do I change the I2C address of the INA219?
A: Use the A0 and A1 pins to configure the I2C address. Refer to the datasheet for the address mapping.

By following this documentation, you can effectively integrate the INA219 into your projects for precise power monitoring and energy management.