25#ifndef DETERMINISTICESPASYNCWEBSERVER_INA219_H
26#define DETERMINISTICESPASYNCWEBSERVER_INA219_H
30#define INA219_REG_CONFIG 0x00
31#define INA219_REG_SHUNT 0x01
32#define INA219_REG_BUS 0x02
33#define INA219_REG_POWER 0x03
34#define INA219_REG_CURRENT 0x04
35#define INA219_REG_CALIBRATION 0x05
62bool ina219_begin(uint8_t addr, uint32_t current_lsb_ua, uint32_t shunt_mohm);
uint16_t ina219_calibration(uint32_t current_lsb_ua, uint32_t shunt_mohm)
Compute the calibration register from the current LSB (microamps per bit) and the shunt resistance (m...
bool ina219_read_bus_mv(int32_t *millivolts)
Read the bus voltage into millivolts.
int32_t ina219_power_uw(int16_t raw, uint32_t current_lsb_ua)
Scale the raw power register to microwatts (power LSB is 20 * current LSB).
bool ina219_read_shunt_uv(int32_t *microvolts)
Read the shunt voltage into microvolts.
int32_t ina219_bus_mv(uint16_t raw)
Decode the bus-voltage register to millivolts (value is bits [15:3], LSB 4 mV).
int32_t ina219_shunt_uv(int16_t raw)
Decode the shunt-voltage register to microvolts (signed, LSB 10 uV).
bool ina219_begin(uint8_t addr, uint32_t current_lsb_ua, uint32_t shunt_mohm)
Program the INA219 at addr: write the calibration for current_lsb_ua (uA/bit) and shunt_mohm (millioh...
bool ina219_read_current_ua(int32_t *microamps)
Read the current into microamps (needs the calibration set by ina219_begin).
bool ina219_read_power_uw(int32_t *microwatts)
Read the power into microwatts (needs the calibration set by ina219_begin).
int32_t ina219_current_ua(int16_t raw, uint32_t current_lsb_ua)
Scale the raw current register to microamps (raw * current_lsb_ua).