48 fprintf(stderr,
"Unable to open I2C bus: %s\n", strerror(errno));
52 for (
int i2cc = 0x40; i2cc < 0x44; i2cc++) {
54 fprintf(stdout,
"Input %02x\n", i2cc - 0x40 + 1);
59 if (isfinite(shuntVolts) && isfinite(busVolts)) {
60 fprintf(stdout,
"\tShunt Voltage: %+.3f mV\n", shuntVolts);
61 fprintf(stdout,
"\tBus Voltage: %+.6f V\n", busVolts);
62 fprintf(stdout,
"\tCurrent: %+.6f A\n", current);
63 fprintf(stdout,
"\tPower: %+.6f W\n", power);
65 fprintf(stdout,
"\tBad voltage readings - input disconnected?\n");
int i2c_openConnection(const char *bus)
Set up a connection to the specified bus.
void i2c_closeConnection(int handle)
Close existing connection.
float i2c_ina219_read_shuntVoltage(const int busHandle, const int devAddr, const void *opts)
Get voltage across the shunt resistor in millivolts.
bool i2c_ina219_configure(const int busHandle, const int devAddr)
Send configuration command to the specified device.
float i2c_ina219_read_current(const int busHandle, const int devAddr, const void *opts)
Get current flow through shunt resistor in amps.
float i2c_ina219_read_busVoltage(const int busHandle, const int devAddr, const void *opts)
Get bus voltage (at V- terminal) in volts.
float i2c_ina219_read_power(const int busHandle, const int devAddr, const void *opts)
Get power consumption in watts.