{"id":13587325,"url":"https://github.com/martinboller/pi-time","last_synced_at":"2026-04-22T04:35:00.977Z","repository":{"id":135877584,"uuid":"247526640","full_name":"martinboller/pi-time","owner":"martinboller","description":"Raspberry PI Stratum 1 NTP server","archived":false,"fork":false,"pushed_at":"2023-12-28T19:37:12.000Z","size":565,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-12-25T16:16:08.692Z","etag":null,"topics":["gpsd","ntp","raspberry-pi","stratum-1"],"latest_commit_sha":null,"homepage":"","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/martinboller.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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}},"created_at":"2020-03-15T18:29:26.000Z","updated_at":"2025-09-29T02:43:13.000Z","dependencies_parsed_at":null,"dependency_job_id":"9d279984-11c9-42a4-97f7-e82474d35512","html_url":"https://github.com/martinboller/pi-time","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/martinboller/pi-time","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/martinboller%2Fpi-time","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/martinboller%2Fpi-time/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/martinboller%2Fpi-time/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/martinboller%2Fpi-time/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/martinboller","download_url":"https://codeload.github.com/martinboller/pi-time/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/martinboller%2Fpi-time/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32121146,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-22T00:31:26.853Z","status":"online","status_checked_at":"2026-04-22T02:00:05.693Z","response_time":58,"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":["gpsd","ntp","raspberry-pi","stratum-1"],"created_at":"2024-08-01T15:06:09.493Z","updated_at":"2026-04-22T04:35:00.946Z","avatar_url":"https://github.com/martinboller.png","language":"Shell","funding_links":[],"categories":["Shell"],"sub_categories":[],"readme":"# pi-time\nRaspberry PI Stratum 1 server\n\n# Raspberry Pi Installation script\n\n### Bash script automating the installation of a GPS / PPS Disciplined Stratum-1 Server on the Raspberry Pi (3), 4, or 5 \n\n### Design principles:\n  - Dedicated to being a Stratum-1 NTP server\n  - Use a GPS Breakout board\n\n### Known issues:\n  - None so far\n  - Should work on a Pi Zero, but as these have no ethernet cable, and NTP over wireless is less than optimal it's untested\n  - May work on a Raspberry Pi 2, haven't tried.\n\n### Latest changes \n#### 2023-12-28 - version 5.01\n  - Settings in .env-file\n  - ntpstats and logging corrected\n  - ntpleapfetch usage in update-leap.service\n\n#### 2023-12-27 - Raspberry Pi OS (64-bit) Lite (Debian 12, codename: Bookworm)\n  - Version 5 for Raspberry PI OS Lite (64 bit) - Debian 12 (Bookworm)\n  - This script will only work with ntpsec and has only been tested on the Debian 12 (Bookworm) version of RaspberryPi OS\n\n#### 2021-12-02 - Raspberry Pi OS (64-bit) Lite\n  - Tested to work with Raspberry Pi OS (64-bit) Lite\n\n#### 2021-12-02 - Bullseye version\n  - Version 4.00 now for Debian 11 (Bullseye)\n  \n#### 2021-12-05 - 1GHz\n  - Pinned clock frequency at 1GHz - seems to give best precision, anything below that is -19 instead of -20 at 1GHz\n\n#### 2021-12-10 - config.txt include ntpserver.txt\n  - Keeping the original config.txt, only adding include ntpserver.txt\n\n### Installation\nPrerequisite: A Raspberry PI 4 or 5 and an SD-CARD\n - Download the latest Raspberry Pi OS Lite here: https://downloads.raspberrypi.org/raspios_lite_armhf/images/raspios_lite_armhf-2021-11-08/2021-10-30-raspios-bullseye-armhf-lite.zip\n - Write the latest Raspberry Pi OS Lite, based on Debian 12 (Bookworm), to a good quality sd-card using rpi-imager, dd or whatever tool you prefer. Using rpi-imager is the easiest option, allowing you to create credentials for initial logon and set hostname\n - Configure the .env to your wishes, do NOT forget to change the SSH Public Key and whether or not to disable the original user (which used to be \"pi\")\n - Run prep_sd.sh, enter a new hostname for the pi\u003csup\u003e1\u003c/sup\u003e.\n - Boot the Pi, logon as the credentials created with rpi-imager (this use will be disabled later, if correctly named in .env, I use \"ntp\" as user)\n - sudo su -\n - run ./install-rpi-stratum1.sh\n - Watch install progress on the tty, and from another SSH session, run *tail -fn1000 /var/log/syslog | grep 'Stratum1 NTP Server'*\n - After reboot the Pi should now provide good time, however give it time :) lots of time to achieve good precision\n - Login with root (if you added your public ssh key to .env). If not login with the user you created earlier with rpi-imager.\n\n\u003csup\u003e1\u003c/sup\u003e prep_sd.sh prepares the SD-Card enabling SSH, copies the install script, and changes hostname on the sd-card.\n\n### Hardware\nIt's easy to find GPS breakout boards for Arduino or Raspberry Pi's on ebay, amazon, and other semi-dubious marketplaces.\nHowever there's also great boards from Adafruit and others.\n - Make sure the board outputs the PPS signal.\n - The serial I/O and PPS _must_ be 3.3v TTL level serial. If it's 5 volt serial, then level shifting is needed, however \n - some boards can be supplied with 5v and still only outputs 3v3.\n - 5v output will ***kill*** the GPIO on the Raspberry Pi. Start with powering the GPS Board with 3v3 and see if that works.\n - Connect the ground of the GPS module to pin 6 (Ground) of the GPIO header on the Raspberry Pi.\n - Connect either a +5 power input to pin 2 (or pin 4) of the GPIO header (see above for 5v warning), or\n - +3v3 power input to pin 1 (or pin 17) of the GPIO header.\n - Connect the serial input (RXD) of the GPS module to pin 8 of the GPIO header. This is the UART TXD on the Raspberry Pi\u003csup\u003e2\u003c/sup\u003e.\n - Connect the serial output (TXD) to pin 10 of the GPIO header. This is the UART RXD on the Raspberry Pi\u003csup\u003e2\u003c/sup\u003e.\n - Connect the PPS signal to pin 12 (GPIO 18) of the GPIO header.\n\n\u003csup\u003e2\u003c/sup\u003e When configured with enable_uart=1 in /boot/config.txt. The install-script does this in *configure_pps*.\n\n### GPIO Pinout from raspberrypi.org\n\u003cimg src=\"./images/GPIO-Pinout-Diagram-2.png\" alt=\"drawing\" width=\"800\"/\u003e\n\nBelow is a picture of GPS board I've used several of for exactly this purpose (lucky to buy 7 for a great price).\n\n ![alt text](./images/gps.png \"GPS Ublox7\")\n\n\n## Tips and tricks for troubleshooting\nCheck syslog for 'finalized installation of stratum-1 server', then at least the script finished, but there should also be a log entry for each routine called (main)\n### Follow the log during installation\n- tail -fn1000 /var/log/syslog | grep 'Stratum1 NTP Server'\n### Verify pps\n- dmesg | grep pps\n- ppstest /dev/pps0\n- ppswatch -a /dev/pps0\n### Run gpsd manually (stop gpsd.socket first)\n- gpsd -D 5 -N -n /dev/ttyAMA0 /dev/pps0 -F /var/run/gpsd.sock\n- systemctl stop gpsd.*\n- killall -9 gpsd\nReconfigure gpsd\n- dpkg-reconfigure -plow gpsd\n### Check GPS reception and ensure that it outputs to NTP\n- cgps -s\n- gpsmon\n- ipcs -m\n- ntpshmmon\n### Monitoring the ntp daemon\n- ntpq -crv -pn\n- watch -n 10 'ntpstat; ntpq -p -crv; ntptime;'\n- watch -n 10 'hostname -s; echo -----------; ntpstat; ntpq -p -crv; ntptime;'\n### or if using Chrony\n- watch -n5 'hostname -s; echo --------; chronyc sources -v; chronyc tracking;'\n### If HW clock installed\n- dmesg | grep rtc\n- hwclock --systohc --utc\n- hwclock --show --utc --debug\n- cat /sys/class/rtc/rtc0/date\n- cat /sys/class/rtc/rtc0/time\n- cat /sys/class/rtc/rtc0/since_epoch\n- cat /sys/class/rtc/rtc0/name\n- i2cdetect -y 1\n### Update system\n- export DEBIAN_FRONTEND=noninteractive; apt update; apt full-upgrade -y;\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmartinboller%2Fpi-time","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmartinboller%2Fpi-time","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmartinboller%2Fpi-time/lists"}