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 Timers Guide

ESP32 Timers Guide

Edit on GitHub

The timers the firmware relies on: millis for scheduling, the RTC timer for sleep, and the LEDC for tones.

ESP32 Timers Guide

Timing is the firmware’s skeleton: when to transmit, how long a tone lasts, when to wake. This page maps the ESP32’s timing hardware to its uses in the beacon.

The timing sources

SourceUsed forResolution
millis()Scheduler gaps, debounce1 ms
RTC timerDeep sleep wake (see Firmware Wake Sources)~1 s
LEDC (PWM)Tone generation (see Firmware Tone Generation)Hardware, CPU-free
GPS timeAbsolute time (see GPS Timing)1 s

The millis discipline

The firmware never calls delay() in the timing-critical paths (see Firmware TX Scheduler): every gap is measured with millis() deltas, so the radio keeps its schedule while the display and GPS do their work.

The millis wraparound

millis() wraps after about 49 days. The firmware compares deltas (now - last > interval), which is wraparound-safe: the subtraction works correctly across the wrap. Any code that compares raw millis() values with > instead of deltas will fail after 49 days of continuous operation.

The LEDC hardware

The ESP32’s LEDC peripheral generates the Morse tones without CPU involvement: configure frequency and duty, write the duration in the loop, and the hardware does the rest. This is what keeps the tone timing accurate while the radio works (see Firmware Tone Generation).