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 Firmware & Software ESP32 ADC Guide

ESP32 ADC Guide

Edit on GitHub

Using the ESP32's ADC for the battery monitor: the pins, the reference, the nonlinearity, and the calibration the firmware applies.

ESP32 ADC Guide

The ESP32’s ADC is where the battery voltage enters the firmware. It is also the most calibration-sensitive peripheral on the chip. This page is the practical guide.

The usable pins

The ESP32’s ADC is available on specific pins (GPIO 32-39 for ADC1 on most boards). The firmware uses GPIO 36 for the battery divider. Input-only pins (GPIO 34-39) work for the ADC but have no pull-ups (see ESP32 Input Only Pins).

The reference and the range

The ADC converts 0 - 3.3 V (with the default reference). The battery reaches 4.2 V, which is why the divider halves it first (see Ohm’s Law and Battery Monitor Calibration).

The nonlinearity

The ESP32’s ADC is famously nonlinear, especially near the rails. The consequences:

  • A reading of 3.3 V at the pin might represent a true 3.1 or 3.4 V.
  • The firmware applies calibration curves for the specific chip revision.
  • The two-point calibration (see Battery Monitor Calibration) is the field fix.

The sampling practices

PracticeWhy
Average 8 - 16 samplesKills noise
Read when the radio is idleThe TX burst pulls the rail and skews the reading
Read with a settled dividerThe divider’s own current settles in microseconds

The input impedance trap

The ADC pin’s input impedance is not infinite: a high-value divider (1 M ohm) interacts with the sample-and-hold and reads low. The firmware’s divider values (100k range) are chosen to avoid this (see Battery Monitor Details).