UPDATE: My only GPS-based time
server is now running on a tiny Raspberry
Pi Zero 2 W computer! Here is the pinout of
that board: |
Here are the connections required
between the Raspberry Pi Zero 2 W board and the u-blox
NEO-6M GPS Module (note that the TXD pin of the
GPS board connects to the UART RX of the Pi, and the RXD
pin of the GPS board connects to the UART TX of the Pi):
|
If everything is working OK, and a PPS lock has been established (sometimes tricky inside my home), this text will show the current 'chrony' statistics results: |
Here is some Linux 'cgps' position
tracking statistics when connected to the GPS satellites: |
┌───────────────────────────────────────────┐┌──────────────────Seen
16/Used 10┐ │ Time: 2024-03-27T16:17:56.000Z (18)││GNSS PRN Elev Azim SNR Use│ │ Latitude: xx.18374174 N ││GP 2 2 37.0 105.0 12.0 Y │ │ Longitude: xx.12526860 W ││GP 7 7 47.0 150.0 28.0 Y │ │ Alt (HAE, MSL): 300.345, 326.047 m ││GP 8 8 28.0 52.0 26.0 Y │ │ Speed: 0.28 km/h ││GP 13 13 36.0 288.0 31.0 Y │ │ Track (true, var): 224.5, 3.6 deg ││GP 14 14 67.0 284.0 21.0 Y │ │ Climb: -5.88 m/min ││GP 15 15 16.0 315.0 26.0 Y │ │ Status: 3D FIX (9 secs) ││GP 17 17 36.0 208.0 30.0 Y │ │ Long Err (XDOP, EPX): 0.53, +/- 8.0 m ││GP 21 21 37.0 84.0 29.0 Y │ │ Lat Err (YDOP, EPY): 0.88, +/- 13.2 m ││GP 22 22 46.0 273.0 27.0 Y │ │ Alt Err (VDOP, EPV): 1.93, +/- 44.8 m ││GP 30 30 75.0 199.0 24.0 Y │ │ 2D Err (HDOP, CEP): 1.03, +/- 20.3 m ││GP 1 1 n/a 0.0 0.0 N │ │ 3D Err (PDOP, SEP): 2.19, +/- 42.2 m ││GP 10 10 0.0 28.0 0.0 N │ │ Time Err (TDOP): 1.28 ││GP 19 19 9.0 214.0 0.0 N │ │ Geo Err (GDOP): 2.54 ││GP 23 23 1.0 356.0 16.0 N │ │ ECEF X, VX: -590394.040 m -0.030 m/s ││SB133 46 34.0 179.0 0.0 N │ │ ECEF Y, VY: -4135253.440 m 0.000 m/s ││SB138 51 33.0 192.0 0.0 N │ │ ECEF Z, VZ: 4804167.050 m 0.090 m/s ││ │ │ Speed Err (EPS): +/- 3.7 km/h ││ │ │ Track Err (EPD): n/a ││ │ │ Time offset: 0.357281442 s ││ │ │ Grid Square: EN09we44 ││ │ └───────────────────────────────────────────┘└─────────────────────────────────┘ |
Here is a Linux 'inxi' hardware
report from this board: |
System: Host:
raspberrypi Kernel: 5.10.63-v7+ armv7l bits: 32 Console:
tty 0 Distro: Raspbian GNU/Linux 11 (bullseye) Machine: Type: ARM Device System: Raspberry Pi Zero 2 Rev 1.0 details: BCM2835 rev: 902120 serial: 00000000655a270f Memory: RAM: total: 491.6 MiB used: 188.4 MiB (38.3%) gpu: 64 MiB RAM Report: unknown-error: Unknown dmidecode error. Unable to generate data. CPU: Info: Quad Core model: ARMv7 v7l variant: cortex-a53 bits: 32 type: MCP Speed: 600 MHz min/max: 600/1000 MHz Core speeds (MHz): 1: 600 2: 600 3: 600 4: 600 Graphics: Device-1: bcm2835-hdmi driver: vc4_hdmi v: N/A Device-2: bcm2835-vc4 driver: vc4_drm v: N/A Display: server: No display server data found. Headless machine? tty: 238x55 Message: Advanced graphics data unavailable in console for root. Audio: Device-1: bcm2835-hdmi driver: vc4_hdmi Device-2: bcm2835-audio driver: bcm2835_audio Sound Server: ALSA v: k5.10.63-v7+ Network: Message: No ARM data found for this feature. IF-ID-1: wlan0 state: up mac: e4:5f:01:5b:3c:55 Drives: Local Storage: total: 14.67 GiB used: 3.86 GiB (26.3%) ID-1: /dev/mmcblk0 vendor: Transcend model: USDU1 size: 14.67 GiB Partition: ID-1: / size: 14.16 GiB used: 3.82 GiB (27.0%) fs: ext4 dev: /dev/mmcblk0p2 ID-2: /boot size: 252 MiB used: 48.1 MiB (19.1%) fs: vfat dev: /dev/mmcblk0p1 Swap: ID-1: swap-1 type: file size: 100 MiB used: 9.8 MiB (9.8%) file: /var/swap Sensors: System Temperatures: cpu: 42.4 C mobo: N/A Fan Speeds (RPM): N/A Info: Processes: 117 Uptime: 3d 23h 49m Init: systemd runlevel: 5 Shell: Bash inxi: 3.3.01 |
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:
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*61Here 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 jitterIn 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? UPDATE: After upgrading my Raspberry Pi linux version to Raspbian/Debian 9 'Stretch', my GPS/PPS functionality stopped working -- which I have now finally fixed by doing the following -- since I found out that the '/dev/ttyAMA0' device was being used by the 'login' process, which was interferring with 'ntp' from getting at it as well:
I also did the following, but was not sure whether it
was necessary or helped: UPDATE: I also activated the same feature on my backup server: an Orange Pi PC Plus (info here, purchased here and here). I chose this particular model since it was the best 'bang-for-the-buck' that I could find in the Orange Pi series, was less expensive than the boards offered by the Raspberry Pi foundation, and had an 8GB eMMC flash memory module on it (to avoid eventual wear-out of removable SD cards). A good resource comparing the various Orange Pi models is here.systemctl stop serial-getty@ttyAMA0.service systemctl disable serial-getty@ttyAMA0.service systemctl mask serial-getty@ttyAMA0.service The wiring for the GPS module that I
used is as follows:
Currently the 'best' source of Linux distros for the Orange Pi boards comes from Armbian, rather than from the manufacturer itself (which provides almost no support, and with non-100%-functional software!). A useful discussion forum for the Allwinner H3 boards with mainline Linux kernel is here.
ORANGE PI PLUS H3 with GPS/PPS – — The Black Magic Boxes
In order for the NTP logging to work properly, the directory '/var/log/ntp' needs to be created for every reboot, and with the correct (open) permissions. Add the following to '/etc/rc.local':
# Default settings for the gpsd init script and the hotplug wrapper.
sudo service gpsd start |