This class provides APIs to all of the registers of the TI BQ27441 battery gauge, as used on the u-blox C030 board. The caller should instantiate an I2C interface and pass this to init(), which will initialise the chip and place it into its lowest power state. When battery gauging is enabled, the getRemainingCapacity()/getRemainingPercentage() API calls may be used; otherwise the chip will be maintained in its lowest power state until a voltage/current/temperature reading is requested.

Dependents:   example-battery-gauge-bq27441

Fixed current measurement and added power consumption

Hi Rob,

Nice work on the library. I have been using it over the past couple of days and noticed that the getCurrent always returned 0. I looked into it and it seems that it was hardcoded to return 0. When the battery is being drained, the chip returns a negative value for current, and the getTwoBytes function gives an unsigned int, which would have caused the current value to be misread. I added another function that reads a signed value from the specified register. This allows for the correct current and power measurements to be read from the chip. I also went ahead and added a getPower function which also returns a negative value if being drained. Adding the second getTwoBytesSigned method was probably not the best fix, however that is just what I did to get it to work. Ideally the getTwoBytes() would take a parameter that would specify signed/unsigned, however I did not want to go through the whole library and change every single getTwoBytes call. Just wanted to work with the current and power methods.

Feel free to pull these changes.

Tyler

Library to interface to the TI BQ27441, a fuel gauge monitor BQ27441

1 comment:

05 Apr 2018

Hi Tyler, very sorry for the late response. For some reason we never get e-mail notifications of pull requests, which is a real pain. Thanks very much for your fix: it so happens that one of our guys noticed this issue himself and was beginning to look into the problem. By complete coincidence, while looking for something else, I noticed your fork and then this PR.

It all turns out well in the end :-).

We'll do a quick test of your changes and then pull them in.