Calibration of a battery gauge BQ27510-G3

Hi Community,

I am currently trying to connect a battery gauge (BQ27510-G3 from TI) to an Arduino MKR 1010 Wifi via I2C. I don't have that much experience with serial communication and registers, but with example codes I was able to read the values provided by the gauge.

To obtain the correct values, it is necessary to calibrate the battery gauge (e.g. battery capacity, ....). Here the trouble starts, I am not able to read or write calibration parameters in the register (more precisely: classes with offsets). I have checked the data sheets and my code looks correct, but I am not able to read even the default calibration parameters.

Does anyone have a working sample code for the above mentioned gauge with an Arduino?

Thanks in advance!

I have checked the data sheets and my code looks correct, but I am not able to read even the default calibration parameters.

I miss the link to the datasheet and the mentioned code in your post.

Hi Pylon,

I copied the code from a Sparkfun project on GIT. The big difference between my gauge and the gauge of Sparkfun is that the gauge of Sparkfun uses a ROM, while the BQ27510-G3 uses a FLASH. The FLASH does not have to go into the config mode. I mainly adjusted the addresses of the registers and deleted some things not needed. The working principle should however be the same as for the Sparkfun gauge (BQ27441), according to the data sheet.

Reading and writing from the registers works well. I only have problems with the calibration (reading and writing of the classes/offsets).

The datasheet is here: BQ27510-G3 data sheet, product information and support | TI.com. Some information also comes from the first version of the gauge: BQ27510 data sheet, product information and support | TI.com.

Thanks

Bq27510_codeadaption_I2C.ino (1.95 KB)

BQ27441_Definitions.h (6.39 KB)

SparkFunBQ27441.cpp (16.1 KB)

SparkFunBQ27441.h (13.5 KB)

That code doesn't compile, it's not complete. You don't even try to implement the calibration process as described by this document. Am I wrong and you try to implement something different? If yes, please specify what you're actually trying to do.

Hi Pylon,

thanks for the answer!
I have seen your document, but the data sheet of the bq27510-G3 does not contain control commands (0x81 and 0x80) as defined in the other gauges in this document. So I am confused. However, the enable control command (0x2d) exists, unlike in the older bq27510 versions.
I tried to get into this configuration mode but had no success. The value I wanted to write was not written.

PS: It should be possible to compile the files. I call the function "setupBQ27441(void)" in the setup part of my main program and the function "printBatteryStats()" in the loop part.

Hi pylon or someone else,

I have now implemented the communication with the BQ27510-G3 from scratch. Reading the output parameters from the gauge works well.
The problem remains reading and writing the calibration parameters to the gauge.
The purpose of the attached code script is to read the standard calibration values (check function: "Read_Classes" ), I followed the description in the datasheet (Chapter 4). The data sheet has recently been updated, but the communication process should not have changed.
It looks like I have an access problem, but the gauge should be in unsealed mode.

I have been stuck at this point for some time now, so any help would be appreciated.

firmware.ino (5.13 KB)

Turn up your compiler warnings. You have some functions that purport to return int but have no return statements.

Hi Wildbill,

I don't get any error messages when I compile the script in the Arduino IDE.

Check your preferences. I don't think you have the error setting maxed out.

I have now extended my error messages and added returns. But the main problem remains the same.

Hi together,

I have a specific question still regarding this topic.

I want to perform the following procedure (https://www.ti.com/lit/ug/sluua97/sluua97.pdf?ts=1608223535387#page=29&zoom=100,0,425), but I get stuck at the first item (unsealing).
First I check the control_status bits (https://www.ti.com/lit/ug/sluua97/sluua97.pdf?ts=1608223535387#page=10 and plot them:

I interpret the first 7 bits as the HighBytes and the last 8 bits as the Lowbytes of the control_status bits (https://www.ti.com/lit/ug/sluua97/sluua97.pdf?ts=1608223535387#page=10) .
Especially important for unsealing (done in the function: ModifClasses) is the second bit (SS bit), which should be unset.
However, plotting the control_status bits again after unsealing (calling the function: ModifClasses) does not result in any changes:

So the Unsealing was not succesful.
What am I doing wrong? Or are my assumptions wrong? Unfortunately, I have no possibilities to check what is happening on the line.

Thanks for any help!

PS: The functions for this job are:

int ModifClasses(){

  // Reset
  int e[2]={0x41, 0x00};
  bytesending(e);
  
  // Unsealing
  int a= readControlWord(0x0000);   // Pre Command status
  Serial.print("StatusCommandPre:");
  Serial.println(a,BIN);
  Serial.println();

  int c[2]={0x14,0x04};
  bytesending(c);
  int d[2]={0x72,0x36};
  bytesending(d);
 
  int b= readControlWord(0x0000);   // Post Command status
  Serial.print("StatusCommandPost:");
  Serial.println(b,BIN);
  Serial.println();

  return true;
  }

With the sub-functions:

int bytesending(int *command){  
  if (i2cWrite((int) 0x00, command, 2))
    return true;
  
  return false;
}
int i2cWrite(int subAddress, int *data, int count)
{
  Wire.beginTransmission(BQ27510G3_Address);
  Wire.write(subAddress);
  for (int i=0; i<count; i++)
  {
    Wire.write(data[i]);
  } 
  Wire.endTransmission(true);
  
  //int f=Wire.endTransmission(true);
  //Serial.println(f);
  
  return true;  
}

int i2cRead(int subAddress, int *data, int count)
{ 
  Wire.beginTransmission(BQ27510G3_Address);
  Wire.write(subAddress);
  Wire.endTransmission(true);
  
  Wire.requestFrom(BQ27510G3_Address, count);
  
  for (int i=0; i<count; i++)
  {
    data[i] = Wire.read();
  } 

  return true;
}

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