This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Programmatically accessing the BQ-27441 fuel gauge using Raspberry PI

Other Parts Discussed in Thread: BQSTUDIO, BQ27441EVM-G1B, EV2400

I am using a Raspberry PI - B+, although my question is generic to any micro-controller board out there like Arduino. I have a BQ27441EVM-G1B, and I want to communicate with it with my own program, and not the bqStudio. I have got it working with a EV2400 and bqStudio and I can see the reqd voltage and temp values inside bqStudio. Now I want my program to access them. 

1.  Is there any library for accessing the gauge registers ? I saw one here  https://android.googlesource.com/kernel/tegra/+/b445e5296764d18861a6450f6851f25b9ca59dee/drivers/power/bq27441_battery.c 

but I dont know if its for general use. 

2.  Also, I am not able to detect the I2C device on my RPi. For that I am trying the standard command "sudo i2cdetect -y 1" . This outputs a table, and tells the address on which our I2C device is connected. For our gauge, this address should be 0xAA (if we consider 8-bit addressing, although the table only goes to 0x7F, considering 7-bit addressing, the address should be 0x55), but I see the whole table as blank. This command and this I2C bus works as I was getting the correct address and functionality with the BQ-24261 charger (which has a address of 0x6B). 

I am not writing any C code yet, as I think it should first be detected and then code should be tried. In either case, a small code sample to test could be great. 

My connections are as under:

Gauge  ----->    Raspberry Pi

VSS                      Pin 4 (5V)

SCL                      Pin 5 (SCL1)

SDA                      Pin 3 (SDA1)

VOUT                    Pin 6 (GND)

The pin-out diagram for the RPi is attached for your reference. I have tried "detecting" with and without the VSS pin connected to 5V, but to no avail. I am not connecting any pull-up resistors, as I believe there are some in the board. 

3. Do I need to make some configurations from inside bqStudio before trying to access this device using a micro-controller ?

Thanks and Regards,

Chintan Pathak 

  • 1. Refer to the TRM on how to configure the dataflash parameters. There is an example on how to change Design Capacity via I2C.

    2. How are you detecting your charger? The address is 0x55 for the gas gauge. 7-bit.

    3. Do you have an EV2300 or EV2400? Without these boxes, you will not be able to access the gas gauge via bqStudio.

  • 1. I read the TRM - Data Memory Parameter Update Example - Section 3.1, Pg - 14, it has set of commands to update the relevant registers, which is great. But I wanted to confirm that the gauge is connected to raspberry pi properly before coding and that the Pi is detecting it (This is  typically done using "sudo i2cdetect -y 1" which gives a blank output, even at 0x55. )

    2. I connected the BQ-24261 charger, as a separate experiment, to the I2C channel of raspberry Pi, it didnt require the VSS pin, so I just connected the SDA, SCL and GND of charger to SDA, SCL and GND of R Pi and issued the command "sudo i2cdetect -y 1 " meaning detect all devices on bus 1, and it obediently printed the address of the charger 0x6B. It should have done the same for gauge, which it hasnt, yet. So I am trying to debug this.

    3. I have a EV2400 and I am able to connect the gauge using the EV-2400 to the bqStudio, which lets me monitor the values obtained from the gauge, which is fine. Now, I want my program to read these values, for which the device had to be detected, or some other code sample to check the connections are proper.

    I have also tried running the i2cdetect command with and without the battery connected to the gauge and it is giving the same blank output.

    - CP

  • With some help from peers, I was able to get i2cdetect to read the values, the correct connections are:

    VSS ----- > GND     , SDA ------ > SDA1,     SCL ------> SCL1      , and that's it.

    Now running sudo i2cdetect -y 1 gives the address 0x55, which is the 7-bit address for the gauge.

    Thanks,

    CP