Skip to main content
GNSS Documentation
GitHub Toggle Dark/Light/Auto mode Toggle Dark/Light/Auto mode Toggle Dark/Light/Auto mode Back to homepage

Time Server

Build a stratum-1 NTP time server using the GNSS HAT PPS signal and chrony.

Works with all three HATs. PPS output is on GPIO 5.

Note
PPS vs Library Timepulse — Enabling kernel PPS claims GPIO 5. You cannot use IGnssHat::timepulse() from the library while kernel PPS is active. Pick one or the other.

Overview

GNSS HAT → PPS (GPIO 5) → /dev/pps0 → chrony → NTP clients
         → NMEA         → gpsd      → chrony

The GNSS module provides two time references:

  1. PPS — sub-microsecond edge on GPIO 5 (precise but carries no date)
  2. NMEA — coarse UTC time in serial data (has date, ~50 ms jitter)

chrony combines both: NMEA tells it which second, PPS tells it exactly when that second starts.

Requirements

sudo apt-get update
sudo apt install pps-tools chrony gpsd gpsd-clients

1. Enable PPS in Device Tree

sudo nano /boot/firmware/config.txt

Add at the end:

dtoverlay=pps-gpio,gpiopin=5

Reboot:

sudo reboot

2. Load PPS Kernel Module

sudo modprobe pps-gpio
echo "pps-gpio" | sudo tee -a /etc/modules

Verify:

ls /dev/pps0
sudo ppstest /dev/pps0

3. Configure gpsd

Edit /etc/default/gpsd:

START_DAEMON="true"
USBAUTO="false"
DEVICES="/dev/jimmypaputto/gnss /dev/pps0"
GPSD_OPTIONS="-n"
START_DAEMON="true"
USBAUTO="false"
DEVICES="/dev/ttyAMA0 /dev/pps0"
GPSD_OPTIONS="-n"
START_DAEMON="true"
USBAUTO="false"
DEVICES="/dev/ttyACM0 /dev/pps0"
GPSD_OPTIONS="-n"

4. Configure chrony

Edit /etc/chrony/chrony.conf:

refclock SHM 0 refid GPS precision 1e-1 offset 0.0 delay 0.2 noselect
refclock PPS /dev/pps0 refid PPS lock GPS precision 1e-9 prefer
refclock SHM 0 refid GPS precision 1e-1 offset 0.0 delay 0.2 noselect
refclock PPS /dev/pps0 refid PPS lock GPS precision 1e-9 prefer
refclock SHM 0 refid GPS precision 1e-1 offset 0.0 delay 0.2 noselect
refclock PPS /dev/pps0 refid PPS lock GPS precision 1e-9 prefer

Restart services:

sudo systemctl restart gpsd
sudo systemctl restart chrony

5. Verify

chronyc sources -v
chronyc tracking

Look for the PPS source with * (selected) and offset in nanoseconds.

Note
Serving Time to LAN — Add allow 192.168.0.0/16 (or your subnet) to /etc/chrony/chrony.conf to serve NTP to other devices.