Documentation
Onboarding
Getting Started
Power & Battery
Hardware & Components
Build & Assembly
Radio & RF Design
Frequencies & Regulations
Firmware & Software
USB & Connectivity
GPS & Navigation
Morse & Communication
Modes & Operation
Field Operations & Rescue
Building Effectively
Build Variants
Project & Reference
Docs Power & Battery Battery Monitor Details

Battery Monitor Details

Edit on GitHub

ADC chain, the 9-point Li-ion curve, calibration and the charging detect path

Battery Monitor Details

Overview

The battery monitor turns a resistor divider reading into a percentage you can trust. It samples 32 times, maps the voltage through a 9-point Li-ion discharge curve, and shows the result as both a number and a pixel-art icon.

Signal Chain

CODE
BAT+ (TP4056)
  -> 100k R3a
  -> GPIO 36 (ADC1_CH0) ---- 100k R3b ---- GND

Divider halves the voltage: 4.2 V full charge reads 2.1 V at the ADC.

Software Parameters

ParameterValueConstant
ADC pinGPIO 36PIN_BAT_ADC
Samples averaged32BAT_SAMPLES
Read interval5000 msBAT_READ_MS
Full-scale reference3900 mVBAT_VREF_MV
Full charge4200 mVBAT_FULL_MV
Empty3000 mVBAT_EMPTY_MV
Range guard2500-4500 mV-

The 9-Point Curve

Voltage%
4.20 V100
4.05 V90
3.90 V75
3.75 V60
3.65 V50
3.55 V35
3.40 V20
3.20 V10
3.00 V0

Calibration

If the reading disagrees with a multimeter, adjust BAT_VREF_MV:

CODE
#define BAT_VREF_MV   3900   // Increase if readings too low, decrease if too high

Charging Detect

The firmware does not currently read a charge-detect line: GPIO 39 is reserved for the radio DIO1 interrupt and no TP4056 STDBY input exists in the default build. Charge state must be judged from the battery percentage trend or a future firmware revision that dedicates a pin to the TP4056 STDBY signal.