Standalone ESP-IDF firmware for debugging the LTC3337 coulomb counter on MHMB hardware.
- No Wi-Fi, MQTT, BLE, PPG, or main firmware
- Reads BAT_IN on/off, BAT_OUT on/off, Q counter, SoC (voltage + coulomb)
- ADC snapshot on every sample (best for bench; higher I2C load)
- Serial commands + CSV logging for host capture
Includes a vendored copy of the production LTC3337 driver (components/ltc3337/).
From ESP-IDF PowerShell:
cd ltc3337-coulomb-debug
.\build.ps1 build flash monitor -Port COM5In the monitor window:
ltc> read
You should see BAT_IN on/off, BAT_OUT on/off, delta mV, Q, and SoC.
ltc> csv on
ltc> loop 2000
Samples every 2 seconds as LTC3337_CSV,... lines.
Second terminal:
cd host
pip install pyserial
python capture_ltc3337_csv.py --port COM5Files land in host/captures/ltc3337_<timestamp>.csv.
| Command | Action |
|---|---|
read / r |
One human-readable sample |
csv |
One CSV line |
regs |
Hex dump B–H (+ last written A) |
loop [ms] |
Auto-sample (default 2000 ms) |
stop |
Stop loop |
csv on / csv off |
Loop output format |
prescaler <0-15> |
Rewrite Reg A prescaler M |
capacity <mAh> |
Pack size for SoC math (default 500) |
header |
Print CSV column names |
status |
Show config |
| Signal | Healthy battery + load |
|---|---|
BAT_IN on/off |
~4.0–4.2 V / ~3.5–3.7 V (IPEAK ripple on IN) |
BAT_OUT on/off |
Valid mV (not -1000) after ADC refresh |
delta_on / best_delta |
≥ 600 mV needed for coulomb counting |
Q (Reg B) |
Should increment under sustained load |
SoC source |
voltage until Q moves; then coulomb |
See docs/TEST_PROCEDURE.md for a step-by-step bring-up checklist.
| Parameter | Value |
|---|---|
| IPEAK | 50 mA (IPK_sel=5, resistor strap) |
| Prescaler M | 9 |
| Reg A written | 0xFF09 |
| Pack capacity | 500 mAh |
| Turn-on delta | 600 mV |
Edit main/ltc3337_bench_config.h to change bench defaults.
cd ..\..
idf.py -DWEARABLE_PROFILE=v7_offline_queue build flash monitor -p COM5| Item | Value |
|---|---|
| I2C SDA / SCL | GPIO 8 / 9 |
| LTC3337 address | 0x64 |
Same as main MHMB firmware.