Adafruit INA219 Arduino Library
Classes | Macros | Enumerations
Adafruit_INA219.h File Reference
#include "Arduino.h"
#include <Adafruit_BusIO_Register.h>
#include <Adafruit_I2CDevice.h>
#include <Wire.h>

Go to the source code of this file.

Classes

class  Adafruit_INA219
 Class that stores state and functions for interacting with INA219 current/power monitor IC. More...
 

Macros

#define INA219_CALC_ADDRESS(INA_ADDR0, INA_ADDR1)   (0x40 | (INA_ADDR0 != 0 ? 0x01 : 0x00) | (INA_ADDR1 != 0 ? 0x04 : 0x00))
 
#define INA219_ADDRESS   (0x40)
 
#define INA219_READ   (0x01)
 
#define INA219_REG_CONFIG   (0x00)
 
#define INA219_CONFIG_RESET   (0x8000)
 
#define INA219_CONFIG_BVOLTAGERANGE_MASK   (0x2000)
 
#define INA219_CONFIG_GAIN_MASK   (0x1800)
 
#define INA219_CONFIG_BADCRES_MASK   (0x0780)
 
#define INA219_CONFIG_SADCRES_MASK   (0x0078)
 
#define INA219_CONFIG_MODE_MASK   (0x0007)
 
#define INA219_REG_SHUNTVOLTAGE   (0x01)
 
#define INA219_REG_BUSVOLTAGE   (0x02)
 
#define INA219_REG_POWER   (0x03)
 
#define INA219_REG_CURRENT   (0x04)
 
#define INA219_REG_CALIBRATION   (0x05)
 

Enumerations

enum  { INA219_CONFIG_BVOLTAGERANGE_16V = (0x0000), INA219_CONFIG_BVOLTAGERANGE_32V = (0x2000) }
 
enum  { INA219_CONFIG_GAIN_1_40MV = (0x0000), INA219_CONFIG_GAIN_2_80MV = (0x0800), INA219_CONFIG_GAIN_4_160MV = (0x1000), INA219_CONFIG_GAIN_8_320MV = (0x1800) }
 
enum  {
  INA219_CONFIG_BADCRES_9BIT = (0x0000), INA219_CONFIG_BADCRES_10BIT = (0x0080), INA219_CONFIG_BADCRES_11BIT = (0x0100), INA219_CONFIG_BADCRES_12BIT = (0x0180),
  INA219_CONFIG_BADCRES_12BIT_2S_1060US, INA219_CONFIG_BADCRES_12BIT_4S_2130US, INA219_CONFIG_BADCRES_12BIT_8S_4260US, INA219_CONFIG_BADCRES_12BIT_16S_8510US,
  INA219_CONFIG_BADCRES_12BIT_32S_17MS, INA219_CONFIG_BADCRES_12BIT_64S_34MS, INA219_CONFIG_BADCRES_12BIT_128S_69MS
}
 
enum  {
  INA219_CONFIG_SADCRES_9BIT_1S_84US = (0x0000), INA219_CONFIG_SADCRES_10BIT_1S_148US = (0x0008), INA219_CONFIG_SADCRES_11BIT_1S_276US = (0x0010), INA219_CONFIG_SADCRES_12BIT_1S_532US = (0x0018),
  INA219_CONFIG_SADCRES_12BIT_2S_1060US, INA219_CONFIG_SADCRES_12BIT_4S_2130US, INA219_CONFIG_SADCRES_12BIT_8S_4260US, INA219_CONFIG_SADCRES_12BIT_16S_8510US,
  INA219_CONFIG_SADCRES_12BIT_32S_17MS, INA219_CONFIG_SADCRES_12BIT_64S_34MS, INA219_CONFIG_SADCRES_12BIT_128S_69MS
}
 
enum  {
  INA219_CONFIG_MODE_POWERDOWN = 0x00, INA219_CONFIG_MODE_SVOLT_TRIGGERED = 0x01, INA219_CONFIG_MODE_BVOLT_TRIGGERED = 0x02, INA219_CONFIG_MODE_SANDBVOLT_TRIGGERED,
  INA219_CONFIG_MODE_ADCOFF = 0x04, INA219_CONFIG_MODE_SVOLT_CONTINUOUS = 0x05, INA219_CONFIG_MODE_BVOLT_CONTINUOUS = 0x06, INA219_CONFIG_MODE_SANDBVOLT_CONTINUOUS
}
 

Detailed Description

This is a library for the Adafruit INA219 breakout board -—> https://www.adafruit.com/product/904

Adafruit invests time and resources providing this open source code, please support Adafruit and open-source hardware by purchasing products from Adafruit!

Written by Bryan Siepert and Kevin "KTOWN" Townsend for Adafruit Industries.

BSD license, all text here must be included in any redistribution.

Macro Definition Documentation

◆ INA219_CALC_ADDRESS

#define INA219_CALC_ADDRESS (   INA_ADDR0,
  INA_ADDR1 
)    (0x40 | (INA_ADDR0 != 0 ? 0x01 : 0x00) | (INA_ADDR1 != 0 ? 0x04 : 0x00))

calculated I2C address: 0 = GND, 1 = V+

◆ INA219_ADDRESS

#define INA219_ADDRESS   (0x40)

default I2C address

◆ INA219_READ

#define INA219_READ   (0x01)

read

◆ INA219_REG_CONFIG

#define INA219_REG_CONFIG   (0x00)

config register address

◆ INA219_CONFIG_RESET

#define INA219_CONFIG_RESET   (0x8000)

reset bit

◆ INA219_CONFIG_BVOLTAGERANGE_MASK

#define INA219_CONFIG_BVOLTAGERANGE_MASK   (0x2000)

mask for bus voltage range

◆ INA219_CONFIG_GAIN_MASK

#define INA219_CONFIG_GAIN_MASK   (0x1800)

mask for gain bits

◆ INA219_CONFIG_BADCRES_MASK

#define INA219_CONFIG_BADCRES_MASK   (0x0780)

mask for bus ADC resolution bits

◆ INA219_CONFIG_SADCRES_MASK

#define INA219_CONFIG_SADCRES_MASK   (0x0078)

mask for shunt ADC resolution bits

◆ INA219_CONFIG_MODE_MASK

#define INA219_CONFIG_MODE_MASK   (0x0007)

mask for operating mode bits

◆ INA219_REG_SHUNTVOLTAGE

#define INA219_REG_SHUNTVOLTAGE   (0x01)

shunt voltage register

◆ INA219_REG_BUSVOLTAGE

#define INA219_REG_BUSVOLTAGE   (0x02)

bus voltage register

◆ INA219_REG_POWER

#define INA219_REG_POWER   (0x03)

power register

◆ INA219_REG_CURRENT

#define INA219_REG_CURRENT   (0x04)

current register

◆ INA219_REG_CALIBRATION

#define INA219_REG_CALIBRATION   (0x05)

calibration register

Enumeration Type Documentation

◆ anonymous enum

anonymous enum

bus voltage range values

◆ anonymous enum

anonymous enum

values for gain bits

◆ anonymous enum

anonymous enum

values for bus ADC resolution

◆ anonymous enum

anonymous enum

values for shunt ADC resolution

◆ anonymous enum

anonymous enum

values for operating mode

Enumerator
INA219_CONFIG_MODE_POWERDOWN 

power down

INA219_CONFIG_MODE_SVOLT_TRIGGERED 

shunt voltage triggered

INA219_CONFIG_MODE_BVOLT_TRIGGERED 

bus voltage triggered

INA219_CONFIG_MODE_SANDBVOLT_TRIGGERED 

shunt and bus voltage triggered

INA219_CONFIG_MODE_ADCOFF 

ADC off

INA219_CONFIG_MODE_SVOLT_CONTINUOUS 

shunt voltage continuous

INA219_CONFIG_MODE_BVOLT_CONTINUOUS 

bus voltage continuous

INA219_CONFIG_MODE_SANDBVOLT_CONTINUOUS 

shunt and bus voltage continuous