Pi OS 12 M8T - BYO-NTP/recipes GitHub Wiki

date server os gnss daemon 🎯 🗣️
2025-05 Raspberry Pi 4
Raspberry Pi 5
Pi OS
12
Huawei WD22UGRC
u-blox LEA-M8T
chrony
NTPsec
ntp
0.4 µs
0.4 µs
discuss

Pi 5 with Huawei WD22UGRC attached

1. Install OS

Install Pi OS 12.

2. Configure the LEA-M8T

There's a Bill of Materials and assembly instructions below.

2.1 Program the GNSS

There are two ways:

  • Use gpsctl
  • Connect to a Windows computer with u-blox u-center installed. Configure per the recommendations on the gnss page.

3. Configure the UART

Liberate the serial port from the console:

raspi-config nonint do_serial_cons 0
raspi-config nonint do_serial_hw 1
systemctl disable --now [email protected]
systemctl mask [email protected]

Create a symlink to /dev/gps0, and enable low_latency on the serial port:

apt install -y setserial
cat > /etc/udev/rules.d/10-gps.rules <<EOL
# symlink /dev/ttyAMA0 to /dev/gps0
KERNEL=="ttyAMA0", SYMLINK+="gps0", GROUP="dialout", MODE="0660"

# configure the serial port for low latency.
KERNEL=="ttyAMA0", RUN+="/bin/setserial /dev/ttyAMA0 low_latency"
EOL

udevadm control --reload-rules

4. Enable PPS

apt install -y pps-tools
grep -q pps-gpio /boot/firmware/config.txt || cat >> /boot/firmware/config.txt <<EOWD

# Huawei WD22UGRC board w/LEA-M8T
dtoverlay=pps-gpio,gpiopin=18
enable_uart=1

EOWD
reboot

Verify that the PPS module loaded:

lsmod | grep pps
pps_gpio               12288  0

Test that PPS pulses are present (Control-C to cancel):

ppstest /dev/pps0
trying PPS source "/dev/pps0"
found PPS source "/dev/pps0"
ok, found 1 source(s), now start fetching data...
source 0 - assert 1747026175.000003161, sequence: 4756 - clear  1747023968.100025259, sequence: 2549
source 0 - assert 1747026176.000000660, sequence: 4757 - clear  1747023968.100025259, sequence: 2549
^C

Note that if your GPS hasn't got a fix yet, you may need to wait up to 20 minutes before you get PPS output.

5. Install a NTP daemon

Each section heading is a link with many more details about installing, configuring, and verifying that particular NTP daemon.

export NTP_REFCLOCKS=$(cat <<EO_CHRONY
refclock SHM 0         refid NMEA precision 0.03 poll 2 offset 0.120
refclock PPS /dev/pps0 refid PPS  precision 4e-7 poll 2 lock NMEA trust
EO_CHRONY
)
curl -sS https://byo-ntp.github.io/tools/chrony/install.sh | sh
export NTP_REFCLOCKS=$(cat <<EO_NTPSEC
refclock nmea refid NMEA minpoll 3 maxpoll 4 time2 0.125 prefer mode 8 baud 115200
refclock pps  refid PPS  minpoll 1 maxpoll 2
EO_NTPSEC
)
curl -sS https://byo-ntp.github.io/tools/ntpsec/install.sh | sh
export NTP_REFCLOCKS=$(cat <<EO_NTP
server 127.127.20.0 mode 88 minpoll 3 maxpoll 4 prefer
fudge  127.127.20.0 refid NMEA time2 0.115 minjitter 0.003

server 127.127.22.0 minpoll 3 maxpoll 4
fudge  127.127.22.0 refid PPS
EO_NTP
)
curl -sS https://byo-ntp.github.io/tools/ntp/install.sh | sh

Observe

  • watch the status in near real time:
    • printf '\e[8;9;80t'; ssh -t pi5 watch -n2 chronyc sources
    • printf '\e[8;9;80t'; ssh -t pi5 watch -n2 ntpq -c peer
  • Measure the offset
  • Gather statistics with telegraf + influxdb + grafana or similar.

References

Bill of Materials

Item Vendor(s) Cost
Huawei WD22UGRC GPS module eBay $25
SMA-F to SMB-F connector Amzn $5
Active GPS Antenna, 30dB gain Amzn $11
2P-F to 1P-F 2mm to 2.54mm Jumper wires Amzn $8
Total $49

Assembly

The Huawei GNSS module has a LEA-M8T chip which supports GPS, Galileo, Beidou, and GLONASS.

This photo shows the pinouts on the board. Note that you MUST cross the TxD and RxD pins. If the module isn't spewing data, check that the pins are crossed.

Pins: 1 ANT 3V3, 2 3V3/VCC, 3 TXD, 4 NC, 5 RXD, 6 TP1/1PPS, 7 NC TP2, 8 GND

For science, and because my antenna said 3-5v, I also tested connecting 5V to the antenna pin and it works great!

Fully assembled:

Performance

Chrony

NTPsec

ntp

⚠️ **GitHub.com Fallback** ⚠️