You are here

easy GPS NTP server howto

6 posts / 0 new
Last post
easy GPS NTP server howto

If you need a source for time and don't have regular internet for your node(s), you can use a GPS dongle to get good enough results.  This is NOT a high accuracy NTP 'stratum 1' option, but should be 'good enough' to milliseconds for your mesh.

First, you need to have a raspberry pi or other linux based computer with a base install, and a GPS that is compatible with pi/linux.
Install some packages to get gps and ntp functionality.
Then, tweak the gpsd and ntp configs to use GPS dongle.

0. Give your pi a static mesh IP assignment on the mesh

1. install required packages on pi (internet needed):
         sudo apt-get install libgps gpsd gpsd-clients ntp

2. remove internet and reconnect pi to mesh as needed

3. on pi, edit /etc/default/gpsd, add/modify this line:


4. reboot pi

5. on pi, run cgps command line program and check output for gps lock

6. if cgps/gpsd does not work or use correct device, specify gps device in /etc/default/gpsd, and reboot.  In my experience, gpsd 'just works'.

7. on pi, edit /etc/ntp.conf
           1. comment out "pool..." lines
           2. add this at bottom of file:
               # GPSD
               server prefer
               fudge flag1 1 refid GPS

8. on pi, restart ntp (/etc/init.d/ntp restart)

9. on pi, check with command line program ntpq -p.  You should see some output regarding 'GPS'.  'Offset' should be 'small'

10. on pi, check time is accurate with 'date' command

11. on another mesh computer, check ntpd availability with windows command line on computer connected to mesh: w32tm /stripchart /computer:[your_pi.local.mesh]

12. configure nodes to use pi for network time. The ntp server entry on main config page at bottom = [your_pi.local.mesh]

13. nodes should have proper time within 0-15 minutes if the pi is accessible on the mesh

14. profit

N8SQT's picture
libgps >> libgps-dev

Should the package "libgps" actually be "libgps-dev"?

K6CCC's picture
That's great if want an
That's great if want an erector set.  Or for not much more money (provided you can even find a RasPi for sale) and a lot less effort, you can get one of these:

I have the NTP200 and it works great - and it is Stratum 1.
If you want to see mine, feel free to look at:
That's a look only page, so you can't break anything.

Note about step 12.  If you advertise the NTP service properly, no additional configuration is required in order for nodes on the AREDN mesh to get time from it - other than having a firmware version released some time this year (I don't remember which build added that).  As of the last I looked, there are 169 AREDN devices that have made a NTP request from my NTP200.
K5DLQ's picture
correct.   Advertising ntp is
correct.   Advertising ntp is now easier than ever...
N8SQT's picture
Had the bits

Hi Jim,

That's some nice kit. Good to see you're using the u-blox MAX-M8 - that keeps my paychecks coming ;-). Have a look at the MAX-M10. Drop in and more available.

I got one of those SparkFun surprise boxes over the summer and an old, but working, RPi 1 model B was in there. I figured that could handle serving NTP easy enough ;-). Something to play with and learn, so I don't mind the erector set approach.

When setting up a go box, I'll certainly consider one of your CenterClick units.

Cheers & 73,
Bob / N8SQT

N8SQT's picture
RPi OS: Bullseye and Bookworm comments
  • Bullseye: these instructions work
  • Bookworm: NTP got replaced with NTPsec, and there are some permissions details to figure out for the GPS

Theme by Danetsoft and Danang Probo Sayekti inspired by Maksimer