Reach a server

SNTP time sync

Where time comes from when there is no RTC chip. Logs and TLS depend on it.

Reach a server Time sync ESP32 Wi-Fi parts

Official path: examples/protocols/sntp

01 Overview

Sync wall time after the network is up.

  • Use when: timestamps, TLS, scheduled jobs.
  • Skip when: fully offline calendar accuracy (add an RTC).

02 Hardware

  • No external RTC required. Add a coin-cell RTC if time must survive power loss.
  • Timezone is software, not the crystal.

03 Software flow

1. Get on the network.

2. Configure SNTP servers and start.

3. Wait until time is valid before TLS or schedules.

4. Retry on failure — never write business records with a fake clock.

04 Core points

  • TLS failures are sometimes a clock, not a certificate.
  • Custom work: RTC+SNTP mix, timezone, offline policy.

中文

连上服务器

SNTP 对时

没有 RTC 芯片时,时间从网上来。日志和证书都靠它。

连上服务器 对时 ESP32 Wi-Fi parts

官方路径: examples/protocols/sntp

01 项目概述

联网后同步网络时间。

  • 适用: 日志时间戳、TLS、定时任务。
  • 不适用: 完全离线且必须准确年历(要加 RTC 芯片)。

02 项目硬件描述

  • 可无外部 RTC。若要断电后仍知时间,加电池 RTC。
  • 时区是软件问题,不是晶振问题。

03 项目软件流程描述

1. 联网。

2. 配置 SNTP 服务器并启动。

3. 等时间有效后再做 TLS 或计划任务。

4. 失败要有重试,不能假时间写业务账。

04 项目核心点

  • TLS 失败有时是时间错,不是证书错。
  • 可定制: RTC 与 SNTP 混合、时区、离线策略。