{"id":5238,"date":"2023-04-07T16:30:19","date_gmt":"2023-04-07T07:30:19","guid":{"rendered":"https:\/\/blog.bitmeister.jp\/?p=5238"},"modified":"2023-04-07T16:53:36","modified_gmt":"2023-04-07T07:53:36","slug":"rpi4-ubuntu22-04-gps-1pps-chrony","status":"publish","type":"post","link":"https:\/\/blog.bitmeister.jp\/?p=5238","title":{"rendered":"RPi4, Ubuntu22.04, GPS, 1PPS, chrony"},"content":{"rendered":"<p>\u74b0\u5883<\/p>\n<pre class=\"brush: bash; gutter: false; title: ; notranslate\" title=\"\">\r\nu-blox M10S &lt;UART, PPS-GPIO&gt; Raspberry Pi 4B + Ubuntu 22.04 + chrony (NTP)\r\n<\/pre>\n<p><!--more--><br \/>\n\u3053\u306e Raspberry Pi HAT GR-M10-RP \u306f UART \u304c\u7d50\u7dda\u3055\u308c\u3066\u3044\u308b\u3002PPS \u306f\u5f15\u304d\u51fa\u3057\u3066\u3042\u308b\u304c\u7d50\u7dda\u3055\u308c\u3066\u3044\u306a\u3044\u306e\u3067 PPS \u3068 GPIO18 \u3092\u63a5\u7d9a\u3059\u308b\u3002\u3068\u308a\u3042\u3048\u305a\u30af\u30ea\u30c3\u30d7\u3067\u63a5\u7d9a\u3057\u3066\u3044\u308b\u3060\u3051\u3067\u3001\u6c7a\u3057\u3066\u63a8\u5968\u3057\u3066\u3044\u308b\u308f\u3051\u3067\u306f\u306a\u3044\u3002\u96fb\u6e90\u3092\u5207\u3063\u3066\u63a5\u7d9a\u3059\u308b\u3053\u3068\u3002<br \/>\n<img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/blog.bitmeister.jp\/wp-content\/uploads\/2023\/04\/pps-gpio18.png\" alt=\"\" width=\"806\" height=\"600\" class=\"aligncenter size-full wp-image-5239\" srcset=\"https:\/\/blog.bitmeister.jp\/wp-content\/uploads\/2023\/04\/pps-gpio18.png 806w, https:\/\/blog.bitmeister.jp\/wp-content\/uploads\/2023\/04\/pps-gpio18-300x223.png 300w, https:\/\/blog.bitmeister.jp\/wp-content\/uploads\/2023\/04\/pps-gpio18-768x572.png 768w\" sizes=\"auto, (max-width: 806px) 100vw, 806px\" \/><\/p>\n<p>\u3044\u308d\u3044\u308d\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3059\u308b\u3002<\/p>\n<pre class=\"brush: bash; gutter: false; title: ; notranslate\" title=\"\">\r\n$ sudo apt update\r\n$ sudo apt install gpsd gpsd-tools pps-tools chrony\r\n<\/pre>\n<p>PPS-GPIO \u30e2\u30b8\u30e5\u30fc\u30eb\u3092\u8aad\u307f\u8fbc\u3080\u8a2d\u5b9a\u3002<\/p>\n<pre class=\"brush: bash; gutter: false; title: ; notranslate\" title=\"\">\r\n$ sudo vi \/etc\/modules\r\npps-gpio\r\n<\/pre>\n<p>UART \u3092\u6709\u52b9\u306b\u3057\u3066\u3001PPS-GPIO \u30e2\u30b8\u30e5\u30fc\u30eb\u3092\u7d10\u4ed8\u3051\u308b\u8a2d\u5b9a\u3002<\/p>\n<pre class=\"brush: bash; gutter: false; title: ; notranslate\" title=\"\">\r\n$ sudo vi \/boot\/firmware\/config.txt\r\n&#x5B;all]\r\n...\r\n\r\n# Enable the UART port\r\nenable_uart=1\r\n\r\n# Associate GPS 1PPS with the GPIO18\r\ndtoverlay=pps-gpio,gpiopin=18\r\n<\/pre>\n<p>\u518d\u8d77\u52d5\u3059\u308b\u3002<\/p>\n<pre class=\"brush: bash; gutter: false; title: ; notranslate\" title=\"\">\r\n$ sudo reboot\r\n<\/pre>\n<p>PPS \u30c7\u30d0\u30a4\u30b9\u304c\u751f\u3048\u3066\u4fe1\u53f7\u304c\u53d6\u308c\u3066\u304f\u308b\u304b\u78ba\u8a8d\u3002<\/p>\n<pre class=\"brush: bash; gutter: false; title: ; notranslate\" title=\"\">\r\n$ sudo ppstest \/dev\/pps0\r\ntrying PPS source &quot;\/dev\/pps0&quot;\r\nfound PPS source &quot;\/dev\/pps0&quot;\r\nok, found 1 source(s), now start fetching data...\r\nsource 0 - assert 1680849684.999999591, sequence: 10165 - clear  0.000000000, sequence: 0\r\nsource 0 - assert 1680849685.999998084, sequence: 10166 - clear  0.000000000, sequence: 0\r\nsource 0 - assert 1680849687.000001170, sequence: 10167 - clear  0.000000000, sequence: 0\r\nsource 0 - assert 1680849687.999997829, sequence: 10168 - clear  0.000000000, sequence: 0\r\n<\/pre>\n<p>NMEA \u304c\u30ef\u30e9\u30ef\u30e9\u53d6\u308c\u3066\u3044\u308b\u3053\u3068\u3092\u78ba\u8a8d\u3002<\/p>\n<pre class=\"brush: bash; gutter: false; title: ; notranslate\" title=\"\">\r\n$ gpsmon -n \/dev\/ttS0\r\n<\/pre>\n<p>gpsd \u3092\u8a2d\u5b9a\u3002<\/p>\n<pre class=\"brush: bash; gutter: false; title: ; notranslate\" title=\"\">\r\n$ sudo vi \/etc\/default\/gpsd\r\nDEVICES=&quot;\/dev\/ttyS0 \/dev\/pps0&quot;\r\n\r\nGPSD_OPTIONS=&quot;-n&quot;\r\n\r\nUSBAUTO=&quot;false&quot;\r\n<\/pre>\n<p>gpsd \u3092\u518d\u8d77\u52d5\u3002<\/p>\n<pre class=\"brush: bash; gutter: false; title: ; notranslate\" title=\"\">\r\n$ sudo systemctl restart gpsd.service\r\n<\/pre>\n<p>\u30c7\u30d0\u30a4\u30b9\u3092\u6307\u5b9a\u305b\u305a NMEA \u304c\u53d6\u308c\u3066\u3044\u308b\u3053\u3068\u3092\u78ba\u8a8d\u3002<\/p>\n<pre class=\"brush: bash; gutter: false; title: ; notranslate\" title=\"\">\r\n$ gpsmon -n\r\n<\/pre>\n<p>chrony \u3092\u8a2d\u5b9a\u3002<\/p>\n<pre class=\"brush: bash; gutter: false; title: ; notranslate\" title=\"\">\r\n$ sudo vi \/etc\/chrony\/chrony.conf\r\npool ntp.ubuntu.com        iburst maxsources 4\r\npool ntp.nict.jp           iburst maxsources 4\r\n\r\nrefclock PPS \/dev\/pps0 lock NMEA refid GPS\r\n<\/pre>\n<p>chrony \u3092\u518d\u8d77\u52d5\u3002<\/p>\n<pre class=\"brush: bash; gutter: false; title: ; notranslate\" title=\"\">\r\n$ sudo systemctl restart chrony.service\r\n<\/pre>\n<pre class=\"brush: bash; gutter: false; title: ; notranslate\" title=\"\">\r\n$ chronyc sources -v\r\n\r\n  .-- Source mode  '^' = server, '=' = peer, '#' = local clock.\r\n \/ .- Source state '*' = current best, '+' = combined, '-' = not combined,\r\n| \/             'x' = may be in error, '~' = too variable, '?' = unusable.\r\n||                                                 .- xxxx &#x5B; yyyy ] +\/- zzzz\r\n||      Reachability register (octal) -.           |  xxxx = adjusted offset,\r\n||      Log2(Polling interval) --.      |          |  yyyy = measured offset,\r\n||                                \\     |          |  zzzz = estimated error.\r\n||                                 |    |           \\\r\nMS Name\/IP address         Stratum Poll Reach LastRx Last sample               \r\n===============================================================================\r\n#* GPS                           0   4    77    14   +291ns&#x5B; +637ns] +\/-  243ns\r\n^- prod-ntp-3.ntp4.ps5.cano&gt;     2   6    37    27  -1629us&#x5B;-1629us] +\/-  125ms\r\n^- prod-ntp-3.ntp4.ps5.cano&gt;     2   6    37    26  -5502us&#x5B;-5502us] +\/-  131ms\r\n^- alphyn.canonical.com          2   6    37    27  +1522us&#x5B;+1522us] +\/-  133ms\r\n^- prod-ntp-4.ntp4.ps5.cano&gt;     2   6    37    27  -4972us&#x5B;-4972us] +\/-  126ms\r\n^- ntp-a2.nict.go.jp             1   6    37    28  +1090us&#x5B;+1090us] +\/- 5824us\r\n^- 2001:ce8:78::2                1   6    37    29   +589us&#x5B; +589us] +\/-   10ms\r\n^- ntp-a3.nict.go.jp             1   6    37    29  -2611us&#x5B;-2611us] +\/- 5687us\r\n^- ntp-a2.nict.go.jp             1   6    37    28   -166us&#x5B; -166us] +\/- 3466us\r\n<\/pre>\n<p>\u540c\u671f\u3057\u3066\u306a\u304b\u3063\u305f\u3089\u6570\u5206\u5f85\u3064\u3068\u540c\u671f\u3059\u308b\u3002<\/p>\n<p>\u53c2\u8003\u306b\u3057\u305f\u30da\u30fc\u30b8\u306e\u30ea\u30f3\u30af<br \/>\n<a href=\"https:\/\/chrony.tuxfamily.org\/doc\/4.3\/chrony.conf.html\">https:\/\/chrony.tuxfamily.org\/doc\/4.3\/chrony.conf.html<\/a><br \/>\n<a href=\"https:\/\/qiita.com\/yamakenjp\/items\/e69eeabdefd9cc960610\">https:\/\/qiita.com\/yamakenjp\/items\/e69eeabdefd9cc960610<\/a><br \/>\n<a href=\"https:\/\/www.popnja.com\/entry\/2021\/10\/04\/181652\">https:\/\/www.popnja.com\/entry\/2021\/10\/04\/181652<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u74b0\u5883 u-blox M10S &lt;UART, PPS-GPIO&gt; Raspberry Pi 4B + Ubuntu 22.04 + chrony (NTP)<\/p>\n","protected":false},"author":8,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-5238","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/blog.bitmeister.jp\/index.php?rest_route=\/wp\/v2\/posts\/5238","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.bitmeister.jp\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.bitmeister.jp\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.bitmeister.jp\/index.php?rest_route=\/wp\/v2\/users\/8"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.bitmeister.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=5238"}],"version-history":[{"count":28,"href":"https:\/\/blog.bitmeister.jp\/index.php?rest_route=\/wp\/v2\/posts\/5238\/revisions"}],"predecessor-version":[{"id":5268,"href":"https:\/\/blog.bitmeister.jp\/index.php?rest_route=\/wp\/v2\/posts\/5238\/revisions\/5268"}],"wp:attachment":[{"href":"https:\/\/blog.bitmeister.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=5238"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.bitmeister.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=5238"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.bitmeister.jp\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=5238"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}