5 minute guide to making a GPS Locked Stratum 1 NTP Server with a Raspberry Pi

This is an article on making a network attached Stratum 1 NTP Server using a Raspberry Pi+ Model 2 or 3 and the Uputronics Raspberry Pi+ GPS Expansion Board. If you need a standalone ready to go solution or need more performance please consider the LeoNTP Networked Time server unit which is available here.

Due to significant changes to Raspbian we have decided to retire the old guide here https://ava.upuaut.net/?p=726 and redo it.This guide assumes Raspbian Stretch Lite November 2018 released 2018-11-13. No other version or distribution is supported.

This solution will not give you a standalone off grid NTP server. NTP isn’t designed to work off grid using just the NMEA derived time and PPS to discipline it. You need an external server and then use PPS to discipline it.

Uputronics Raspberry Pi+ GPS Expansion Board

Ideally rather than supplying a premade image I would have a set of concise instructions on making your own install from scratch so you could use the latest versions of the software. With assistance from David Taylor who did lots of background work on this here I present the following instructions on making a cheap PPS disciplined NTP Time server using one of the Raspberry Pi+ GPS boards sold on Uputronics.

The guide assumes you have a cursory knowledge of Linux, enough to install Raspbian and login should do.

You will need a Raspberry Pi 2 or 3 B+, the Uputronics Raspberry Pi+ GPS Expansion Board and a suitable GPS antenna.

This guide is assuming you’re using Raspbian Stretch Lite November 2018 released 2018-11-13 image. Download and write this to an SD card (See http://www.raspberrypi.org/documentation/installation/installing-images/README.md). Other distributions may work but these instructions are known to work with Raspbian Stretch Lite.

Attach the Uputronics Raspberry Pi+ GPS Expansion Board to the Pi, insert the SD card, connect the antenna and network cable and boot the Pi up. Either connect locally or via SSH to the Pi (If you can’t SSH in and don’t have a monitor see this https://www.raspberrypi.org/documentation/configuration/wireless/headless.md)

Follow the instructions carefully if you miss steps things won’t work.

Text in italics is what you type.
Text in red indicates editing inside a file.

Prerequisite Settings

sudo raspi-config
5 Interfacing Options
P2 SSH -> Would you like the SSH server to be enabled – YES (Recommended)
P6 Serial -> Login Shell (no) Hardware (yes) (Optional)
Quit but no need to reboot at this point.

sudo nano /boot/config.txt
Add at the bottom :

Save and Quit Nano.

sudo apt-get update
sudo systemctl disable hciuart
sudo systemctl mask [email protected]
sudo apt-get install pps-tools ntp dnsutils
sudo reboot

Verifying PPS Is Working

Ensure the GPS has a lock and the Green PPS LED on the Uputronics Pi+ GPS Expansion Board is blinking once a second.

dmesg | grep pps

Output should be similar to :

[ 2.443494] pps_core: LinuxPPS API ver. 1 registered
[ 2.446699] pps_core: Software ver. 5.3.6 - Copyright 2005-2007 Rodolfo Giometti <[email protected]>
[ 2.471796] pps pps0: new PPS source pps.-1
[ 2.471886] pps pps0: Registered IRQ 498 as PPS source
[ 6.965166] pps_ldisc: PPS line discipline registered
[ 6.966569] pps pps1: new PPS source ttyAMA0
[ 6.966664] pps pps1: source "/dev/ttyAMA0" added

sudo ppstest /dev/pps0

Output should be similar to:

 trying PPS source "/dev/pps0"
 found PPS source "/dev/pps0"
 ok, found 1 source(s), now start fetching data...
 source 0 - assert 1418933982.998042450, sequence: 970 - clear  0.000000000, sequence: 0
 source 0 - assert 1418933983.998045441, sequence: 971 - clear  0.000000000, sequence: 0

(Press CTRL+C to quit). This indicates the PPS Module is loaded (top example) and is working (bottom).

GPS board mounted in Geaux Robot Dog Bone Case for Raspberry Pi B+ also available from HAB Supplies

GPS board mounted in Geaux Robot Dog Bone Case for Raspberry Pi B+ also available from Uputronics

Enabling PPS/ATOM Support in NTPD

The supplied version of NTPD on the Raspberry Pi now supports PPS so there is no need to roll your own NTP.

You need to pick a few local NTP servers to use. The easiest way to do this is pick your region:

Select your region then you get a list of the country servers. E.g for the UK its uk.pool.ntp.org.

dig uk.pool.ntp.org

You will get four IP’s back:

; <<>> DiG 9.10.3-P4-Raspbian <<>> +answer uk.pool.ntp.org
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 51647
;; flags: qr rd ra; QUERY: 1, ANSWER: 4, AUTHORITY: 0, ADDITIONAL: 1

; EDNS: version: 0, flags:; udp: 4000
;uk.pool.ntp.org. IN A

uk.pool.ntp.org. 24 IN A
uk.pool.ntp.org. 24 IN A
uk.pool.ntp.org. 24 IN A
uk.pool.ntp.org. 24 IN A

sudo nano /etc/ntp.conf
server minpoll 4 maxpoll 4
fudge flag3 1 refid PPS
tos mindis 0.2

Comment out all the pool lines:

#pool 0.debian.pool.ntp.org iburst
#pool 1.debian.pool.ntp.org iburst
#pool 2.debian.pool.ntp.org iburst
#pool 3.debian.pool.ntp.org iburst

Add the four servers from the dig command with the top one saying prefer on it:

server iburst prefer
server iburst
server iburst
server iburst

You may also want to add your local lan to so you can query the NTP Server by adding:
restrict mask

Note You MUST add a preferred server or PPS doesn’t work. Its worth at this point seeing if you’re ISP has its own NTP server you can use and adding that.

Save and close nano.

sudo service ntp restart

After a few minutes run

ntpq –p

if you get oPPS(0) this indicates source selected, Pulse Per Second (PPS) used and everything is working.

If you aren’t seeing the settings its possible the NTP server is picking up the NTP information via DHCP which is over riding your settings above. Do this :

rm /etc/dhcp/dhclient-exit-hooks.d/ntp
rm /var/lib/ntp/ntp.conf.dhcp

At this point you have a NTP server which will use an external time source and use your local PPS to discipline it.

Setting Stationary Mode

Grab this small program code here : https://pastebin.com/YTc9Nd3D
Compile + link:

gcc -o gpsControl gpsControl.c

sudo ./gpsControl -p -d /dev/ttyAMA0 = Portable Mode
sudo ./gpsControl -s -d /dev/ttyAMA0 = Stationary Mode

May take a few goes to set it.

[email protected]:~ $ sudo ./gpsControl -s -d /dev/ttyAMA0
Set GPS for stationary mode
Configuring device /dev/ttyAMA0
>>>>>>>>>>>>>>>>>>>>> SENDING >>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>> SENDING >>>>>>>>>>>>>>>
GPS mode set OK

Static IP + Hostname

If you want to fix your LAN IP you do it by amending /etc/dhcpcd.conf adding the following lines:

interface eth0
static ip_address=
static routers=
static domain_name_servers=

Amend your hostname by editing /etc/hostname and then adding this to /etc/hosts as well. I.e if you call your machine ‘eleanor’ add this after localhost in /etc/hosts: localhost eleanor

Further Reading

David Taylor’s website here http://satsignal.eu/ntp/Raspberry-Pi-NTP.html goes into much further detail about the process above and covers graphing, remote access monitoring etc and I highly recommend you read it.

Hope this helps, let me know how you get on with these instructions and I’ll try keep them up to date.

Thanks to:

David Taylor
Dave Akerman
sout + others on #ntp irc.freenode.org

Leave a comment ?


  1. Thanks for the post. Unfortunately I cannot make these things work. When I write “sudo ./gpsControl -s -d /dev/ttyAMA0” and run, I get this message:
    “Set GPS for stationary mode
    Configuring device /dev/ttyAMA0
    >>>>>>>>>>>>>>>>>>>>> SENDING >>>>>>>>>>>>>>>”

    After that there is no answer and I cannot write any new commands.

  2. “This solution will not give you a standalone off grid NTP server.”

    That’s wrong, NTP is quite capable or working stand-alone without any network connection. You need to mark the NMEA source as “prefer”. You may need an extra “flag1 1” in the fudge for the type 28 ref-clock.


  3. JF Allaire

    I just got the GPS board (January 3rd 2019). My Raspberry Pi 3 B+ just won’t boot when the board is connected to it. As soon as I remove the board, the Pi boots just fine. (of course, I turn off the Pi before I plug or unplug the board)

    Is there something I should have done in the config of the Raspberry Pi before I plug in the board?

    Is there a parameter somewhere that could prevent booting with a certain connection on a pin?

    Or should I just get to the unfortunate conclusion that I received a defective board and will have to return it?

  4. Attach the board the right way up 🙂

  5. Hi David,

    Yes this is correct I will document this shortly!


  6. JF Allaire

    Well, I feel a bit stupid… the “additional headers” thing is actually a spacer this should fit between the raspberry pi and the board. Now I know. Honestly though, what threw me off is the force one as to apply in order to make that thing sit where it should.

    I guess fitting tight is necessary since this is a “solderless” solution…

    Thank very much!

  7. Who's Asking?

    For the record, the hat also works correctly in a Pi 3 A+. I was even able to apply GM8ARV’s various tweaks to make the GPS time server work. Like JF Allaire, I did have the board upside-down at first, but the posts helped me to correct it. It would be advised to have people pay attention to the finished picture and point out that, for reference, the chips, components, and lights should all be facing UP.

  8. Bob Geddes

    in /etc/ntp.conf file
    tos mindis 0.2
    results in error in /var/log/syslog. However:
    tos mindist 0.2
    Suspect missing t in instruction above.

  9. there is an important typo here: you wanted to say:
    tos mindist 0.2
    It’s missing the “t”.

  10. Unfortunately I cannot make these things work. When I write “sudo ./gpsControl -s -d /dev/ttyAMA0” and run, I get this message:
    “Set GPS for stationary mode
    Configuring device /dev/ttyAMA0
    >>>>>>>>>>>>>>>>>>>>> SENDING >>>>>>>>>>>>>>>”

    only thing I can do is to ctrl z to stop it…

    I tried running several times….any help on this?

  11. Hello,

    Thanks for the excellent product and a great tutorial.

    I noticed from the ntpq docs online that “tos mindis 0.2” doesn’t look quite right. Should it be “tos mindist 0.2”?

    I’ll also have a LeoNTP as my primary NTP server- and I have set that as my preferred server for the Raspberry Pi/ GPS Board. However the GPS Board (PPS) signal keeps getting given a “X” in ntp querries (as in not being used. Sometimes the LeoNTP is also being marked as “X” too.

    Any ideas why this might be?

    Lastly, I thought that using IPs directly from the NTP pool (as shown here) was generally not the best policy. They aren’t always public access servers and can be removed without warning in most cases. Any comments perhaps?

    Thanks again for the great products and support.

    Kind Regards,


  12. Michael Fincham

    Well I have been at this for ages, almost feel like giving up and purchasing an NTP dedicated server.

    when I type ntp -p the result I get is Temporary failure in name resolution

  13. Michael Fincham

    This is not working at all, I have followd all the instructions and when it comes to ntpq –p it fails every time

    Please help

  14. Michael Fincham

    About the 5th time I done this now and followed your instructions explicitly and this is the result I get

    source 0 – assert 1552046500.000712440, sequence: 124 – clear 0.000000000, sequence: 0
    source 0 – assert 1552046501.000717752, sequence: 125 – clear 0.000000000, sequence: 0
    source 0 – assert 1552046502.000723168, sequence: 126 – clear 0.000000000, sequence: 0
    source 0 – assert 1552046503.000728272, sequence: 127 – clear 0.000000000, sequence: 0
    [email protected]_MCSLTD:~ $ sudo nano /etc/ntp.conf
    [email protected]_MCSLTD:~ $ sudo service ntp restart
    [email protected]_MCSLTD:~ $
    [email protected]_MCSLTD:~ $ sudo service ntp restart
    [email protected]_MCSLTD:~ $
    [email protected]_MCSLTD:~ $ ntpq –p
    Temporary failure in name resolution
    ntpq> exit
    [email protected]_MCSLTD:~ $

    Any Help would be much appreciated, Thanks

  15. Can someone please tell me if the latest GPS boards have V. 3.01 FW and are Galileo capable? From the current M8Q documentation I believe they should. Thanks.


  16. Anything where the Ublox module ends in -10 can use Galileo. However you need to switch the GNSS mode to use it, by default it does Glonass & GPS only. See CFG-GNSS in manual.

  17. Thats odd, points to more of a DNS issue where it doesn’t know how to resolve its own hostname.

    Check /etc/hosts and make sure you have a localhost entry ?

  18. Can you tell me if your uputronincs board has -10? I got no answer from uputronics but need to order a Galileo-enabled board pretty soon.
    Thank you very much!

  19. We’ve been fitting -10’s for at least a year now probably more.

    See here for the code or use U-Center



  20. Thank you!
    I will order today.

  21. Apologies for no response – I can’t find your mail to us anywhere.

  22. Joren Van Severen

    @Michael: try ntpq -p

  23. I’ve forked Tom Dilatush’s gpsctl (http://www.jamulblog.com/2017/11/paradise-ponders-gpsctl-functionally.html):


    sudo /path.to/gpsctl -a –configure_for_timing

    works for me.

Leave a Comment

NOTE - You can use these HTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

Human test : * Time limit is exhausted. Please reload CAPTCHA.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Trackbacks and Pingbacks: