These days we’re all used to our computers always having the correct time. Periodically, they simply connect to the Internet and get the correct time from an Internet time (NTP) server. Our local mesh network is designed to work “off-the-grid” without an Internet connection. This is a problem.
All of our nodes and devices running services need to know the correct time. MeshChat servers record the date and time anyone posts a message. So does the SBARC mesh website. So how do we keep all these devices synchronized with the correct time?
To address this problem, I am building a Raspberry Pi (RPi) based stand-alone NTP Stratum 1 server. Since it cannot connect to the Internet to update the time, I decided to synchronize it using GPS. Adafruit makes a perfect add-on board for this that plugs into the GPIO header that offers full access to GPS signals including the time.
So every few seconds, the Raspberry “reads” the incoming GPS signals from whatever satellites it can “see” and adjusts it’s internal time. Normally, to get a good GPS “fix”, we need to connect to at least 5 or more satellites. However we can get an extremely accurate time reading from just one satellite.
To allow other devices on the mesh to synchronize the time, a little programming is required on the RPi so it can be used as an NTP Stratum 1 server. It operates exactly the same as a time server does on the Internet. So instead of using something like time.windows.com as a time server, we can use k6bpm-ntp.local.mesh as the time server for our mesh connected devices.
Connection speeds will vary node to node. While the RPi will be accurate to the millisecond, the various nodes using it may be off by a second or two because of latency delays due to connection speeds. But that’s okay. We don’t need millisecond accuracy for our purposes. In fact, we can be a minute off and it won’t hurt anything.
I will probably locate this at my house when I am through testing it. I have a very fast connection (25Mbps+) to the Gibraltar nodes there. Everyone is free to use it for their “NTP Server” when setting up their local nodes.