Skip to content

Conversation

@zakrent
Copy link

@zakrent zakrent commented Apr 8, 2024

Adds support for BQ27441 battery gauge IC.
This IC is used for example in this sparkfun dev board: https://www.sparkfun.com/products/13777 and also can be used on custom PCBs.
It uses Sparkfun library for this IC: https://github.com/sparkfun/SparkFun_BQ27441_Arduino_Library, it is MIT license.
I modified this library slightly to disable Wire.begin() call in it.

@zakrent zakrent force-pushed the main branch 2 times, most recently from 09b281b to 13e8674 Compare July 31, 2025 18:55
@zakrent zakrent changed the title Add support for BQ27441 battery monitor WIP: Add support for BQ27441 battery monitor Jul 31, 2025
@zakrent
Copy link
Author

zakrent commented Jul 31, 2025

Sorry, it exploded after I rebased it but now should be fine.

@zakrent zakrent changed the title WIP: Add support for BQ27441 battery monitor Add support for BQ27441 battery monitor Jul 31, 2025
float getVoltage() const { return voltage; }
float getLevel() const { return level; }

String getExtendedInfo();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use std::string instead

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

}
logger.info(
"Battery voltage: %.3f, level: %.1f%%",
"Battery voltage: %.3f, level: %.1f%%, %s",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this adds an unnecessary leading "," when anything other than the BQ chip is in use

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

src/defines.h Outdated
Comment on lines 66 to 68
#if BATTERY_MONITOR == BAT_BQ27441 && I2C_SPEED > 100000
#error BQ27441 library supports only 100 kHz I2C speed
#endif
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure how well this requirement would work, the sensor reading speed is already somewhat the bottleneck with 400kHz

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right, for daily use I use trackers iwth single IMU but if I tried it with 2nd one it got laggy.
I improved the sparkfun lib to support i2c >100 kHz.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants