I'm trying to solve this problem three days now, I narrowed it down and the root of the problem seems that the device doesn't want to exit sleep and initialize itself based on the reading the 0x12 Battery Status() Command returns this 1100010010000100 . Based on the bit definition it seems to be in sleep mode and not initialized. It's on page 53 of this datasheet https://www.ti.com/lit/ug/sluuby2b/sluuby2b.pdf . Does anyone know what I should do next?
#include <Wire.h>
// BQ76952 I2C address (7-bit)
#define BQ76952_I2C_ADDR 0x08
void setup() {
Serial.begin(115200);
Wire.begin(21, 22, 400000); // Initialize I2C with default pins (SDA=21, SCL=22)
delay(2000);
uint16_t subcmdStatus = readWord(0x00);
Serial.print("Subcommand Status (0x00): ");
Serial.println(subcmdStatus, BIN); // 10010100000000
uint16_t batteryStatus = readWord(0x12);
Serial.print("batteryStatus (0x12): ");
Serial.println(batteryStatus, BIN); // 1100010010000100
}
void loop(){
delay(1000);
}
uint16_t readWord(uint8_t reg) {
Wire.beginTransmission(BQ76952_I2C_ADDR); // 7-bit address of BQ76952
Wire.write(reg); // Register address
Wire.endTransmission(false); // Send repeated start
Wire.requestFrom(BQ76952_I2C_ADDR, 2); // Request 2 bytes
if (Wire.available() == 2) {
uint8_t lsb = Wire.read();
uint8_t msb = Wire.read();
return (msb << 8) | lsb; // Correct byte order
}
return 0xFFFF; // Error
}
delayMicroseconds(50);in between the command sending and data receiving in your readWord() function.BQ76952_I2C_ADDR 0x08where do you get this I2C address from? According to page 74 first paragraph, it said "The I2C device address is set by default as 0x10 (write), 0x11 (read), which can be changed by programming Settings:Configuration:I2C Address with the desired write address".