communication with BMS circuit (bq2060)

Hello, I've been trying to get communication working between my Seeeduino Mega and the bq2060 "fuel gauge" circuit from a busted NTB battery where one cell failed, but the other 3 are fine, I want to :

a) get cummunication with the "fuel gauge" itself working
b) rewrite the EEPROM (24c01a) to set it to 3 cells (datasheet says it can be done)

I can't seem to able to get any of them to even respond, when scannig the I2C bus with "arduino explorer", both the bq2060 or the EEPROM show up where they're supposed to be...

my code so far:

#include <i2cmaster.h>

unsigned int addr=0x50;
unsigned char cmd=0;
unsigned char LSB=0;
unsigned char MSB=0;
int pec = 0;

void setup()
{
  i2c_init();
  Serial.begin(9600);
  Serial.println("Start!");
  delay(10);
  Serial.println("address is:");
  Serial.println(addr);
  addr<<1;
  Serial.println("command? ");
}

void loop()
{
  if (Serial.available() > 0) {
    cmd = Serial.read();
    delay(100); //wait for recive
    Serial.print(cmd);
  
  i2c_start_wait(addr+I2C_WRITE); //address & direction
  i2c_write(cmd); //command
  i2c_rep_start(addr+I2C_READ); //repeated start, read-mode, waits for Ack
  LSB = i2c_readAck();
  MSB = i2c_readNak();
  i2c_stop();
  Serial.print(" ");
  Serial.print(LSB);
  Serial.print(MSB);
  delay(100);
  Serial.println("command? ");
  }
}

Any help would be appreciated...

Hello
Did you ever get it working?
If not please send me your i2cmaster library and I will have a look at it. You might have forgot to change the CPU frequency (F_CPU) in twimaster.cpp, also are you using the right baudrate? :slight_smile:
Take a look at this post: http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1214872633
Especially reply 13.

  • Lauszus