GPS RECEIVER
Setting atomic-clock precise time on your Pi
Sean Conway makes use of a Raspberry Pi Hat to pass some time, by setting up a GPS receiver to establish an accurate clock.
OUR EXPERT
Sean D. Conway After 40 years working with technology Sean uses Raspberry Pi projects to satiate his desire to explore electronics while having fun.
W e all assume that our devices and computers all keep accurate date and time, but when was the last time you looked at the clock on your computer and asked, “I wonder if that time is correct?” Often computers use the Network Time Protocol (NTP) from an internet time source to synchronise their time. In this tutorial, we’re going to examine a system for establishing accurate time without an internet connection. We will assemble a global positioning system (GPS) receiver using a Raspberry Pi and take advantage of the accurate time signals that are broadcast by GPS satellites.
Establishing a GPS reference time source is a complex task so we’ll break the task down into some manageable parts. First, we’ll install an Adafruit GPS Receiver HAT and configure the software. Second, we’ll examine the output signals provided by the receiver and take advantage of the GPS supplied tools to tweak the receiver for obtaining accurate time. Finally, we’ll configure a daemon service that uses the GPS signals to ensure the computer’s system time is accurate.
A reliable time source used as a reference could be an atomic clock or the master clock on a GPS receiver. NTP uses a stratum levels to organise the hierarchy in a time servers network. A Stratum 0 device is directly connected to a reference (reliable) time source. Stratum 0 may either be an atomic clock or a GPS receiver using the clock signals broadcast by GPS satellites.
Stratum 0 devices can’t distribute time over a network directly. They’re linked to a Stratum 1 time server that will distribute time to Stratum 2 servers or clients connected. The lower the Stratum number, the less timing accuracy and stability of time signal.
Computers worldwide use NTP to synchronise their times with internet-standard reference clocks via a hierarchy of NTP servers. systemd-timesyncd is the Systemd service that can synchronise the local system clock with a remote NTP server. Applications like ntpd and chrony can also obtain time from stratum time servers to manage time. GPS reception doesn’t require such a internet access network. GPS signal paired with a daemon like PPS-Client can be used for managing time.
YOU NEED
Raspberry Pi 3B+ 8+GB SD card Adafruit Ultimate GPS HAT Mini Kit Raspberry Pi OS Lite (4/3/2021) MT3339/ PA6H GPS software tools PPS-Client v2.0.3