Howto share GPS and NTP over the Network (local) this is on my boat, off-grid.
The LC29H(AA) GPS HAT can track L1+L5 dual-frequency and multi-GNSS signals, concurrent receiving of GPS, BDS, GLONASS, Galileo and QZSS.
Onboard battery holder, supports ML1220 rechargeable cell, for preserving ephemeris information and hot starts.
The raspberry Pi Zero 2W is used and connected to the local Network to distribute GPS and NTP on my boat.
And Youtube, I am not adding a nice Thumbnail to be used as clickbait in exchange for my phone numer!
I installed 64-bit Raspberry Pi OS Lite Trixie on a 32GB SD card.
Software configuration:
sudo raspi-config
#Interface Options Enable SSH, Localisation Options set Timezone GMT, System Options set Hostname
sudo apt-get update
sudo apt-get upgrade -y
sudo apt autoremove
sudo apt install gpsd gpsd-clients pps-tools chrony jq tcpdump -y
gpsd -V
gpsd: 3.25 (revision 3.25)
sudo raspi-config
#Interface Options/Enable Serial Port, and NO login shell on it
sudo vi /boot/firmware/config.txt
enable_uart=1
dtoverlay=pps-gpio,gpiopin=18
enable_uart=1
init_uart_baud=9600
#Find the following line:
#Additional overlays and parameters are documented /boot/overlays/README
dtoverlay=disable-wifi
sudo vi /etc/modules
pps-gpio
#check for PPS pulses
sudo ppstest /dev/pps0
sudo vi /etc/default/gpsd
Devices gpsd should collect to at boot time.
They need to be read/writeable, either by user gpsd or the group dialout.
Start the gpsd daemon at boot time
START_DAEMON="true"
Devices gpsd should collect to at boot time
OPTIONS=/dev/ttyS0
DEVICES="/dev/pps0"
Other options you want to pass to gpsd
#GPSD_OPTIONS="-n"
Share gpsd daemon on the Network
GPSD_OPTIONS="-n -G"
Automatically hot add/remove USB GPS devices via gpsdctl
USBAUTO="true"
#command to make gpsd start on boot
sudo ln -s /lib/systemd/system/gpsd.service /etc/systemd/system/multi-user.target.wants/
#check status gpsd
sudo systemctl restart gpsd.socket gpsd.service
systemctl status gpsd
#check Network status
sudo netstat -tlnp
sudo systemctl edit --full gpsd.socket
[Unit]
Description=GPS (Global Positioning System) Daemon Sockets
[Socket] for -G
ListenStream=/run/gpsd.sock
ListenStream=[::1]:2947
ListenStream=127.0.0.1:2947
To allow gpsd remote access, start gpsd with the -G option and
uncomment the next two lines:
ListenStream=[::]:2947
ListenStream=0.0.0.0:2947
SocketMode=0600
BindIPv6Only=yes
[Socket]
ListenStream=/run/gpsd.sock
ListenStream=[::1]:2947
ListenStream=127.0.0.1:2947
To allow gpsd remote access, start gpsd with the -G option and
uncomment the next two lines:
ListenStream=[::]:2947
ListenStream=0.0.0.0:2947
SocketMode=0600
BindIPv6Only=yes
[Install]
WantedBy=sockets.target
sudo systemctl restart gpsd.socket gpsd.service
systemctl status gpsd
#Test PPS
sudo ppstest /dev/pps0
#trying PPS source "/dev/pps0"
#found PPS source "/dev/pps0"
#ok, found 1 source(s), now start fetching data...
#source 0 - assert 1767105999.000000687, sequence: 869 - clear 0.000000000, sequence: 0
#On graphical console only!
gpsmon
#show amount satellites used
gpspipe -w | jq ".uSat| select( . != null )"
sudo vi /etc/chrony/chrony.conf
#Add below the pool.ntp.org entry
refclock SHM 0 refid NMEA offset 0.000 precision 1e-3 poll 3 noselect
refclock PPS /dev/pps0 refid PPS lock NMEA poll 3
sudo systemctl restart chrony
#Check chrony
watch -n 1 chronyc sources
with explanation
watch -n 1 chronyc sources -v
watch -n 1 chronyc tracking
sudo vi /etc/chrony/chrony.conf
#allow clients to connect to us, we need a manual directive which enables support at run-time for the settime command in chronyc, if we are offline the say that this is a stratum 1 time server
allow 0.0.0.0/0
manual
local stratum 1
sudo tcpdump -Qin -ni any port 123
#Monitor NTP traffic to see clients are actually using it
#Check the logs
dmesg | egrep 'tty|pps'
#Check if the pps_gpio module is loaded
lsmod | grep pps_gpio
modinfo pps_gpio
#New devices ?
ls -ld /dev/serial? /dev/pps0
#To see some results
sudo ntpshmmon
#See some satellites
cgps -s -u m
“The ocean is everything I want to be. Beautiful, mysterious, wild, and free.”