Ben's notes

Linux, Unix, network, radio...

User Tools

Site Tools


dragino_lora_gps_hat_ntp

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
dragino_lora_gps_hat_ntp [2019/03/17 18:54] – [Configure GPS] admindragino_lora_gps_hat_ntp [2021/10/09 15:14] (current) – external edit 127.0.0.1
Line 1: Line 1:
-=====Dragino LoRa / GPS hat - NTP PPS===== +=====Raspberry Pi, Dragino LoRa / GPS hat - NTP PPS===== 
-Configure NTPd with PPS+Configure NTPd with PPS. Based on Raspbian Stretch. 
 + 
 +**Notes:** 
 +  * Could not get PPS to work with the new refclock driver 46, GPSD NG client protocol. Switched to PPS (22) and SHM (28). 
 +  * GPSd did not auto start at boot, added the driver above with ''noselect'' to get GPSd to start. 
 + 
 +**Sources:** 
 +  * [[https://www.eecis.udel.edu/~mills/ntp/html/refclock.html]] 
 +  * [[https://www.slsmk.com/how-to-setup-a-gps-pps-ntp-time-server-on-raspberry-pi/]]
  
 {{:lora_gps_hat1.png?400|}} {{:lora_gps_hat1.png?400|}}
Line 19: Line 27:
   * Reboot   * Reboot
   * Test GPS output: ''cat /dev/serial0''   * Test GPS output: ''cat /dev/serial0''
- +====Configure Pulse Per Second (PPS)==== 
-====Configure GPS==== +  * Install PPS tools:<code>apt install pps-tools setserial</code> 
-  * Install packages:<code>apt install gpsd gpsd-clients</code>+  * Configure GPIO for PPS:<code>echo "dtoverlay=pps-gpio,gpiopin=18" >> /boot/config.txt</code>
   * Configure udev rules in ''/etc/udev/rules.d/gps.rules''<code>   * Configure udev rules in ''/etc/udev/rules.d/gps.rules''<code>
-KERNEL=="ttyAMA0", SUBSYSTEM=="tty", DRIVER=="", SYMLINK+="gps0", MODE="0666+KERNEL=="ttyAMA0", RUN+="/bin/setserial /dev/ttyAMA0 low_latency" 
-KERNEL=="pps0", SUBSYSTEM=="pps", DRIVER=="", SYMLINK+="gpspps0", MODE="0666"+KERNEL=="ttyAMA0", SYMLINK+="gps0" 
 +KERNEL=="pps0", GROUP="dialout", MODE="0660"
 </code> </code>
-  * Configure device in ''/etc/default/gpsd''<code>DEVICES="/dev/ttyAMA0 /dev/pps0"</code> 
-  * Reboot 
-  * Test GPS output with ''cgps'' or ''gpsmon''. 
-====Configure Pulse Per Second (PPS)==== 
-  * Install PPS tools:<code>apt install pps-tools</code> 
-  * Configure GPIO for PPS:<code>echo "dtoverlay=pps-gpio,gpiopin=18" >> /boot/config.txt</code> 
   * Reboot   * Reboot
   * There should be a ''/dev/pps0'' device   * There should be a ''/dev/pps0'' device
Line 45: Line 48:
 source 0 - assert 1552847116.000137416, sequence: 157 - clear  0.000000000, sequence: 0 source 0 - assert 1552847116.000137416, sequence: 157 - clear  0.000000000, sequence: 0
 </code> </code>
 +====Configure GPdS====
 +  * Install packages:<code>apt install gpsd gpsd-clients</code>
 +  * Configure devices and options in ''/etc/default/gpsd''<code>DEVICES="/dev/ttyAMA0"
 +GPSD_OPTIONS="-n"
 +</code>
 +  * Reboot
 +  * Test GPS output with ''cgps'' or ''gpsmon''.
 +
 ====Configure NTPd==== ====Configure NTPd====
   * Disable systemd timesyncd:<code>systemctl stop systemd-timesyncd   * Disable systemd timesyncd:<code>systemctl stop systemd-timesyncd
 systemctl disable systemd-timesyncd</code> systemctl disable systemd-timesyncd</code>
-  * Install NTP:<code>apt install ntp</code>+  * Install required packages:<code>sudo apt install libcap-dev</code> 
 +  * Install NTP:<code> 
 +# Download latest from http://www.ntp.org/downloads.html 
 +curl -OL http://www.eecis.udel.edu/~ntp/ntp_spool/ntp4/ntp-4.2/ntp-4.2.8p13.tar.gz 
 +tar zxvf ntp-4.2.8p13.tar.gz 
 +cd ntp-4.2.8p13 
 +./configure --enable-linuxcaps 
 +make -j4 
 +sudo make install 
 + 
 +sudo cp /home/user/ntp-4.2.8p13/scripts/rc/ntpd /etc/init.d/ 
 +# Modify ntpd location in /etc/init.d/ntpd, and add lines below above variables. 
 + 
 +### BEGIN INIT INFO 
 +# Provides:             ntpd 
 +# Default-Start:        2 3 4 5 
 +# Default-Stop: 
 +# Short-Description:    NTPD 
 +### END INIT INFO 
 + 
 + 
 +groupadd ntp 
 +useradd -d /var/lib/ntp -g ntp -s /bin/false ntp 
 +printf 'PATH=${PATH}:/usr/local/bin\n' > /etc/profile.d/ntp-path.sh 
 +install -v -o ntp -g ntp -d /var/lib/ntp 
 + 
 +systemctl enable ntpd 
 + 
 +</code>
   * Add to ''/etc/ntp.conf''<code>   * Add to ''/etc/ntp.conf''<code>
-# GPS Serial +# PPS 
-server 127.127.28.0 +server 127.127.22.0 minpoll 4 maxpoll 4 true 
-fudge 127.127.28.0 time1 refid GPS+fudge 127.127.22.0 flag3 1 refid PPS 
 + 
 +# GPS Serial, GPSD SHM 
 +server 127.127.28.0 minpoll 4 maxpoll 4 iburst prefer 
 +fudge 127.127.28.0 flag1 1 time1 0.200 refid SHM0 stratum 1 
 + 
 +# PPS, GPSD SHM 
 +server 127.127.28.2 minpoll 4 maxpoll 4 
 +fudge 127.127.28.2 flag1 1 refid SHM2 
 + 
 +# GPSD JSON driver, to auto start GPSD 
 +server 127.127.46.0 minpoll 4 maxpoll 4 noselect
  
-GPS PPS +Fix False tickers 
-server 127.127.28.1 prefer +tos mindist 0.5
-fudge 127.127.28.1 refid PPS+
 </code> </code>
   * Enable and start ntpd:<code>systemctl enable ntp   * Enable and start ntpd:<code>systemctl enable ntp
dragino_lora_gps_hat_ntp.1552848861.txt.gz · Last modified: 2019/03/17 18:54 by admin