battery-charger-fuel-gauge-integration
Skill36 starsChanged 5 months agoMITView on GitHub
Use when integrating or debugging Li-ion charger/fuel gauge ICs (BQ24295, BQ27441, MAX17048) over I2C, covering charge start, watchdog host mode, NTC/JEITA faults, and SOC jumps
In this repository75 other files it gives its agents.
- 8051-mcu-debugSkill
- avem-integrationSkill
- ble-gatt-integrationSkill
- bootloader-debugSkill
- canbus-integrationSkill
- canopen-integrationSkill
- cellular-at-modem-integrationSkill
- cmbacktrace-integrationSkill
- cmsis-dsp-integrationSkill
- cortex-m-debugSkill
- cortex-r5-debugSkill
- crc-checksum-integrationSkill
- easylogger-integrationSkill
- embedded-app-example-libsSkill
- embedded-buffer-queue-libsSkill
- embedded-data-parsing-libsSkill
- embedded-debug-entrySkill
- embedded-fault-debugSkill
- embedded-framework-libsSkill
- embedded-input-libsSkill
- embedded-library-entrySkill
- embedded-linux-login-debugSkill
- embedded-peripheral-bringupSkill
- embedded-serial-log-debugSkill
- embedded-state-machine-libsSkill
- embedded-timing-libsSkill
- epd-integrationSkill
- esp-idf-integrationSkill
- fatfs-integrationSkill
- flashdb-integrationSkill
- freemodbus-integrationSkill
- freertos-kernel-debugSkill
- freertos-plus-tcp-integrationSkill
- gnss-gps-integrationSkill
- hardware-interface-debugSkill
- heatshrink-integrationSkill
- letter-shell-integrationSkill
- littlefs-integrationSkill
- low-power-debugSkill
- lvgl-integrationSkill
- lwip-integrationSkill
- mbedtls-integrationSkill
- mcuboot-integrationSkill
- mcu-flashing-debugSkill
- micro-ecc-integrationSkill
- miniz-integrationSkill
- mqtt-embedded-integrationSkill
- nanopb-integrationSkill
- nrf-connect-sdk-integrationSkill
- nr-micro-shell-integrationSkill
- openocd-jlink-stlink-debugSkill
- openthread-integrationSkill
- ota-update-integrationSkill
- plooc-integrationSkill
- power-management-integrationSkill
- qspi-xip-flash-debugSkill
- readme-writingSkill
- riscv-mcu-debugSkill
- rtos-debugSkill
- rt-thread-integrationSkill
- The first 60 shown.
The file
We split this skill into the rules it gives an agent
6 rules. About 0 are common, 2 are distinctive, and 4 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈2
Distinctive · estimate
This author's own choices. Worth a look.
4
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 14
Use this skill when:
- Very specific: line 21
Do not use this skill when the I2C bus itself is dead (no ACK on any address) or the board rails are wrong.
- Very specific: line 50
Run temperature compensation and status polling.
- Very specific: line 51
Update MAX17048 RCOMP from measured temperature at least once/minute.
- Very specific: line 56
No current with valid adapter: IINLIM too low, EN_HIZ set, ILIM pin resistor, or CE held high disabling charge.
- Distinctive: line 65
Before claiming charging and gauging work:
≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Battery Charger and Fuel Gauge Integration
Overview
Use this skill to bring up a Li-ion/LiPo charger IC (TI BQ24xxx/BQ25xxx) and a fuel gauge (TI BQ27xxx Impedance Track, or Maxim/Analog MAX1704x ModelGauge, e.g. MAX17048) over I2C. The hard parts are keeping the charger in host mode past its watchdog, and getting an accurate SOC before the gauge has a matching battery profile.
When To Use
Use this skill when:
- Charging never starts or restarts in a loop: check input current limit (
IINLIM,REG00[2:0]),EN_HIZ, theCEpin, and the I2C watchdog resetting registers to default. - The charger reports faults:
REG09latched faults,NTC_FAULT(REG09[2:0], with a real thermistor such as103ATon theTSpin), safety timer expiration, or JEITA temperature de-rating. - SOC from
BQ27441/MAX17048is wrong or jumps at power-up: profile not loaded, no learning cycle, or bad OCV calibration. - I2C reads to the charger/gauge fail or the wrong 7-bit address is used.
Do not use this skill when the I2C bus itself is dead (no ACK on any address) or the board rails are wrong; debug the bus and power tree first with hardware-interface-debug.
First Questions
Ask for:
- Exact charger and gauge part numbers, cell count/chemistry, pack capacity (mAh), and charge voltage (4.2 V vs 4.35 V — picks
BQ27441-G1Avs-G1B). - 7-bit I2C addresses, bus speed, and pull-up values; whether
INT/GPOUTis wired. - NTC/thermistor part and TS resistor network (
RT1/RT2), plus target charge/discharge temperature window. - Whether a battery profile (TI golden image
.gm.fs/.df.fs, or a MaximRCOMP/custom-model INI) exists, or a golden image must be created. - Current symptom: register dump, fault code, measured
VBAT/ICHG, or reported SOC vs true SOC.
Integration Checklist
- Confirm the device on the bus.
ACK the charger and gauge 7-bit addresses; read a known register (charger
REG0AVendor/Part/Revision, or gaugeControl()DEVICE_TYPEsubcommand) before writing anything. - Take and hold host mode on the charger.
Set
IINLIMinREG00[2:0], clearEN_HIZ(REG00[7]), enable charging viaCE/CHG_CONFIG(REG01[4]), then feed the I2C watchdog (writeREG01[6]) on a timer, or disable it (WATCHDOG=REG05[5:4]= 00), so registers do not reset to default and drop charging. - Configure charge parameters and protection.
Program fast-charge current (
ICHG,REG02), pre-charge/termination current (REG03), charge voltage (VREG,REG04), and enable NTC/JEITA limits; confirm the thermistor scaling (e.g.103AT) on theTSpin. - Load the fuel gauge battery profile.
For
BQ27441:UNSEALviaControl(), enterCFGUPDATE, pollFlags()until bit 4 is set, writeDesign Capacity/Design Energy/Terminate Voltage/Taper Ratein the data-memory block, fixBlockDataChecksum(255 - x, wherexis the byte-wise sum of the block), thenSOFT_RESET. ForMAX17048: load a custom model / setRCOMP0(CONFIGdefault0x97) or accept EZ defaults. - Calibrate SOC at first power-up.
Let the pack rest for a valid OCV read, then issue
MAX17048QuickStart(MODE=0x4000) or checkBQ27441Flags()ITPORcleared; do notQuickStartunder load. - Run temperature compensation and status polling.
Update
MAX17048RCOMPfrom measured temperature at least once/minute; onBQ27441feedTemperature()if host-reported. Poll chargerCHRG_STAT(REG08[5:4]) and readREG09twice to get fresh faults (it latches, clears on read).
Common Failures
- Charging restarts every ~40 s: I2C watchdog expired (default 40 s), resetting the writable control registers to defaults; feed it or disable
WATCHDOG. - No current with valid adapter:
IINLIMtoo low,EN_HIZset,ILIMpin resistor, orCEheld high disabling charge. - Charge stuck in pre-charge or never terminating:
BATLOWVthreshold (REG04[1]), wrong termination current, or safety timer expiring (REG09charge safety timer fault). NTC_FAULT/ no charge in a comfortable room: TS resistor network wrong, floatingTSpin, or JEITA cold/hot fold-back.- SOC reads 0/100 % or jumps tens of percent: profile (
Design Capacity) not written,BlockDataChecksumwrong so writes silently rejected, orITPORstill set. - Gauge writes ignored: device still
SEALED, or not inCFGUPDATEmode before writing the data-memory block. - I2C NAK: wrong 7-bit vs 8-bit address, missing pull-ups, or gauge in hibernate/shutdown.
Verification
Before claiming charging and gauging work:
- Dump charger
REG00–REG0A; confirmIINLIM,VREG,ICHG, watchdog state, andCHRG_STATtransitions Not Charging → Fast Charging → Termination Done. - Force a fault (unplug NTC or overheat pack) and confirm
REG09/INTreports it and clears on re-read. - Compare gauge SOC against a coulomb-counted or bench-measured charge/discharge; verify it tracks within a few percent and survives a reset (
ITPORclear, profile persists). - Confirm charging continues across a full watchdog interval without host register rewrites (or with the feeding task running).
Example
User:
BQ24295 一充电就每隔几十秒重启,SOC 还老是乱跳,怎么查?Agent:
- Asks for I2C address, adapter/
IINLIMsetting, whether the watchdog is fed, NTC network, and whether aBQ27441profile was loaded. - Reads
REG00/REG08/REG09; if registers reverted to defaults, enables watchdog feeding (writeREG01[6]) or disablesWATCHDOGto hold host mode. - Checks the gauge:
UNSEAL, verifiesDesign CapacityandBlockDataChecksum, clearsITPOR, thenQuickStart/rest-OCV calibrates SOC and re-tests across a charge cycle.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

