Other Parts Discussed in Thread: BQSTUDIO,
Hi everyone,
I have been working with this BMS for two months now, but I can't even get the connection between the BMS system and any MCU. I previously tried to establish the communication using an STM32F407 board without any result. I used the function HAL_isDeviceReady() to check the address of the BMS (which should be 0x16/0x17 according to the datasheet), but the board didn't recognise any of address.
I gave up on that and I started using the Arduino Uno board, thinking that it would be much easier. I was wrong. I still have the same problem. I created a code to check whether the board sees that any slave address is connected to any of the possible 128 addresses but the board doesn't recognise anything. Actually as soon as I connect the BMS data line the Serial port freezes and only prints a few characters. The Arduino code that I am using is shown below.
Can someone help please!!
P.S. I must mention that both the HAL_isDeviceReady() and the Arduino code that I wrote work with any other I2C device that I have tested.
#include <Wire.h>
//#include <inttypes.h>
//#ifdefined(ARDUINO) && ARDUINO >= 100
//#include "Arduino.h"
/*
#define printIIC(args) Wire.write(args)
inline size_t CheckAddress::write(uint8_t value) {
send(value, Rs);
return 1;
}*/
void setup()
{
Serial.begin(2000000);
Wire.begin();
Serial.println("\nI2C Scanner");
//while (!Serial); // Leonardo: wait for serial monitor
//delay(1000);
}
void loop()
{
byte error, address;
int nDevices;
Serial.println("Scanning...");
nDevices = 0;
for(address = 0; address < 127; address++ )
{
Serial.print("Scanninng address");
Serial.println(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
}