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
|
#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. | |
INA219 class.
Definition at line 106 of file ErriezINA219.h.
INA219::INA219 | ( | uint8_t | i2cAddress = INA219_I2C_ADDRESS , |
float | shuntResistor = INA219_SHUNT_RESISTOR |
||
) |
INA219 constructor.
i2cAddress | I2C address |
shuntResistor | Shunt register in ohm, default: INA219_SHUNT_RESISTOR = 0.1 Ohm |
Definition at line 46 of file ErriezINA219.cpp.
bool INA219::begin | ( | ) |
Initialize INA219.
Definition at line 59 of file ErriezINA219.cpp.
void INA219::dumpRegisters | ( | Stream * | serial | ) |
Print I2C registers on serial port.
This function is optimized away by the compiler when not used
serial | Serial port |
Definition at line 239 of file ErriezINA219.cpp.
uint8_t INA219::getI2CStatus | ( | ) |
Return status of the last I2C write, returned by Wire endTransfer()
0 | Success |
1 | Data too long to fit in transmit buffer |
2 | Received NACK on transmit of address |
3 | Received NACK on transmit of data |
4 | Other error |
Definition at line 226 of file ErriezINA219.cpp.
bool INA219::powerDown | ( | ) |
Set INA219 in power-down mode.
true | Success |
false | Error: I2C write register failed |
Definition at line 71 of file ErriezINA219.cpp.
bool INA219::powerUp | ( | ) |
Power-up INA219.
true | Success |
false | Error: I2C write register failed |
Definition at line 90 of file ErriezINA219.cpp.
bool INA219::read | ( | ) |
Read voltage and current from INA219.
Variables
true | Conversion completed |
false | Error: I2C read failed, or INA219 is in power-down |
Definition at line 112 of file ErriezINA219.cpp.
uint16_t INA219::registerRead | ( | uint8_t | reg | ) |
Read from INA219 register.
reg | INA219 register 0..5 |
true | Register read success |
false | Error: I2C read failed |
Definition at line 191 of file ErriezINA219.cpp.
void INA219::registerWrite | ( | uint8_t | reg, |
uint16_t | val | ||
) |
Write to INA219 register.
Definition at line 209 of file ErriezINA219.cpp.