This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

BQ25895: I2C not reporting correct battery voltage

Part Number: BQ25895


Tool/software:

Hi! 

I have a raspberry pi interacting with the BQ25895 via i2c. The D+/D- are shorted to set max current input to 3.25A automatically. The register reports at 0.992V when charger is not plugged in and 1.001V when VBUS in plugged in. The voltage also doesnt ever reflect the real battery voltage despite adding the 2.304V offset. The actual battery voltage measured with a multi meter is closer to 4.1V and 4.03V under load. Not really sure what's going wrong.

This is my python code:

import time
from smbus2 import SMBus

I2C_BUS = 6 
BQ25895_ADDR = 0x6A

REG_CONV = 0x02
VBAT_ADC_MSB = 0x10
VBAT_ADC_LSB = 0x11

def trigger_adc_conversion(bus):
val = bus.read_byte_data(BQ25895_ADDR, REG_CONV)
val |= (1 << 7) 
bus.write_byte_data(BQ25895_ADDR, REG_CONV, val)


while True:
val = bus.read_byte_data(BQ25895_ADDR, REG_CONV)
if not (val & (1 << 7)):
break
time.sleep(0.01) 

def read_battery_voltage():
with SMBus(I2C_BUS) as bus:

trigger_adc_conversion(bus)


msb = bus.read_byte_data(BQ25895_ADDR, VBAT_ADC_MSB)
lsb = bus.read_byte_data(BQ25895_ADDR, VBAT_ADC_LSB)

adc_val = (msb << 4) | (lsb >> 4)
voltage = adc_val * 0.001 
return voltage

if __name__ == "__main__":
vbat = read_battery_voltage()
print(f"Battery Voltage: {vbat:.3f} V")