PNG
        timeserver logo
JPG rpi 2 model
                b
JPG
                ublox neo-6m gps


PNG rpi 2 model b pinout

The primary reason that I had originally purchased my first Raspberry Pi 2 Model B SBC (Single Board Computer) was to operate my Flight Tracking Station.

With the prices of GPS modules dropping to extremely affordable levels (about $4 CDN), I decided to swap out the U-Blox NEO-6M GPS module for one that had a 5th pin -- a PPS (Pulse-Per-Second) contact that I could use to implement a high-accuracy NTP (Network Time Protocol)  stratum 1 time server!  In other words, using the primary (stratum 0) time clock sources available on GPS satellites to make my own secondary (stratum 1) shareable computer time source.

My primary source of information on how to do this came from these excellent sources:

Setting up a Stratum 1 NTP server on a Raspberry Pi
The Raspberry Pi as a Stratum-1 NTP Server
GPSD Time Service HOWTO
A Guide To GPS Network Time Synchronization

The wiring for the GPS module that I used is as follows:

NEO-6M
Raspberry Pi
VCC
3V3
GND
GND
RXD
TXD (GPIO14)
TXD
  RXD (GPIO15)
PPS
PWM0 (GPIO18)

Power (VCC/3V3) and Ground (GND) pins are basic.  The Receive-Data (RXD) and Transmit-Data (TXD) are used to receive and transmit the serial-based GPS data stream (notice that reversal when connecting the pins i.e. the GPS 'transmit' pin is connected to the Raspberry Pi 'receive' pin, and vice versa).  The magic comes from the Pulse-Per-Second (PPS) GPS pin being connected to the Raspberry Pi Pulse-Code-Modulation (PCM) pin (also acting as Pulse-Width-Modulation (PWM0)).

When a good GPS satellites lock has been achieved, my GPS will transmit useful time (as well as position) data (at 9600 baud) using various NMEA sentence structures.  The one that the NTP utility uses to extract time are the following:
$GPRMC,POS_UTC,POS_STAT,LAT,LAT_REF,LON,LON_REF,SPD,HDG,DATE,MAG_VAR,MAG_REF*CC<cr><lf>
$GPGLL,LAT,LAT_REF,LONG,LONG_REF,POS_UTC,POS_STAT*CC<cr><lf>
$GPGGA,POS_UTC,LAT,LAT_REF,LONG,LONG_REF,FIX_MODE,SAT_USED,HDOP,ALT,ALT_UNIT,GEO,G_UNIT,D_AGE,D_REF*CC<cr><lf>
Here are some samples of those sentences from my GPS (with position information obscured):
$GPRMC,195038.00,A,xx11.02333,N,xxx07.52859,W,0.052,,140817,,,A*61
$GPGLL,xx11.02333,N,xxx07.52866,W,195037.00,A,A*77
$GPGGA,195038.00,4911.02333,N,09807.52859,W,1,08,1.06,341.9,M,-26.1,M,,*69
Here is a sample NTP time statistics from my time server soon after it was running:
pi@raspberrypi ~ $ ntpq -p 
     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
 LOCAL(0)        .LOCL.          10 l  45h   64    0    0.000    0.000   0.000
oGPS_NMEA(0)     .GPS.            0 l    8   16  377    0.000    0.003   0.002
*192.95.27.155   200.98.196.212   2 u   37   64  377   51.341    1.001 166.392
+kirdu.smartacti 213.251.128.249  2 u    3   64   77   42.552   10.272  99.637
+host1.hosttechn 213.251.128.249  2 u   20   64  377   38.465   10.301 161.560
+zero.gotroot.ca 30.114.5.31      2 u   65   64  376   34.556    0.719  52.451
In this sample, the GPS source is providing a time accuracy of 0.003 microseconds (3 millionths of a second) to my computer network!  This time source is good enough to join (if I chose to do so) the list of other NTP time sources used by millions of computers around the world: How do I join pool.ntp.org?

If working properly, here are the latest NTP stats from the time server:
Embedded Text Document