Monday, March 20, 2017

RPi GPS/NTP for Dashcam System

This is more notes for my future self in case I ever have to get ntp working using a gps time source. The biggest lesson was to wait for a few minutes before giving up on ntp getting the GPS signal.

This is for an Adafruit Ultimate GPS on my Raspberry Pi 2. GPIO 18 is connected to the PPS pin on the GPS. I'm connected to the GPS using a USB to serial adapter.

/etc/udev/rules.d/09-pps.rules
KERNEL=="ttyUSB0", SYMLINK+="gps0"
KERNEL=="pps0", OWNER="root", GROUP="tty", MODE="0777", SYMLINK+="gpspps0"

/etc/ntp.conf
server 127.127.20.0 mode 16 maxpoll 6 prefer
fudge 127.127.20.0 time2 -0.301 flag1 1 refid GPS

/etc/default/gpsd
START_DAEMON="true"

# Use USB hotplugging to add new USB devices automatically to the daemon
USBAUTO="true"

# Devices gpsd should collect to at boot time.
# They need to be read/writeable, either by user gpsd or the group dialout.
DEVICES="/dev/ttyUSB0"

# Other options you want to pass to gpsd
GPSD_OPTIONS="-n -F /var/run/gpsd.sock"

/etc/modules
pps-gpio

/boot/config.txt
dtoverlay=pps-gpio,gpiopin=18