My computers now know what time it is, to the millisecond, without using the Internet.
I put together a stratum-1 ntp time server, based on a Raspberry Pi 3 model B with an Adafruit Ultimate GPS Hat. I put the whole thing into a C4 Labs Zebra GPS HAT Case, made of layers of shiny acrylic. The case is entirely too beautiful, considering that I’m keeping this unit on a shelf in my garage, high up and out of sight, but it provides good dust protection, and the acrylic top is not only transparent to visible light, but it also allows the GPS signals to be received with the GPS unit’s built-in patch antenna, even indoors under my garage roof (the thinnest roof in my house, one layer of wood plus some composite shingles).
Why? Because I can, mostly. No, this has nothing to do with my earlier post on the possible demise of WWV/WWVB. I do have a use for accurate computer time coming in a future post. But before this, I was using ntp to get time accurate to a handful of milliseconds, usually. Now, my accuracy and stability has improved by a few of orders of magnitude, with errors measured in single-digit microsecond (millionths of a second) levels. That’s far more accurate than I need for any practical reason, but it’s nice to have, anyway. It was amazingly simple and cheap to achieve this level of accuracy.
How did I do it?
I purchased a Raspberry Pi 3 model B, an Adafruit Ultimate GPS Hat, and the case. The GPS hat required a bit of simple through-hole soldering to attach the header to the board. The rest went together very simply. Once I got it all together, I powered up the Raspberry Pi even before I placed an SD card into the Pi, and I left it outdoors, so it could “see” the satellites and obtain a GPS lock.
As I left the GPS outside getting locked onto the satellites, I downloaded the latest Raspbian Stretch image, and burned it onto an SD card. I changed the boot directory of the SD card image, and put a file named “SSH” there (contents don’t matter, mine was zero bytes long). This allows me to get into the Pi using the “ssh” program. Then I disconnected power from the Raspberry Pi, inserted the SD card, and booted up.
I went to my router’s status page to find out the address of my new Pi, and used ssh to connect to it, using the default user “pi” and default password, “raspberry”. I immediately changed the password, expanded the SD card image to fill the entire disk, set a static IP address, set a hostname, updated the software using “aptitude update” and “aptitude upgrade”, installed emacs (my favorite text editor), and basically got myself a basic bare-bones headless Raspberry Pi on my home network.
Once I did that, I went through the basic checkout and setup of the Adafruit GPS hat, as listed here: https://learn.adafruit.com/adafruit-ultimate-gps-hat-for-raspberry-pi/
Finally, I set up the Pi with GPS hat as a Stratum-1 time server, using the following instructions and script, by the legendary hacker Eric S. Raymond: https://www.ntpsec.org/white-papers/stratum-1-microserver-howto/
There is a lot of detail in that page, but the “Clockmaker” script handled the dirty work very effectively.
How well does it work? It stays pretty accurate, but if you watch for a while, you may notice some fluctuations as the computer’s quartz oscillator speeds up and slows down with the daily temperature fluctuations, and the ntp software steers the clock to correct as best it can. You can see the current offset and jitter of my ntp server right here!