Skip to content

Instantly share code, notes, and snippets.

@jasonmhite
Last active April 13, 2021 22:33
Show Gist options
  • Save jasonmhite/fa82f47efa0a263a674c02814e12e1dd to your computer and use it in GitHub Desktop.
Save jasonmhite/fa82f47efa0a263a674c02814e12e1dd to your computer and use it in GitHub Desktop.
### Time ###
All of this needs to be done as root.
This assumes the GPS module is connected to the 4th channel of the
FT4232H. If it isn't, you need to edit the DEVICES variable below to
point to the correct one. The connections you need to make are:
GPS Pin <--> FT4232 Pin
----------------------------
3.3V No connect
EN No connect
VBAT No connect
FIX No connect
TX DD1
RX DD0
GND GND (doesn't matter which one)
VIN 3V3 (doesn't matter which one)
PPS No connect
Wire those up, then connect the FT4232H to the USB port on the Pitaya.
**DO NOT CONNECT POWER IN TO THE 3.3V PIN NOR THE VBAT PIN ON THE GPS
MODULE! Power should be connected to VIN only.**
Make sure the default timesync daemon is disabled:
systemctl disable systemd-timesyncd
Run:
apt-get update
apt-get install gpsd chrony gpsd-clients
Replace the contents of /etc/default/gpsd with:
START_DAEMON="true"
DEVICES="/dev/ttyUSB3"
GPSD_OPTIONS="-n"
Replace contents of /etc/chrony/chrony.conf with:
refclock SHM 0 refid NMEA trust
keyfile /etc/chrony/chrony.keys
commandkey 1
driftfile /var/lib/chrony/chrony.drift
logdir /var/log/chrony
maxupdateskew 100.0
makestep 0.1 -1
hwclockfile /etc/adjtime
rtcsync
Note: when I say replace, I mean delete the current contents and replace
them with what I showed. Both of these files should exist already.
Restart the two services:
systemctl restart gpsd
systemctl restart chrony
Make sure they started without errors:
systemctl status gpsd
systemctl status chrony
If all is well, make sure they are set to run at boot:
systemctl enable gpsd
systemctl enable chrony
Can view GPS status with:
gpsmon
Can view the synchronization information with
chronyc sources
and detailed statistics with
chronyc sourcestats
Can check time with:
timedatectl
Time zone will be UTC! This is easiest, otherwise you'd have to
change it if you took the detectors somewhere. If you really want to
change the timezone:
timedatectl list-timezones
to list the available ones, then
timedatectl set-timezone xxx
where xxx is the timezone you want from the output of the first command.
EST is "America/New_York".
One final note: GPS time does not include leap seconds. Chrony can be set
up to correct for leap seconds, but I have not done this. See the
`leapsecmode` section of `man chrony.conf`. At present, this means
that GPS time is ahead of UTC by 17 seconds. I did not enable this because
it requires manually updating the leap seconds record whenever a new one
is added. It shouldn't really matter, because all the detectors will still be
synchronized to the same time (within a few ms), which is all that matters.
### Position ###
Again, all as root. The library for GPSD requires Python3. See
https://github.com/MartijnBraam/gpsd-py3
for info.
Run:
apt-get update
apt-get install python3 python3-pip
pip3 install gpsd-py3
Simple example:
import gpsd
gpsd.connect()
packet = gpsd.get_current()
print(packet.position)
Remember it's Python3, so this must be run with `python3`, not `python`.
I don't think this script needs to be run as root, but I'm not sure.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment