Skip to content

ESP32 SNTP Configuration Not Syncing

DodaTech Updated 2026-06-26 1 min read

In this tutorial, you'll learn about ESP32 SNTP Configuration Not Syncing. We cover key concepts, practical examples, and best practices.

The Problem

ESP32 SNTP daemon fails to synchronize time or uses incorrect NTP servers.

Quick Fix

Wrong

sntp_setservername(0, (char*)"pool.ntp.org");
sntp_init();
Time remains at epoch 0. SNTP sync never completes.
sntp_setoperatingmode(SNTP_OPMODE_POLL);
sntp_setservername(0, "pool.ntp.org");
sntp_setservername(1, "time.nist.gov");
sntp_init();
time_t now = 0;
int retry = 0;
while (now < 100000 && retry < 10) {
  delay(2000);
  time(&now);
  retry++;
}
SNTP synchronized. Current time: Fri Jun 26 2026 10:30:00

Prevention

Set operating mode to SNTP_OPMODE_POLL. Provide multiple server fallbacks. Wait for sync with timeout. Call sntp_init() after Wi-Fi connection. Set timezone before displaying local time.

DodaTech engineers apply these same patterns across Doda Browser, DodaZIP, and Durga Antivirus Pro for production IoT reliability.

FAQ

### What is the difference between SNTP and NTP?

SNTP is a simplified version of NTP. ESP32 SNTP provides time with millisecond accuracy, sufficient for most IoT applications.

How often does SNTP sync?

ESP32 SNTP polls the server every 60 minutes by default. The interval is configurable with sntp_set_sync_interval().

Can I use SNTP without Wi-Fi?

No. SNTP requires network access. For offline projects, use an external RTC module (DS3231) via I2C.

Built by the developers of DodaTech

Doda Browser, DodaZIP & Durga Antivirus Pro