Hello,
Got myself a cheap GPS module that I’ve hooked up to my Raspberry Pi 3’s GPIO pins for serial and PPS.
Spent a lot of time getting it working, rearranging the cables for the different GPIO pins to get it right, and trying to power the GPS module using USB for troubleshooting. Turns out, the GPS module can do NMEA over USB as well, and the time Chrony receives over GPIO is >100ms off, while it seems about right over USB. How can that be? Am I doing something wrong?
chronyc -n sources
MS Name/IP address Stratum Poll Reach LastRx Last sample
===============================================================================
#x GPIO 0 4 377 19 +126ms[ +126ms] +/- 401us
#+ USB 0 4 377 20 +40ns[ +129ns] +/- 817ns
#* PPS 0 4 377 20 +40ns[ +129ns] +/- 817ns
^? 192.168.50.201 2 6 377 435 -92us[ -92us] +/- 4445us
^? 192.168.50.1 3 6 377 54 +2356us[+2356us] +/- 23ms
^? 185.175.56.95 2 6 377 46 +5935us[+5935us] +/- 11ms
^? 185.175.56.208 2 6 377 45 +6133us[+6133us] +/- 10ms
relevant bits of chrony.conf
refclock SHM 0 refid GPIO
refclock SHM 2 refid USB trust
refclock PPS /dev/pps0 refid PPS lock USB trust
bits from /boot/config.txt
# Uncomment some or all of these to enable the optional hardware interfaces
#dtparam=i2c_arm=on
#dtparam=i2s=on
dtparam=spi=on
# Uncomment this to enable infrared communication.
#dtoverlay=gpio-ir,gpio_pin=17
#dtoverlay=gpio-ir-tx,gpio_pin=18
dtoverlay=disable-bt
[all]
# the next 3 lines are for GPS PPS signals
dtoverlay=pps-gpio,gpiopin=18
enable_uart=1
init_uart_baud=9600
/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_DAEMON="true"
DEVICES="/dev/ttyAMA0 /dev/pps0"
# Other options you want to pass to gpsd
GPSD_OPTIONS="-n"
# Automatically hot add/remove USB GPS devices via gpsdctl
USBAUTO="true"