SELKIELogger  1.0.0
INA219: Interface functions
Collaboration diagram for INA219: Interface functions:

Functions

bool i2c_ina219_configure (const int busHandle, const int devAddr)
 Send configuration command to the specified device. More...
 
uint16_t i2c_ina219_read_configuration (const int busHandle, const int devAddr)
 Read configuration from device. More...
 
float i2c_ina219_read_shuntVoltage (const int busHandle, const int devAddr, const void *opts)
 Get voltage across the shunt resistor in millivolts. More...
 
float i2c_ina219_read_busVoltage (const int busHandle, const int devAddr, const void *opts)
 Get bus voltage (at V- terminal) in volts. More...
 
float i2c_ina219_read_power (const int busHandle, const int devAddr, const void *opts)
 Get power consumption in watts. More...
 
float i2c_ina219_read_current (const int busHandle, const int devAddr, const void *opts)
 Get current flow through shunt resistor in amps. More...
 

Detailed Description

Function Documentation

◆ i2c_ina219_configure()

bool i2c_ina219_configure ( const int  busHandle,
const int  devAddr 
)

Send configuration command to the specified device.

Connect to specified device address and set configuration to defaults set at compile time.

Parameters
[in]busHandleHandle from i2c_openConnection()
[in]devAddrI2C Address for an INA219 sensor
Returns
True on success, false otherwise

Definition at line 40 of file I2C-INA219.c.

◆ i2c_ina219_read_busVoltage()

float i2c_ina219_read_busVoltage ( const int  busHandle,
const int  devAddr,
const void *  opts 
)

Get bus voltage (at V- terminal) in volts.

Connects to specified device address, reads the contents of the bus voltage register and converts the value to a floating point number.

Bus voltage is measured at the V- terminal.

If the overflow or invalid data flags are set, will return NAN

Parameters
[in]busHandleHandle from i2c_openConnection()
[in]devAddrI2C Address for an INA219 sensor
Returns
Bus voltage in volts, or NAN in case of error

Definition at line 115 of file I2C-INA219.c.

◆ i2c_ina219_read_configuration()

uint16_t i2c_ina219_read_configuration ( const int  busHandle,
const int  devAddr 
)

Read configuration from device.

Connect to specified device address and read configuration

Parameters
[in]busHandleHandle from i2c_openConnection()
[in]devAddrI2C Address for an INA219 sensor
Returns
configuration word

Definition at line 59 of file I2C-INA219.c.

◆ i2c_ina219_read_current()

float i2c_ina219_read_current ( const int  busHandle,
const int  devAddr,
const void *  opts 
)

Get current flow through shunt resistor in amps.

Connects to specified device address, reads the contents of the current register and converts the value to a floating point number.

Parameters
[in]busHandleHandle from i2c_openConnection()
[in]devAddrI2C Address for an INA219 sensor
Returns
Measured current in amperes, or NAN in case of error

Definition at line 173 of file I2C-INA219.c.

◆ i2c_ina219_read_power()

float i2c_ina219_read_power ( const int  busHandle,
const int  devAddr,
const void *  opts 
)

Get power consumption in watts.

Connects to specified device address, reads the contents of the power register and converts the value to a floating point number.

This is calculated internally from successive (but not concurrent) voltage and current measurements, so may be inaccurate for very high frequency variations.

Parameters
[in]busHandleHandle from i2c_openConnection()
[in]devAddrI2C Address for an INA219 sensor
Returns
Power consumption in watts, or NAN in case of error

Definition at line 148 of file I2C-INA219.c.

◆ i2c_ina219_read_shuntVoltage()

float i2c_ina219_read_shuntVoltage ( const int  busHandle,
const int  devAddr,
const void *  opts 
)

Get voltage across the shunt resistor in millivolts.

Connects to specified device address, reads the contents of the shunt voltage register and converts the value to a floating point number.

Out of range values are pinned to zero.

Parameters
[in]busHandleHandle from i2c_openConnection()
[in]devAddrI2C Address for an INA219 sensor
Returns
Shunt voltage in millivolts, or NAN on error

Definition at line 77 of file I2C-INA219.c.