20260217_212053_z set RTC to GPS using 1PPS pulse-per-second discipline rtc-gps drift=+0 s; sats=20; lat=44.936488 lon=-123.021837; alt_m=59.1; hdop=0.7; utc_age_ms=659; pps_edges=805; fw_epoch=1771362221; fw_build_utc=20260217_210341_z |
||
|---|---|---|
| .. | ||
| lib/startup_sd | ||
| scripts | ||
| src | ||
| platformio.ini | ||
| README.md | ||
Exercise 11: Set RTC to GPS (1PPS Discipline)
This exercise extends Exercise 9 behavior (GPS + SD + OLED) and disciplines the onboard RTC from GPS UTC using the GPS 1PPS (pulse-per-second) timing signal.
Implemented behavior:
- Boots PMU, OLED, SD watcher, and GPS UART using the same T-Beam Supreme pin mapping from prior exercises.
- Parses NMEA (
RMC,GGA,GSV) to track UTC validity and satellite counts. - Every 1 minute, attempts to set RTC from GPS:
- Uses latest valid GPS UTC.
- Waits for next
1PPSrising edge. - Sets RTC to GPS time aligned to that edge (UTC + 1 second).
- Appends event records to SD file:
- Path:
/gps/discipline_rtc.log - Append-only writes (
FILE_APPEND) - Format:
YYYYMMDD_HH24MISS_z\t set RTC to GPS using 1PPS pulse-per-second discipline\trtc-gps drift=+/-Ns
- Path:
- OLED success message shows RTC disciplined confirmation and timestamp.
- If GPS time cannot be determined (or 1PPS edge is not seen in timeout), OLED shows failure status and the loop delays 30 seconds before retry.
Build
source /home/jlpoole/rnsenv/bin/activate
pio run -e node_a
Upload
source /home/jlpoole/rnsenv/bin/activate
pio run -e node_a -t upload --upload-port /dev/ttyACM0