who need this tutorial: everyone that want an accurate clock on their system in nano second accuracy, more accurate comparing clock from internet - NTP (milisecond)
i run this tutorial on raspberry pi, but it should be work for any linux distro and pc.
first time hear gpsdo term (not direct related, because what i do is discipline for local clock, not related with oscilator hardware for sdr) from @pe0sat post . first time know about Pulse Per Second (PPS) from @pierros satnogs optical
then yesterday im searching on youtube and found this and that videos
based on both videos i setup my gpsd and pps clock.
i use raspberry pi 4
for gpio scheme check here
the main hardware in this tutorial is gps module.
i use neo-7m gps module
as you can see this module dont have pps pin. (only gnd, txd, rxd, and vcc 5v). but dont worry, searching on internet, you can get the pps pin with just soldering a wire to pin number 3 of the gps chip, or just before the led. here i zoom out:
if you have the gps module that complete with pps pin, that will better and make your life easier.
okay before connect the module to your raspberry pi,
run this command first
install the software
sudo apt install screen gpsd pps-tools
enable serial
sudo raspi-config
select interface
select serial
**the serial login shell is disabled**
**the serial interface is enabled**
add your raspberry pi user to dialout group:
sudo usermod -aG dialout your_username
sudo systemctl stop serial-getty@ttyAMA0.service
sudo systemctl disable serial-getty@ttyAMA0.service
enable PPS :
nano /etc/modules
put this line:
pps-gpio
nano /boot/firmware/config.txt
put this line
# enable PPS on GPIO18
dtoverlay=pps-gpio,gpiopin=18
restart your raspberry
now connect the gps module to your raspberry pi pin.
look this diagram
we only need this:
gnd on module to ground on raspi (6)
vcc on module to 5v power on raspi (4)
txd on module to rxd on raspi (10)
rxd on module to txd on raspi (8)
pps on module to pcm_clk on raspi (12)
you will see the led power is on.
i modify the gps antenna , change the ufl connector to rp-sma connector, then extend with coaxial cable around 3 metre, so i can put it on outside. i put the antenna on used plastic box. on gps module i also add and soldering the rp-sma connector, that i take and desolder from other board (broken lna board).
if you see the usb on central and right picture, dont be confused. that is what i use just to test it on pc , the usb is usb ttl (usb to serial). you dont need it on raspberry.
the gray cable is pps wire.
detect the gps:
sudo gpsctl -n -f /dev/serial0
output:
/dev/serial0 identified as a u-blox SW 7.03 (42969),HW 00040007 at 9600 baud
now check if gps module work, just type this command:
sudo cat /dev/serial0
or
screen /dev/serial0 9600
or
sudo gpsmon /dev/serial0
and you will see running text like
$GPRMC,...$GPGGA,...
that we called NMEA serial message
now test the PPS
sudo ppstest /dev/pps0
you will see response like this:
ok, found 1 source(s), now start fetching data...
source 0 - assert xxxx, sequence: xxxx - clear 0.000000000, sequence: 0
now setup the clock
sudo nano /etc/default/gpsd
change:
DEVICES="/dev/serial0 /dev/pps0"
USBAUTO="false"
GPSD_OPTIONS="-n"
GPSD_OPTIONS=“-n” tells gpsd to start reading from the GPS device immediately, even when no client program such cgps or gpsmon is connected.
run the gpsd services:
sudo systemctl enable gpsd
sudo systemctl start gpsd
install main software, chrony. this app will replace the old clock system.
sudo apt install chrony
sudo nano /etc/chrony/chrony.conf
give comment on ntp line like this one
# Use Debian vendor zone.
# pool 2.debian.pool.ntp.org iburst
add or update with this line
makestep 0.1 -1
initstepslew 1.0 GPS
refclock SHM 0 delay 0.2 refid GPS poll 4 noselect
refclock PPS /dev/pps0 refid PPS lock GPS poll 4 prefer
this setup will force raspberry to only get the clock from PPS.
restart the chrony
sudo systemctl restart chrony
check the crony :
chronyc sources -v
chronyc tracking
finish!!
troubleshot:
to make the gps module get signal and data from gps satellite, it ussualy take some minutes. on my case ussualy around 5 to 10 minutes. you can see if it got the satellite, the pps led will blink on. (green light on my device).
or you can just run this command to check
cgps -s
if until 30 minutes you dont get the gps signal, make sure :
your gps antenna is connected
the antenna facing to up
put the antenna minimum beside window that can see the sky
make sure the antenna is not broken. in my case the cable inside antena is disconnected. what i do is open the metal case of antenna and soldering back. you can check with your avometer to check if the antenna is not broken.











