# GPS NTP Server

用 Rust 编写的 ESP32 GPS 校准网络时间服务器。

rust based ntp gps based server for esp32

用 Rust 编写的 ESP32 GPS 校准网络时间服务器。

- id: tim-oe-rust-gps-ntp
- author: tim-oe
- repository: https://github.com/tim-oe/rust_gps_ntp
- license: Apache-2.0
- shape: headless
- scenes: tools
- boards: ESP32
- browser_playable: no
- preview: Project screenshots
- html: https://esp32gallery.com/projects/tim-oe-rust-gps-ntp/
- html_zh: https://esp32gallery.com/zh/projects/tim-oe-rust-gps-ntp/
- json: https://esp32gallery.com/data/catalog/projects/tim-oe-rust-gps-ntp.json

## Hardware

ESP32-class board. Verify the exact board revision, display, power source and wiring in the upstream build guide.

ESP32 类开发板；请在上游构建文档中核对具体板型、屏幕、供电与接线。

## English

```
A stratum-1 time server built from three Adafruit FeatherWings: an ESP32-S3 TFT Feather, an Ultimate GPS board and an adlogger board. Rust firmware with two targets — ESP-IDF for the device and a host build for pure-logic unit tests — parses NMEA RMC/GGA with checksum validation, timestamps the PPS pulse on GPIO12 through an interrupt, and steers an NTP server answering UDP/123. The display pages cover time, satellites, PPS and battery, with a 15-second auto-blank. Measured against a GPS-disciplined Pi it sat within about 1.5 ms, and a validation script checks stratum, leap indicator and an offset tolerance of 100 ms by default.
```

## 中文

```
拿三块 Adafruit FeatherWing 叠出来的 stratum-1 授时服务器：ESP32-S3 TFT Feather 加 Ultimate GPS 和 adlogger。固件用 Rust 写，同一份 crate 出两个目标，一个跑 ESP-IDF 上设备，一个在主机上跑纯逻辑单测；GPS 的 RMC/GGA 带校验解析，PPS 走 GPIO12 的上升沿中断，NTP 服务在 UDP/123 上应答，还支持 ntpq 的 mode-6 诊断。屏上几页显示时间、卫星数、PPS 和电量，15 秒无操作自动熄屏。对照一台 GPS 授时的树莓派，偏差约 1.5 毫秒，另有脚本默认按 100 毫秒容差验 stratum 和闰秒标志。构建前要先按文档装 Rust 的 Espressif 工具链，Wi-Fi 凭据从编译环境变量读，共用一个 justfile 里的 flash-monitor、bench 等配方。
```
