Erriez I2C/SMB DC Voltage/Current/Power sensor library for Arduino  1.0.0
This is an I2C/SMB DC Voltage/Current/Power sensor library for Arduino
Public Member Functions | Public Attributes | List of all members
INA219 Class Reference

INA219 class. More...

#include <ErriezINA219.h>

Public Member Functions

 INA219 (uint8_t i2cAddress=INA219_I2C_ADDRESS, float shuntResistor=INA219_SHUNT_RESISTOR)
 INA219 constructor. More...
 
bool begin ()
 Initialize INA219. More...
 
bool powerDown ()
 Set INA219 in power-down mode. More...
 
bool powerUp ()
 Power-up INA219. More...
 
bool read ()
 Read voltage and current from INA219. More...
 
void registerWrite (uint8_t reg, uint16_t val)
 Write to INA219 register. More...
 
uint16_t registerRead (uint8_t reg)
 Read from INA219 register. More...
 
uint8_t getI2CStatus ()
 Return status of the last I2C write, returned by Wire endTransfer() More...
 
void dumpRegisters (Stream *serial)
 Print I2C registers on serial port. More...
 

Public Attributes

float busVoltage
 Bus voltage in V.
 
float shuntVoltage
 Shunt voltage in mV.
 
float current
 Current in mA.
 
float power
 Power in mW.
 
bool overflow
 Overflow.
 
bool available
 Successful conversion.
 

Detailed Description

INA219 class.

Definition at line 106 of file ErriezINA219.h.

Constructor & Destructor Documentation

◆ INA219()

INA219::INA219 ( uint8_t  i2cAddress = INA219_I2C_ADDRESS,
float  shuntResistor = INA219_SHUNT_RESISTOR 
)

INA219 constructor.

Parameters
i2cAddressI2C address
shuntResistorShunt register in ohm, default: INA219_SHUNT_RESISTOR = 0.1 Ohm

Definition at line 46 of file ErriezINA219.cpp.

Member Function Documentation

◆ begin()

bool INA219::begin ( )

Initialize INA219.

Return values
trueINA219 detected
falseINA219 not detected

Definition at line 59 of file ErriezINA219.cpp.

◆ dumpRegisters()

void INA219::dumpRegisters ( Stream *  serial)

Print I2C registers on serial port.

This function is optimized away by the compiler when not used

Parameters
serialSerial port

Definition at line 239 of file ErriezINA219.cpp.

◆ getI2CStatus()

uint8_t INA219::getI2CStatus ( )

Return status of the last I2C write, returned by Wire endTransfer()

Return values
0Success
1Data too long to fit in transmit buffer
2Received NACK on transmit of address
3Received NACK on transmit of data
4Other error

Definition at line 226 of file ErriezINA219.cpp.

◆ powerDown()

bool INA219::powerDown ( )

Set INA219 in power-down mode.

Return values
trueSuccess
falseError: I2C write register failed

Definition at line 71 of file ErriezINA219.cpp.

◆ powerUp()

bool INA219::powerUp ( )

Power-up INA219.

Return values
trueSuccess
falseError: I2C write register failed

Definition at line 90 of file ErriezINA219.cpp.

◆ read()

bool INA219::read ( )

Read voltage and current from INA219.

Variables

Return values
trueConversion completed
falseError: I2C read failed, or INA219 is in power-down

Definition at line 112 of file ErriezINA219.cpp.

◆ registerRead()

uint16_t INA219::registerRead ( uint8_t  reg)

Read from INA219 register.

Parameters
regINA219 register 0..5
Return values
trueRegister read success
falseError: I2C read failed

Definition at line 191 of file ErriezINA219.cpp.

◆ registerWrite()

void INA219::registerWrite ( uint8_t  reg,
uint16_t  val 
)

Write to INA219 register.

Parameters
regINA219 register 0..5
val16-bit INA219 register value
Returns
Result of Wire endTransmission()

Definition at line 209 of file ErriezINA219.cpp.


The documentation for this class was generated from the following files: