GPS Timesync Raspberry Pi on demand


When operating digital modes like FT8 or JS8Call in the field, timing is everything. If your system clock is off by just a second or two, your QSOs will fail. This guide shows you how to turn a GPS source into a high-precision Stratum-1 time source for your Pi—without messing up your existing setup or creating conflicts with other USB devices like the DigiRig or LiNK500.


Before you dive into this blog post, I recommend reading the following blog post first: https://dl1gkk.com/raspberry-pi-ham-radio-best-practice-2026


Hardware Options:

  • USB GPS Stick: A simple u-blox 7 USB stick.
  • LiNK500 Interface: Use the built-in GPS module by connecting a GPS antenna.

Step 1: “Pinning” the Hardware (udev Rule)

To avoid the “USB port lottery” where your device might jump between /dev/ttyACM0 and /dev/ttyACM1, we create a permanent alias.

  1. Identify your device:
    lsusb
    Look for ID 1546:01a7 (standard for u-blox 7).
  2. Create the rule file:
    sudo nano /etc/udev/rules.d/99-gps-device.rules
  3. Paste this exact line:
    KERNEL=="ttyACM*", ATTRS{idVendor}=="1546", ATTRS{idProduct}=="01a7", SYMLINK+="gps-device"
  4. Save and exit (Ctrl+O, Enter, Ctrl+X), then activate:
    sudo udevadm control --reload-rules && sudo udevadm trigger

Check: ls -l /dev/gps-device should now point to your ttyACM device.

Step 2: Installing the Tools

We use gpsd for the data and chrony to manage the clock.

sudo apt update
sudo apt install gpsd gpsd-clients chrony -y

Disable the automatic start to keep the system clean when no stick is plugged in:

sudo systemctl stop gpsd.socket
sudo systemctl disable gpsd.socket

Step 3: Configuring Chrony

  1. Open config: sudo nano /etc/chrony/chrony.conf
  2. Add these lines to the very end of the file:
    # GPSD shared memory driver for time sync
    refclock SHM 0 poll 2 refid GPS precision 1e-1 offset 0.1 delay 0.2
    
    # Allow immediate time jumps
    makestep 1.0 3
  3. Restart chrony: sudo systemctl restart chrony

Step 4: The “Sync Button” Script

  1. Create the script: nano ~/gps-sync.sh
  2. Paste the following code:
    #!/bin/bash
    echo "--- GPS Time Sync (Handwerker-Style) ---"
    
    # Clean up
    sudo killall gpsd 2>/dev/null
    
    # Check for device
    if [ ! -L /dev/gps-device ]; then
        echo "ERROR: GPS device (/dev/gps-device) not found!"
        exit 1
    fi
    
    # Start GPSD
    echo "Starting GPS service at /dev/gps-device..."
    sudo gpsd /dev/gps-device -F /var/run/gpsd.sock
    
    echo "Waiting for GPS Fix... (Needs clear view of sky)"
    
    # Wait for valid data
    timeout 60 gpspipe -w | grep -m 1 "TPV" > /dev/null
    
    if [ $? -eq 0 ]; then
        echo "GPS Fix OK! Syncing system time..."
        sudo chronyc makestep
        echo "--- SUCCESS: Time is synchronized! ---"
        echo ""
        echo "Current GPS Data (Press 'q' to exit):"
        sleep 2
        cgps -s
    else
        echo "TIMEOUT: No GPS fix after 60 seconds."
    fi
  3. Make it executable: chmod +x ~/gps-sync.sh

Step 5: The Menu Entry

To start the sync conveniently from your desktop menu:

  1. Create the desktop file: nano ~/.local/share/applications/gps-sync.desktop
  2. Paste the following content:
    [Desktop Entry]
    Name=GPS Time Sync
    Comment=Sync system time via GPS
    Exec=lxterminal -e "bash -c '/home/pi/gps-sync.sh; echo; echo Press any key to close...; read -n 1'"
    Icon=preferences-system-time
    Terminal=false
    Type=Application
    Categories=Utility;HamRadio;

    (Note: Verify if your user path is /home/pi/ or adjust accordingly.)

How to use it

  • At Home: Chrony uses your Internet connection automatically. No manual action required.
  • Off-Grid: Plug in the GPS (or connect antenna to LiNK500), click the icon in the menu, and wait for the “SUCCESS” message. Once your coordinates appear, press ‘q’ and start your Ham Radio software.

Disclaimer: This setup was developed in collaboration with Gemini AI. While we’ve worked hard to make this guide as “bulletproof” as possible, tech is always evolving—errors may occur, or specific functions might need a bit of extra tweaking.

The solution? Don’t hesitate to ask Gemini yourself if you get stuck. Good luck with your build!


GPS Timesync Info