Skip to content

About

ESP-IDF bench firmware for debugging the LTC3337 coulomb counter on MHMB hardware

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

1 Commit

Folders and files

Repository files navigation

LTC3337 coulomb counter bench

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/).

Quick start

1. Build and flash

From ESP-IDF PowerShell:

cd ltc3337-coulomb-debug
.\build.ps1 build flash monitor -Port COM5

2. Take a reading

In the monitor window:

ltc> read

You should see BAT_IN on/off, BAT_OUT on/off, delta mV, Q, and SoC.

3. Continuous log

ltc> csv on
ltc> loop 2000

Samples every 2 seconds as LTC3337_CSV,... lines.

4. Save CSV on PC

Second terminal:

cd host
pip install pyserial
python capture_ltc3337_csv.py --port COM5

Files land in host/captures/ltc3337_<timestamp>.csv.

Serial commands

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

What to look for

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.

Defaults (match v7 profile)

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.

Restore production firmware

cd ..\..
idf.py -DWEARABLE_PROFILE=v7_offline_queue build flash monitor -p COM5

Hardware

Item Value
I2C SDA / SCL GPIO 8 / 9
LTC3337 address 0x64

Same as main MHMB firmware.

About

ESP-IDF bench firmware for debugging the LTC3337 coulomb counter on MHMB hardware

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages