{"id":23057107,"url":"https://github.com/geerlingguy/time-pi","last_synced_at":"2026-03-02T05:04:51.105Z","repository":{"id":267974618,"uuid":"902937362","full_name":"geerlingguy/time-pi","owner":"geerlingguy","description":"Raspberry Pi stratum 1 PTP and NTP timeserver configuration.","archived":false,"fork":false,"pushed_at":"2026-02-25T22:16:33.000Z","size":2061,"stargazers_count":219,"open_issues_count":8,"forks_count":9,"subscribers_count":9,"default_branch":"master","last_synced_at":"2026-02-26T00:38:04.316Z","etag":null,"topics":["gps","ntp","ptp","raspberry-pi","time","time-server"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/geerlingguy.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null},"funding":{"github":"geerlingguy","patreon":"geerlingguy"}},"created_at":"2024-12-13T15:22:25.000Z","updated_at":"2026-02-25T22:16:37.000Z","dependencies_parsed_at":"2026-01-07T01:01:54.150Z","dependency_job_id":null,"html_url":"https://github.com/geerlingguy/time-pi","commit_stats":null,"previous_names":["geerlingguy/time-pi"],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/geerlingguy/time-pi","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/geerlingguy%2Ftime-pi","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/geerlingguy%2Ftime-pi/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/geerlingguy%2Ftime-pi/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/geerlingguy%2Ftime-pi/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/geerlingguy","download_url":"https://codeload.github.com/geerlingguy/time-pi/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/geerlingguy%2Ftime-pi/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29993118,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-02T01:47:34.672Z","status":"online","status_checked_at":"2026-03-02T02:00:07.342Z","response_time":60,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["gps","ntp","ptp","raspberry-pi","time","time-server"],"created_at":"2024-12-16T02:01:20.215Z","updated_at":"2026-03-02T05:04:51.057Z","avatar_url":"https://github.com/geerlingguy.png","language":"Python","funding_links":["https://github.com/sponsors/geerlingguy","https://patreon.com/geerlingguy"],"categories":["Jinja","Python"],"sub_categories":[],"readme":"# Time Pi\n\n[![CI](https://github.com/geerlingguy/time-pi/actions/workflows/ci.yml/badge.svg)](https://github.com/geerlingguy/time-pi/actions/workflows/ci.yml)\n\n\u003cp align=\"center\"\u003e\u003cimg alt=\"Raspberry Pi 5 with TimeHAT V2\" src=\"/resources/time-pi.jpeg\" height=\"auto\" width=\"600\"\u003e\u003c/p\u003e\n\nA Raspberry Pi stratum 1 time server.\n\nTakes in GPS (or potentially other stratum 0 time sources), spits out NTP, PTP, etc.\n\n## Setup\n\n### Hardware\n\nTo run a decent time server (with high accuracy), you need a few things:\n\n  - A computer running Linux (all the nice tooling for network time is availabe here)\n  - A high quality time source (GPS is most commonly used these days)\n  - A network adapter capable of hardware timestamping (Intel and ASIX make some good NICs for time-related applications)\n\nThere are many options for each of the above items—for example, many use [Adafruit's Ultimate GPS HAT](https://www.adafruit.com/product/2324) or its [USB equivalent](https://www.adafruit.com/product/4279) for GPS acquisition, and for PTP, you can use a Compute Module 4 or 5's built-in NIC (with [PPS in or out](https://www.jeffgeerling.com/blog/2022/ptp-and-ieee-1588-hardware-timestamping-on-raspberry-pi-cm4)), or add on a compatible NIC on the Pi 5 with something like the [uPCIty Lite](https://amzn.to/4iUn9ke).\n\nMy own hardware configuration—which is the basis for the code in this repository, consists of:\n\n  - Computer: Raspberry Pi 5 model B\n  - Time source: u-blox ZED-F9T-00B-01 (installed on [TimeHAT V4](https://github.com/geerlingguy/raspberry-pi-pcie-devices/issues/674))\n  - NIC: Intel i226-LM (installed on [TimeHAT V4](https://github.com/geerlingguy/raspberry-pi-pcie-devices/issues/674))\n\nA precise GPS signal for nanosecond-accurate time requires a decent antenna with as clear a view of the sky as possible. Some GPS receivers are better than others, but even USB receivers will do better than NTP!\n\nI use a small [active GPS antenna](https://amzn.to/4gdhBj1) for testing, but for permanent installation it is best to mount a [higher-quality GPS antenna](https://www.meinbergglobal.com/english/products/gps-glonass-l1-antenna.htm) outside, clear of obstructions.\n\n### Software\n\nMake sure you have Ansible installed. Copy the following example files and customize them according to your setup:\n\n  - `example.hosts.ini` to `hosts.ini`\n  - `example.config.yml` to `config.yml`\n\nNow run the Ansible playbook:\n\n```\nansible-playbook main.yml\n```\n\nThis playbook will configure:\n\n  - [GPSd](https://gpsd.gitlab.io/gpsd/gpsd.html): interface with the u-blox GPS and provide GPS data to other applications\n  - [Chrony](https://chrony-project.org): NTP server, which also sync GPS time (with Internet NTP server backup) to the system clock\n  - [Linux PTP](https://linuxptp.nwtime.org): synchronize the system clock to the NIC PHC (Physical Hardware Clock), and set up the Pi as a PTP grandmaster clock\n\n\u003e **Intel i226 Notes**: Currently I can't get the i226 to work with DHCP at all, so I have to manually set an IP address using `nmtui`. It also [doesn't work at 2.5 Gbps currently](https://github.com/geerlingguy/raspberry-pi-pcie-devices/issues/674#issuecomment-2533117275), and it can't be overridden via Linux, so I make sure to plug it into a 1 Gbps port on my network.\n\n## GPS Notes\n\nUsing u-blox GPS modules, you may encounter a baud rate mismatch. Many of the u-blox modules default to `38400` baud, but this project recommends `115200` baud for slightly faster timing updates.\n\n```\n# Get the protocol version ('PROTVER')\nubxtool -p MON-VER\n...\nUBX-MON-VER:\n  swVersion EXT CORE 4.04 (7f89f7)\n  hwVersion 00190000\n  extension ROM BASE 0x118B2060\n  extension FWVER=SPG 4.04\n  extension PROTVER=32.01\n...\n\n# Set the version in ubxtool options\nexport UBXOPTS=\"-P 32.01\"\n\n# Set the baud rate to 115200\nubxtool -S 115200\n\n# Persist the setting\nubxtool -p SAVE\n```\n\n**KNOWN ISSUE**: The baud setting is currently not persisting across reboots. See [this GitHub issue](https://github.com/geerlingguy/time-pi/issues/11) for updates.\n\n`ubxtool` is installed as part of the `gpsd-clients` package, which is automatically installed by this playbook.\n\nFor more on how to set the baud rate (or tweak other GPS module parameters), see [millerjs.org's ubxtool page](https://wiki.millerjs.org/ubxtool) and the [ubxtool examples](https://gpsd.io/ubxtool-examples.html) page.\n\n## Usage and Debugging\n\nSome handy commands:\n\n```\n# GPS-related debugging\nsudo systemctl status gpsd  # check gpsd status\ngpsmon -n  # monitors gpsd output\ncgps -s  # also monitors gps output\n\n# PTP timestamping debugging\nethtool -T eth0  # or eth1, lists hardware clock info\n\n# Chrony debugging\nchronyc sources -v  # shows sources with documentation of fields\nchronyc tracking  # shows detailed timing data\n\n# Check on NTP service from another computer\nntpdate -q [ip of grandmaster]\n\n# Check on PTP clocks and offsets (assuming ptp4l is running)\nwget https://tsn.readthedocs.io/_downloads/f329e8dec804247b1dbb5835bd949e6f/check_clocks.c\ngcc -o check_clocks check_clocks.c\nsudo ./check_clocks -d eth0  # or eth1 (the interface you're using for PTP)\n\n# Check offset between NIC PHY and system clock\nsudo phc_ctl eth1 cmp  # should be nearly -37000000000ns\n```\n\nMuch of the work that went into this project was documented in [this thread on the TimeHat v2](https://github.com/geerlingguy/raspberry-pi-pcie-devices/issues/674).\n\n## GPS / GNSS Module debugging\n\nLike cellular modems, GPS modules can be a bit tricky, using arcane syntaxes and custom protocols for communication.\n\nFor the NEO-M9N module, the default `baud` rate is a little low for my liking, but to get it working, I had to go through a lengthy process learning `ubxtool`.\n\nTo configure my module for `115200` baud, I did the following:\n\n```\n# Set the baud rate\nubxtool -S 115200\n\n# Save the settings (get the `-P` PROTVER with `ubxtool -p MON-VER`)\n$ ubxtool -p SAVE -P 32.01\n\n# Update the rate in your GPSd config and restart `gpsd`\nsudo nano /etc/default/gpsd\nsudo systemctl restart gpsd\n\n# Test the settings by rebooting the GPS module manually.\n$ ubxtool -p COLDBOOT -P 32.01\n```\n\nSee this issue for more: [Debug NEO-M9N module on TimeHAT V2](https://github.com/geerlingguy/time-pi/issues/11).\n\n## Slave / Client Setup\n\nFor PTP, you need to install and configure PTP for Linux on slave/client machines, and synchronize them to the master/server node as well.\n\nAn example configuration for a slave/client node is set up in `ptp-client-node.yml`, and further examples may be provided in the future.\n\n## Other Hobbyist Time Servers\n\n  - [LeapSecond.com](http://www.leapsecond.com)\n  - [Austin's Nerdy Things: Nanosecond accurate PTP Pi server](https://austinsnerdythings.com/2025/02/18/nanosecond-accurate-ptp-server-grandmaster-and-client-tutorial-for-raspberry-pi/)\n  - [Andreas Spiess: NTP Server from GPS Satellites](https://www.youtube.com/watch?v=RKRN4p0gobk)\n  - [Jeff Geerling: Time Card mini for GPS and OXCO on Pi](Time Card mini adds Pi, GPS, and OCXO to your PC)\n\n## Other Time Resources I found Interesting\n\n  - [Where does my computer get the time from?](https://dotat.at/@/2023-05-26-whence-time.html) (good overview of the sources of modern NTP + GPS time, with the history of each source)\n\n## License\n\nGPLv3 or Later\n\n## Author\n\n[Jeff Geerling](https://www.jeffgeerling.com), with assistance from Ahmad Byagowi and Oleg Obleukhov from Meta.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgeerlingguy%2Ftime-pi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgeerlingguy%2Ftime-pi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgeerlingguy%2Ftime-pi/lists"}