Using i2c scanner with a device that has CRC

Hi, i have a stm32 bluepill running arduino framework, and it is connected to BQ7693003 battery monitor IC. Using the I2C Scanner sketch its running but spitting out all possible addresses and then saying at the end "No i2c device found" then repeats to list out all possible device ids. to me this means that the BQ7693003 is not communicating properly to the MCU. and looking through this BQ7693003 arduino compatible library it says my chip has CRC i was wondering is this why its not working for me? btw i have not used this library yet i just want to make sure that the bluepill has connection with the chip and then move on to use the library. (BQ7693003 is brand new thus working. circuit is connected properly.)

The standard I2C scanner code does not do this, so post the code you are actually using.

If the I2C scanner program does not detect the device, either you have a wiring error (check for the required pullup resistors on SDA and SCL), an I/O voltage mismatch, or a nonfunctional device.

Code:

#include <Arduino.h>
#include <Wire.h>
void setup()
{
  Wire.begin(PB7, PB6);
 
  Serial.begin(9600);
  while (!Serial);             // Leonardo: wait for serial monitor
  Serial.println("\nI2C Scanner");
}
 
 
void loop()
{
  byte error, address;
  int nDevices;
 
  Serial.println("Scanning...");
 
  nDevices = 0;
  for(address = 1; address < 127; address++ )
  {
    // The i2c_scanner uses the return value of
    // the Write.endTransmisstion to see if
    // a device did acknowledge to the address.
    Wire.beginTransmission(address);
    error = Wire.endTransmission();
 
    if (error == 0)
    {
      Serial.print("I2C device found at address 0x");
      if (address<16)
        Serial.print("0");
      Serial.print(address,HEX);
      Serial.println("  !");
 
      nDevices++;
    }
    else if (error==4)
    {
      Serial.print("Unknown error at address 0x");
      if (address<16)
        Serial.print("0");
      Serial.println(address,HEX);
    }    
  }
  if (nDevices == 0)
    Serial.println("No I2C devices found\n");
  else
    Serial.println("done\n");
 
  delay(5000);           // wait 5 seconds for next scan
}

Output:

Scanning...
Unknown error at address 0x01
Unknown error at address 0x02
Unknown error at address 0x03
Unknown error at address 0x04
Unknown error at address 0x05
Unknown error at address 0x06
Unknown error at address 0x07
Unknown error at address 0x08
Unknown error at address 0x09
Unknown error at address 0x0A
Unknown error at address 0x0B
Unknown error at address 0x0C
Unknown error at address 0x0D
Unknown error at address 0x0E
Unknown error at address 0x0F
Unknown error at address 0x10
Unknown error at address 0x11
Unknown error at address 0x12
Unknown error at address 0x13
Unknown error at address 0x14
Unknown error at address 0x15
Unknown error at address 0x16
Unknown error at address 0x17
Unknown error at address 0x18
Unknown error at address 0x19
Unknown error at address 0x1A
Unknown error at address 0x1B
Unknown error at address 0x1C
Unknown error at address 0x1D
Unknown error at address 0x1E
Unknown error at address 0x20
Unknown error at address 0x21
Unknown error at address 0x22
Unknown error at address 0x23
Unknown error at address 0x24
Unknown error at address 0x25
Unknown error at address 0x26
Unknown error at address 0x27
Unknown error at address 0x28
Unknown error at address 0x29
Unknown error at address 0x2A
Unknown error at address 0x2B
Unknown error at address 0x2C
Unknown error at address 0x2D
Unknown error at address 0x2E
Unknown error at address 0x2F
Unknown error at address 0x30
Unknown error at address 0x31
Unknown error at address 0x32
Unknown error at address 0x33
Unknown error at address 0x34
Unknown error at address 0x35
Unknown error at address 0x36
Unknown error at address 0x37
Unknown error at address 0x38
Unknown error at address 0x39
Unknown error at address 0x3A
Unknown error at address 0x3B
Unknown error at address 0x3C
Unknown error at address 0x3D
Unknown error at address 0x3E
Unknown error at address 0x3F
Unknown error at address 0x40
Unknown error at address 0x41
Unknown error at address 0x42
Unknown error at address 0x43
Unknown error at address 0x44
Unknown error at address 0x45
Unknown error at address 0x46
Unknown error at address 0x47
Unknown error at address 0x48
Unknown error at address 0x49
Unknown error at address 0x4A
Unknown error at address 0x4B
Unknown error at address 0x4C
Unknown error at address 0x4D
Unknown error at address 0x4E
Unknown error at address 0x4F
Unknown error at address 0x50
Unknown error at address 0x51
Unknown error at address 0x52
Unknown error at address 0x53
Unknown error at address 0x54
Unknown error at address 0x55
Unknown error at address 0x56
Unknown error at address 0x57
Unknown error at address 0x58
Unknown error at address 0x59
Unknown error at address 0x5A
Unknown error at address 0x5B
Unknown error at address 0x5C
Unknown error at address 0x5D
Unknown error at address 0x5E
Unknown error at address 0x5F
Unknown error at address 0x60
Unknown error at address 0x61
Unknown error at address 0x62
Unknown error at address 0x63
Unknown error at address 0x64
Unknown error at address 0x65
Unknown error at address 0x66
Unknown error at address 0x67
Unknown error at address 0x68
Unknown error at address 0x69
Unknown error at address 0x6A
Unknown error at address 0x6B
Unknown error at address 0x6C
Unknown error at address 0x6D
Unknown error at address 0x6E
Unknown error at address 0x6F
Unknown error at address 0x70
Unknown error at address 0x71
Unknown error at address 0x72
Unknown error at address 0x73
Unknown error at address 0x74
Unknown error at address 0x75
Unknown error at address 0x76
Unknown error at address 0x77
Unknown error at address 0x78
Unknown error at address 0x79
Unknown error at address 0x7A
Unknown error at address 0x7B
Unknown error at address 0x7C
Unknown error at address 0x7D
Unknown error at address 0x7E
No I2C devices found

(check for the required pullup resistors on SCA and SCL), an I/O voltage mismatch, or a nonfunctional device.

I have all that checked out. Also, i have a working BMS with stm32 chip same as in the bluepill, and that exact bq chip, everything tested working on the original firmware, however flashing code above will not show the chip's i2c address.

Unknown error means the I2C library is failing, most likely due to a serious wiring problem of some sort, for example, SCL shorted to SDA.

Please post a link to the battery management module.

1 Like

Ah really!? the bms is not really documented as far as i know, (thus needing custom firmware) here is some pictures of it.



I have reverse-engineered the motherboard, to figure out the I2C pins and uart. etc.. i have lots of these boards so also have removed every chip on the board to figure out what trace goes where, referencing the datasheet of STM32 to build a map. And indeed it does have pullups to 3.3V of 10Kohms

Furthermore i have connected a battery to this bms so that everything gets powered properly, just used the UART USB drive and same error pops up.

A logic analyzer would help to discover what is going wrong with the I2C commands.

An inexpensive one like this, combined with PulseView software, should be all you need. They are widely available.

ah okay, thanks for that link, will order one of those. In the meantime does the clock of the STM32 have a role in this problem? maybe? since this one is internal clock and the bluepill usually has external clock

I can't imagine why. The I2C bus line SCL is the communications clock, usually 100 or 400 kHz.

The default 100 kHz is recognized by almost all devices and safe to use, and easy to check with an oscilloscope.

Try changing the pull up resistors to something in the 3.3K range. Then connect only one device at a time and run the scanner. Be sure each works by itself first, that will make debugging much easier.

thanks for suggestion however i figured out what was wrong. The BQ7693003 was not booted via the TS1 Input. after it has a 3.3v signal from the mcu it was detected in the i2c scanner.
Code:

#define BMS_BOOT_PIN PA5      // connected to TS1 input
pinMode(BMS_BOOT_PIN, OUTPUT);
digitalWrite(BMS_BOOT_PIN, HIGH);
delay(100);

Output:

Scanning...
I2C device found at address 0x08  !
done

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.