Skip to content

Instantly share code, notes, and snippets.

@rabssm
Last active July 27, 2024 10:50
Show Gist options
  • Save rabssm/e1890d15ca6b7fbd068dcbea95fa10de to your computer and use it in GitHub Desktop.
Save rabssm/e1890d15ca6b7fbd068dcbea95fa10de to your computer and use it in GitHub Desktop.
NTP with a Raspberry Pi and PPS GPS
# Install packages needed
sudo apt install gpsd gpsd-clients pps-tools
###########################
## Add the following lines to /boot/config.txt to set the port used for the PPS h/w input (in this case GPIO pin 18)
# The next lines are for GPS PPS signals
dtoverlay=pps-gpio,gpiopin=18
###########################
###########################
## Add the following to /etc/default/gpsd. Note that in this case we are just using the PPS output and not using the GPS time from the GPS's USB tty device
USBAUTO="false"
# Devices gpsd should collect to at boot time.
# They need to be read/writeable, either by user gpsd or the group dialout.
# DEVICES="/dev/ttyACM0 /dev/pps0"
DEVICES="/dev/pps0"
# Other options you want to pass to gpsd
GPSD_OPTIONS="-n"
###########################
###########################
## Add the following to /etc/chrony/chrony.conf
# Added for GPS/PPS
refclock SHM 0 delay 0.325 refid NMEA
refclock PPS /dev/pps0 refid PPS
allow 192.168.1.0/24 # my home network
###########################
# Reboot and check everything is working:
sudo ppstest /dev/pps0
gpsmon -n /dev/ttyACM0
chronyc sources && chronyc tracking
See https://austinsnerdythings.com/2021/04/19/microsecond-accurate-ntp-with-a-raspberry-pi-and-pps-gps/ for more details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment