Build Your Own Stratum 1 NTP Time Server with a Raspberry Pi and U-blox NEO-6M

With a low-cost GPS receiver, some wiring, and a Raspberry Pi, Kenneth Finnegan has a Stratum 1 server for his home network.

Gareth Halfacree
5 years agoHW101

Kenneth Finnegan has written a guide to turning a Raspberry Pi into a stratum 1 Network Time Protocol (NTP) server for your home network — using a low-cost off-the-shelf GPS receiver.

The Network Time Protocol, which allows highly-accurate time sources to be used as sources to synchronize multiple devices across a network, and works on a tiered model: The original time sources live in stratum 0, and are read by stratum 1 servers; these in turn are read by stratum 2 servers, which are in turn read by stratum 3 servers — all the way down, if required, to sixteen strata. Typically, a network uses NTP by synchronizing to a stratum 2 or stratum 3 server in an NTP pool — but that's not the only way.

"I decided that it was about time I pulled a project off the shelf from a few years ago and get a stratum 1 NTP server running on a Raspberry Pi again," Finnegan writes. "Pro: NTP is awesome, and this lets you get a stratum 1 time server on your local network for much lower cost that traditional COTS NTP time standards, which tend to be in the thousands of dollars price range.

"Con: This is a Raspberry Pi, booting off an SD card, with a loose PCB plugged into the top of it, so I wouldn't classify it as 'a robust appliance.' It isn't a packaged enterprise grade product, so I wouldn't rely on this NTP server on its own for anything too critical, but then again, I would say that about NTP in general; it's only meant to get clocks to within 'pretty close' of real time. If you're chasing individual milliseconds, you should probably be using PTP (Precision Time Protocol) instead of NTP... Totally depends on what you're doing. I'm just being a nerd."

The original stratum 0 source for Finnegan's NTP server is a GPS signal, received using a low-cost off-the-shelf receiver for the signal from the satellites - based on the incredibly accurate caesium atomic clock at their hearts. "I'm specifically using a u-blox NEO-6M GPS receiver," Finnegan explains, "which I got on eBay for a few dollars on a breakout board. This module isn't the "Precision timing" specific NEO-6T variant, but the 6M module is still completely sufficient for the level of time accuracy that we're looking for, and much cheaper/more available than the 6T module which is specifically designed for this sort of static time-keeping application (to the extent where the 6T will even lose GPS lock if you start moving it!)"

The GPS receiver is connected to the Raspberry Pi in two ways: Through the UART, which connects to a GPS-aware daemon running on the Raspberry Pi, and a pulse-per-second (PPS) connection — used with a kernel driver which timestamps each positive edge — "telling us exactly when the top of the second is," says Finnegan.

The project was put together using a generic NEO-6M breakout board, soldered to prototyping board with jumper wires making the necessary connections. "It will likely be much easier for you to just buy the one part from someone like Adafruit instead of trying to build your own and chase both hardware issues and software issues at the same time when trying to get this working," Finnegan admits. "But hey, do what you want; I'm not the boss of you. I just built my own because I happened to have all of these parts on hand already."

Finnegan's full guide, including configuring Raspbian and setting up the necessary daemons, can be found on his blog.

Gareth Halfacree
Freelance journalist, technical author, hacker, tinkerer, erstwhile sysadmin. For hire: freelance@halfacree.co.uk.
Latest articles
Sponsored articles
Related articles
Latest articles
Read more
Related articles