Setting up NTP to update from a GPS

This is just a quick how to to setup NTP to update from a GPS

Installing software needed for the GPS:

# apt-get install gpsd

If you already not done so connect the GPS to your computer you are wanting to run it on and confirm it is connected with lsusb

$ lsusb
Bus 001 Device 003: ID 067b:2303 Prolific Technology, Inc. PL2303 Serial Port

My GPS is a USGlobalSat BU 353

Now to configure gpsd:

# dpkg-reconfigure gpsd

There just a few questions to answer.
First question asks you if you like to have gpsd to start at boot, I answered YES
Second question ask you to were tthe GPS is connected, in my case it was /dev/ttyUSB0
The last 2 questions I just left them as is.

Now to setup up NTP to talk / work with the GPS by editing the /etc/ntp.conf file:

# nano /etc/ntp.conf

This is what I added to my /etc/ntp.conf file:

# LinuxPPS: GPS + PPS (comment out either this whole section or the next one)
server minpoll 4 prefer
fudge flag3 1 flag2 0

# SHM: PPS filtered mean (comment out either this whole section or the previous one)
server minpoll 4 prefer
fudge refid PPS flag3 1

Now we need to restart the ntp server cause the changes we made to the /etc/ntp.conf file

# /etc/init.d/ntp restart
Stopping NTP server: ntpd.
Starting NTP server: ntpd.

To confirm that the ntp server is using the GPS all we have to do is:

$ ntpq -p

And you get and output like this:

$ ntpq -p

     remote           refid      st t when poll reach   delay   offset  jitter
+mirror.dedicate     2 u   52   64   17   55.405    3.643   0.953
+203-80-162-195.     3 u   54   64   17   43.456    2.346   0.880
*a.pool.ntp.uq.e    2 u   51   64   17   57.256    1.722   2.129
+ds001.hostingsh     2 u   50   64   17   55.676    1.890   1.111
xGPS_NMEA(0)     .GPS.            0 l   10   16  377    0.000  -827.80   7.543
 SHM(0)          .PPS.            0 l    -   16    0    0.000    0.000   0.001 .BCST.            16 u    -   64    0    0.000    0.000   0.001 .BCST.            16 u    -   64    0    0.000    0.000   0.001

These couple lines show that the NTP server is using the GPS to update the time:

xGPS_NMEA(0)     .GPS.            0 l    5   16  377    0.000  -827.34   8.128
 SHM(0)          .PPS.            0 l    -   16    0    0.000    0.000   0.001

That is all that is needed to be done, now you don’t need to be connected to the internet to update you NTP server to have the correct time.

NTP Documentation

7 thoughts on “Setting up NTP to update from a GPS”

  1. hate to say it, but that X beside your GPS means it’s being rejected, the * show’s who you are using.


    ntpq -c lassoc

    to see why it’s rejected

    Also, gpsd isn’t needed as you are accessing the gps directly. gpsd can be used if you configure ntp to use shared memory SHM.

    and PPS isn’t working from your output either …

  2. What flavor and version of linux were you running? From the documentation I read the drivers for the receiver only support red hat 7.3,8, 9. Thus, does your solution allow you to use other versions of linux?

    Thank you.

  3. Attempting to setup a stratum 1 server using an acer notebook running Ubuntu desktop 10.04 and the same global sat receiver. I’ve followed your directions, but have a few questions:

    1. When editing the ntp.conf file, should the IP addresses remain the same or be changed to match the IP address the computer which the gps receiver is connected to?
    2. Can this be added anywhere in the ntp.conf file or should it be placed after the commented section “You do need to talk to an NTP server or two (or three).” ?

  4. What flavor and verison of Linux are you running? I’ve followed your instructions on a newly installed Ubuntu 10.04 desktop and I’m getting some errors, but think I’m really close to getting it working.

  5. The ‘x’ next to the GPS_NMEA(0) indicates that the GPS receiver is regarded as a ‘falseticker’ and as a result, will not consider it as a valid time source for the time being. The ‘*’ next to ‘a.pool.ntp.uq.e’ is the server that the computer is currently syncing with.

Leave a Reply