ESP32 Timer Calibration Off Due to RC Oscillator
DodaTech
Updated 2026-06-26
1 min read
In this tutorial, you'll learn about ESP32 Timer Calibration Off Due to RC Oscillator. We cover key concepts, practical examples, and best practices.
The Problem
ESP32 timer timing is inaccurate because the RTC uses the internal RC oscillator instead of the external crystal.
Quick Fix
Wrong
// Using default timer config - may drift 1-3%
Timer drifts significantly. 1-second timing becomes 0.97-1.03 seconds.
Right
// Calibrate timer against RTC
uint64_t cal = timer_calibrate(TIMER_GROUP_0, TIMER_0, 100000);
if (cal != 0) {
float error = (cal - 100000.0) / 100000.0 * 100;
Serial.printf("Calibration: %llu ticks (%+.2f%% error)\n", cal, error);
} else {
Serial.println("Calibration not supported");
}
Calibration: 99872 ticks (-0.13% error)
(Error within acceptable range)
Prevention
Use timer_calibrate() to measure timer accuracy. Apply software correction for drift. Use external 32kHz crystal for accurate RTC timing. For precision timing, use the FRC (Free Running Counter) timer. Recalibrate when temperature changes.
DodaTech engineers apply these same patterns across Doda Browser, DodaZIP, and Durga Antivirus Pro for production IoT reliability.
FAQ
Built by the developers of DodaTech
Doda Browser, DodaZIP & Durga Antivirus Pro