0

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
}
4
  • I didn't read through the datasheet, but apparently there is a 0x000E EXIT_DEEPSLEEP() subcommand or using a hardware assert on RST_SHUT pin to wake it up. You should read in more details of section "7.4 DEEPSLEEP Mode". Furthermore, when you write code, it is not only to understand what to read/write into a register, but also need to understand the timing requirements, take a look at "Table 9-2. Command/Subcommand Operation Time", so you probably need to add delayMicroseconds(50); in between the command sending and data receiving in your readWord() function. Commented Apr 8 at 13:27
  • hey hcheung, Thanks for the help! I tried to write the 0x000E EXIT_DEEPSLEEP() subcommand but nothing changed. The RST_SHUT pin is connected straight to GND. Thanks for the heads up about the delay. Nevertheless, the results are still the same. Commented Apr 9 at 16:31
  • BQ76952_I2C_ADDR 0x08 where 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". Commented Apr 14 at 1:31
  • I ran an I2C device scanner on my esp and it returned that address. I also checked the datasheet and on page 73 in "Table 9-1. Comm Type Data Memory Settings" and in that table it says this "0x08 I2C Fast (for use above 100 kHz bus speed)" . I tried the other address, but it didn't work. Commented Apr 16 at 15:19

1 Answer 1

0

Bro I’m working on this rn for my college project. To my understanding the ESP32 does not allow clock stretching which is what the IC needs. You should ask the forums on TI for help that’s what I use.

Sign up to request clarification or add additional context in comments.

2 Comments

Hey, you making something like a custom BMS? For some reason the chip always closes the fets and I can't open. I think that this is a problem with software, but idk. Shouldn't a small delay help to act as the clock stretch, like 1ms, the data should be ready by then.
Hey bro yeah I’m marking a custom one for my class, if the FETS are off that could mean you’re in shut down mode. Wanna get on discord and talk about it? This stack exchange stuff is weird to me lol.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.