Got the Time? Ben Leikin Does, Thanks to a Stratum-1 Time Server Built From a Raspberry Pi
The pulse-per-second input on a Raspberry Pi, coupled with a $15 GPS receiver, means you've no excuse to be late again.
Developer Ben Leikin has released everything you need to turn a Raspberry Pi and a low-cost Global Navigation Satellite System (GNSS)receiver into a Stratum-1 time server for your network — delivering a claimed sub-microsecond accuracy.
"[I] spent the last few weekends building out a hardware time reference using a [Raspberry] Pi 4 (could use any [Raspberry] Pi really as it uses almost no CPU power and memory) and it's been a fun rabbit hole," Leikin writes of the project. "The main lesson though: antenna placement matters way more than the GPS module quality. Spent more time moving the antenna around than doing anything else. Got from 1–2 satellites in a fix to consistently 8–11 just by finding a window with a clearer southern view."
The Global Navigation Satellite System (GNSS), of which the Global Positioning System (GPS) is the most well-known constellation, allows devices to determine their location by receiving high-precision time signals from orbiting satellites — which you can also use to figure out exactly what time it is, to a high precision. In Leikin's case, a $15 GPS module linked to a Raspberry Pi delivers sub-microsecond time synchronization with a 200 nanosecond jitter and then shares it to other devices on the network.
"The PPS [Pulse Per Second] pin is where the accuracy comes from," Leikin notes. "NMEA [National Marine Electronics Association 0183] serial data alone is good for ~50ms accuracy because of the variable lag between satellite reading and serial transmission. The PPS pulse is hardware-aligned to the actual GPS second within tens of nanoseconds, so chrony uses NMEA to figure out what time it is and PPS to figure out exactly when each second starts. Together you get sub-microsecond accuracy."
Leikin has released source code for the project and instructions on wiring the GPS module to the Raspberry Pi on GitHub under the permissive MIT license; additional information is available on Reddit.
Freelance journalist, technical author, hacker, tinkerer, erstwhile sysadmin. For hire: freelance@halfacree.co.uk.