Library Reference

Construction and Initialization Functions:

Adafruit_INA219(uint8_t addr = INA219_ADDRESS); 

Constructs an instance of the Adafruit_INA219.  If no address is specified, the default address (0x40) is used.  If more than one INA219 module is connected, it should be addressed as shown on the Assembly page and the configured address passed to the constuctor.

void begin(void); 

Initializes I2C communication with the Adafruit_INA219 device using the default configuration values.

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

Adafruit_INA219 ina219_A;
Adafruit_INA219 ina219_B(0x41);


void setup(void) 
{
  ina219_A.begin();  // Initialize first board (default address 0x40)
  ina219_B.begin();  // Initialize second board with the address 0x41
}

Sensor Reading Functions:

float getBusVoltage_V(void);  

Reads the voltage between GND and V-.  This is the total voltage seen by the circuit under test.  (Supply voltage - shunt voltage).  

The return value is in Volts.

float getShuntVoltage_mV(void);  

Reads the voltage between V- and V+.  This is the measured voltage drop across the shunt resistor.  

The return value is in Milivolts.

float getCurrent_mA(void);

Reads the current, derived via Ohms Law from the measured shunt voltage.

The return value is in Milliamps.

Example:
  float shuntvoltage = 0;
  float busvoltage = 0;
  float current_mA = 0;
  float loadvoltage = 0;

  shuntvoltage = ina219.getShuntVoltage_mV();
  busvoltage = ina219.getBusVoltage_V();
  current_mA = ina219.getCurrent_mA();
  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.println("");
This guide was first published on Oct 26, 2012. It was last updated on Sep 19, 2018. This page (Library Reference) was last updated on Nov 17, 2017.