Hello experts,
I'm attempting to read the current from an INA219 device. I've successfully read the bus voltage, indicating that the I2C driver is working correctly. However, when I read the current, I receive values that are approximately 2.2 times higher than expected (I verified this by comparing with a Fluke measurement). The current I'm working with is about 400-500 mA according to Fluke measurements, so this discrepancy is significant.
Here are the default values I've set:
#define INA219_SHUNT_RESISTOR_Ohm 0.004f #define INA219_CURRENT_LSB_A 0.0004f #define INA219_CALIB_VALUE (((uint16_t)(0.04096f / (INA219_CURRENT_LSB_mA * INA219_SHUNT_RESISTOR_Ohm))) << 1) #define INA219_POWER_LSB_W (INA219_CURRENT_LSB_A * 20.0f)
The register values are:
| 0x00 | Configuration | 0x0443 | Gain = 1; Range = 40mV, BADC = 1 (bus oversampling), SADC = 1 (shunt oversampling), Shunt and bus, triggered |
| 0x05 | Calibration | 0xC800 |
ina219.bus_voltage = (float)(bus_voltage_raw >> 3) * 4.0; // mV ina219.shunt_voltage = (float)((int16_t)shunt_voltage_raw) / 100.0; // mV ina219.current = (float)current_raw * INA219_CURRENT_LSB_A * 1000.0; // mA ina219.power = (float)power_raw * INA219_POWER_LSB_W * 1000.0; // mW
Could you please kindly help me identify the mistake? I've checked myself multiple times and haven't been able to find it.
Thank you in advance,
Genadi.






