Bug
PiSugar3 battery level displays 100% on the pwnagotchi screen even after extended use on battery power.
Root Cause
The pisugarx plugin calculates battery percentage by reading voltage from I2C registers 0x22-0x23 and interpolating against a hardcoded voltage curve (curve5312). The curve maps anything ≥4.10V to 100%.
The problem is the PiSugar3's voltage readings are noisy — they fluctuate between ~4.00V and ~4.14V even when the real battery level is ~93%. The trimmed-mean averaging (deque of 10 readings, remove 2 highest/lowest) isn't enough to filter out the noise near full charge where the voltage curve is extremely flat (4.10V=100%, 4.05V=95%).
Better Approach
The PiSugar3 MCU (at I2C address 0x57) already provides a firmware-calculated battery percentage at register 0x2A. This is more accurate than voltage curve interpolation because the MCU runs continuously and accounts for load and charging state internally.
Testing shows:
- Voltage curve interpolation: 100% (stuck)
- MCU register 0x2A: 93% (correct)
This only affects PiSugar3 — PiSugar2/2Plus use a different IC (IP5312 directly) without this register, so they still need the voltage curve.
Bug
PiSugar3 battery level displays 100% on the pwnagotchi screen even after extended use on battery power.
Root Cause
The pisugarx plugin calculates battery percentage by reading voltage from I2C registers 0x22-0x23 and interpolating against a hardcoded voltage curve (
curve5312). The curve maps anything ≥4.10V to 100%.The problem is the PiSugar3's voltage readings are noisy — they fluctuate between ~4.00V and ~4.14V even when the real battery level is ~93%. The trimmed-mean averaging (deque of 10 readings, remove 2 highest/lowest) isn't enough to filter out the noise near full charge where the voltage curve is extremely flat (4.10V=100%, 4.05V=95%).
Better Approach
The PiSugar3 MCU (at I2C address 0x57) already provides a firmware-calculated battery percentage at register 0x2A. This is more accurate than voltage curve interpolation because the MCU runs continuously and accounts for load and charging state internally.
Testing shows:
This only affects PiSugar3 — PiSugar2/2Plus use a different IC (IP5312 directly) without this register, so they still need the voltage curve.