{"id":1273,"date":"2019-07-08T10:42:54","date_gmt":"2019-07-08T01:42:54","guid":{"rendered":"https:\/\/eguchi.jp\/blog\/?p=1273"},"modified":"2019-07-08T10:42:56","modified_gmt":"2019-07-08T01:42:56","slug":"m5stack%e7%94%a83g-%e6%8b%a1%e5%bc%b5%e3%83%9c%e3%83%bc%e3%83%89%e3%81%a8gps%e3%82%92%e7%b9%8b%e3%81%84%e3%81%a7%e8%a6%8b%e3%81%9f","status":"publish","type":"post","link":"https:\/\/eguchi.jp\/blog\/?p=1273","title":{"rendered":"M5STACK\u75283G \u62e1\u5f35\u30dc\u30fc\u30c9\u3068GPS\u3092\u7e4b\u3044\u3067\u898b\u305f"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">\u7d4c\u7def<\/h2>\n\n\n\n<p><a href=\"https:\/\/eguchi.jp\/blog\/?p=1255\">M5STACK\u7528\u306e3G\u62e1\u5f35\u30dc\u30fc\u30c9\u306e\u4e0d\u5177\u5408<\/a>\u306b\u906d\u9047\u3057\u307e\u3057\u305f\u304c\u3001\u4ea4\u63db\u54c1\u304c\u5c4a\u304d\u307e\u3057\u305f\u306e\u3067\u3001\u3044\u3058\u304f\u308b\u306e\u518d\u958b\uff01<br>\uff13G\u901a\u4fe1\u304c\u53ef\u80fd\u306b\u306a\u3063\u305f\u3068\u3044\u3046\u3053\u3068\u3067\u3001\u5916\u306b\u6301\u3061\u51fa\u3057\u305f\u304f\u306a\u308a\u307e\u3059\u3002\u305d\u3046\u3059\u308b\u3068\u5fc5\u7136\u7684\u306b\u3001\u4f4d\u7f6e\u60c5\u5831\u3092\u53d6\u5f97\u3057\u305f\u304f\u306a\u308b\u3068\u3044\u3046\u3053\u3068\u3067\u3001GPS\u30e2\u30b8\u30e5\u30fc\u30eb\u3092\u63a5\u7d9a\u3057\u305f\u304f\u306a\u308b\u3067\u3057\u3087\u3046\uff01<br>M5STACK\u7528\u306b<a href=\"https:\/\/www.switch-science.com\/catalog\/3861\/\">GPS\u30e2\u30b8\u30e5\u30fc\u30eb<\/a>\u304c\u3042\u308b\u306e\u3067\u3059\u304c\u3001M5STACK\u306eGPIO 16\u300117\u756a\u306eUART\u3092\u4f7f\u3063\u3066\u901a\u4fe1\u3057\u3066\u3044\u308b\u306e\u3067\u3059\u3002<br>M5STACK\u7528\u306e3G\u62e1\u5f35\u30dc\u30fc\u30c9\u3082\u3001\u540c\u3058\u3001M5STACK\u306eGPIO 16\u300117\u756a\u306eUART\u3092\u4f7f\u3063\u3066\u3044\u308b\u306e\u3067\u3001\u30b9\u30bf\u30c3\u30af\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u306a\u3044\u306e\u3067\u3001GROVE\u7aef\u5b50\u7d4c\u7531\u3067\u3001GPS\u3092\u7e4b\u3050\u3053\u3068\u306b\u3057\u307e\u3057\u305f\u3002<br>M5STACK BASIC\u306b\u306f\u3001GROVE B,C\u7aef\u5b50\u306f\u306a\u3044\u306e\u3067\u3001<a href=\"https:\/\/www.switch-science.com\/catalog\/5206\/\">M5Stack PLUS\u30a8\u30f3\u30b3\u30fc\u30c0\u30e2\u30b8\u30e5\u30fc\u30eb<\/a>\u3092\u4f7f\u3063\u3066\u3001\u30dd\u30fc\u30c8\u3092\u62e1\u5f35\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"768\" src=\"https:\/\/eguchi.jp\/blog\/wp-content\/uploads\/2019\/07\/IMG_2507-1024x768.jpg\" alt=\"\" class=\"wp-image-1274\" srcset=\"https:\/\/eguchi.jp\/blog\/wp-content\/uploads\/2019\/07\/IMG_2507-1024x768.jpg 1024w, https:\/\/eguchi.jp\/blog\/wp-content\/uploads\/2019\/07\/IMG_2507-300x225.jpg 300w, https:\/\/eguchi.jp\/blog\/wp-content\/uploads\/2019\/07\/IMG_2507-768x576.jpg 768w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><figcaption>\u5199\u771f\u304c\u6a2a\u306b\u306a\u3063\u3066\u3057\u307e\u3063\u3066\u3044\u307e\u3059\u304c\u3001GPS\u3092M5Stack PLUS\u30a8\u30f3\u30b3\u30fc\u30c0\u30e2\u30b8\u30e5\u30fc\u30eb\u306eGROVE B\u7aef\u5b50\u306b\u63a5\u7d9a\u3057\u3066\u3044\u307e\u3059\u3002<\/figcaption><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9<br>\uff08GPS\u306e\u30e9\u30a4\u30d6\u30e9\u30ea\u3068\u3057\u3066\u3001TinyGPSPlus 1.0.2\u3092\u4f7f\u7528\uff09<\/h2>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n#include &amp;lt;M5Stack.h&gt;\n\n#define CONSOLE Serial\n#define GPS Serial1\n#define MODEM Serial2\n\n#include &amp;lt;TinyGPS++.h&gt;\n\nTinyGPSPlus gps;\n\n#define TINY_GSM_DEBUG Serial\n#define TINY_GSM_MODEM_UBLOX\n\n#include &amp;lt;TinyGsmClient.h&gt;\n\nTinyGsm modem(Serial2);\nTinyGsmClient ctx(modem);\n\nvoid setup() {\n  M5.begin();\n  M5.Lcd.clear(BLACK);\n  M5.Lcd.setTextColor(WHITE);\n  M5.Lcd.println(F(&quot;M5Stack + 3G Module + GPS&quot;));\n\n  GPS.begin(9600, SERIAL_8N1, 36, 26);        \/\/ GROVE B\n  MODEM.begin(115200, SERIAL_8N1, 16, 17);    \/\/ 3G MODULE\n\n  Serial.print(F(&quot;TinyGPS++ library v. &quot;));\n  Serial.println(TinyGPSPlus::libraryVersion());\n\n  M5.Lcd.print(F(&quot;modem.restart()&quot;));\n  modem.restart();\n  M5.Lcd.println(F(&quot;done&quot;));\n\n  M5.Lcd.print(F(&quot;getModemInfo:&quot;));\n  String modemInfo = modem.getModemInfo();\n  M5.Lcd.println(modemInfo);\n\n  M5.Lcd.print(F(&quot;waitForNetwork()&quot;));\n  while (!modem.waitForNetwork()) M5.Lcd.print(&quot;.&quot;);\n  M5.Lcd.println(F(&quot;Ok&quot;));\n\n  M5.Lcd.print(F(&quot;gprsConnect(soracom.io)&quot;));\n  modem.gprsConnect(&quot;soracom.io&quot;, &quot;sora&quot;, &quot;sora&quot;);\n  M5.Lcd.println(F(&quot;done&quot;));\n\n  M5.Lcd.print(F(&quot;isNetworkConnected()&quot;));\n  while (!modem.isNetworkConnected()) M5.Lcd.print(&quot;.&quot;);\n  M5.Lcd.println(F(&quot;Ok&quot;));\n\n  M5.Lcd.print(F(&quot;My IP addr: &quot;));\n  IPAddress ipaddr = modem.localIP();\n  M5.Lcd.print(ipaddr);\n  delay(10000);\n}\n\nvoid loop() {\n  M5.update();\n\n  if (MODEM.available()) {\n    CONSOLE.write(MODEM.read());\n  }\n  \n  if (CONSOLE.available()) {\n    MODEM.write(CONSOLE.read());\n  }\n\n  if(GPS.available()){\n    if(gps.encode(GPS.read())) {\n      displayInfo();\n    }\n  }\n}\n\nvoid displayInfo()\n{\n  Serial.print(F(&quot;Location: &quot;)); \n  if (gps.location.isValid())\n  {\n    Serial.print(gps.location.lat(), 6);\n    Serial.print(F(&quot;,&quot;));\n    Serial.print(gps.location.lng(), 6);\n  }\n  else\n  {\n    Serial.print(F(&quot;INVALID&quot;));\n  }\n\n  Serial.print(F(&quot;  Date\/Time: &quot;));\n  if (gps.date.isValid())\n  {\n    Serial.print(gps.date.month());\n    Serial.print(F(&quot;\/&quot;));\n    Serial.print(gps.date.day());\n    Serial.print(F(&quot;\/&quot;));\n    Serial.print(gps.date.year());\n  }\n  else\n  {\n    Serial.print(F(&quot;INVALID&quot;));\n  }\n\n  Serial.print(F(&quot; &quot;));\n  if (gps.time.isValid())\n  {\n    if (gps.time.hour() &amp;lt; 10) Serial.print(F(&quot;0&quot;));\n    Serial.print(gps.time.hour());\n    Serial.print(F(&quot;:&quot;));\n    if (gps.time.minute() &amp;lt; 10) Serial.print(F(&quot;0&quot;));\n    Serial.print(gps.time.minute());\n    Serial.print(F(&quot;:&quot;));\n    if (gps.time.second() &amp;lt; 10) Serial.print(F(&quot;0&quot;));\n    Serial.print(gps.time.second());\n    Serial.print(F(&quot;.&quot;));\n    if (gps.time.centisecond() &amp;lt; 10) Serial.print(F(&quot;0&quot;));\n    Serial.print(gps.time.centisecond());\n  }\n  else\n  {\n    Serial.print(F(&quot;INVALID&quot;));\n  }\n\n  Serial.println();\n}\n<\/pre><\/div>\n\n\n<h2 class=\"wp-block-heading\">\u52d5\u4f5c\u30ed\u30b0<\/h2>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n10:22:47.703 -&gt; M5Stack initializing...OK\n10:22:48.396 -&gt; TinyGPS++ library v. 1.0.2\n10:22:54.953 -&gt; &#x5B;7334] ### TinyGSM Version: 0.7.9\n10:22:57.084 -&gt; &#x5B;9447] ### Modem: u-blox SARA-U201\n10:23:49.086 -&gt; Location: INVALID  Date\/Time: INVALID 01:22:50.74\n10:23:49.086 -&gt; Location: INVALID  Date\/Time: INVALID 01:22:50.74\n10:23:49.086 -&gt; Location: INVALID  Date\/Time: INVALID 01:22:50.74\n10:23:49.086 -&gt; Location: INVALID  Date\/Time: INVALID 01:22:50.74\n10:23:49.086 -&gt; Location: INVALID  Date\/Time: 7\/8\/2019 01:22:50.74\n10:23:49.086 -&gt; Location: INVALID  Date\/Time: 7\/8\/2019 01:22:50.74\n10:23:49.086 -&gt; Location: INVALID  Date\/Time: 7\/8\/2019 01:22:50.74\n<\/pre><\/div>\n\n\n<p>\u5ba4\u5185\u3067\u3001\u57f7\u7b46\u3057\u3066\u3044\u308b\u305f\u3081\u3001\u4f4d\u7f6e\u60c5\u5831\u306f\u53d6\u5f97\u3067\u304d\u3066\u3044\u307e\u305b\u3093\u304c\u3001\u65e5\u6642\u306f\u51fa\u529b\u3067\u304d\u3066\u3044\u3066\u3001AT\u30b3\u30de\u30f3\u30c9\u3067\u3082\u3084\u308a\u53d6\u308a\u53ef\u80fd\u306a\u306e\u3067\u30013G\u30e2\u30b8\u30e5\u30fc\u30eb\u3068GPS\u30e2\u30b8\u30e5\u30fc\u30eb\u304c\u5171\u5b58\u3067\u304d\u3066\u3044\u308b\u3053\u3068\u304c\u78ba\u8a8d\u3067\u304d\u307e\u3059<\/p>\n\n\n\n<p>\u4ee5\u4e0a\u3001\u3054\u53c2\u8003\u307e\u3067\u306b<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u7d4c\u7def M5STACK\u7528\u306e3G\u62e1\u5f35\u30dc\u30fc\u30c9\u306e\u4e0d\u5177\u5408\u306b\u906d\u9047\u3057\u307e\u3057\u305f\u304c\u3001\u4ea4\u63db\u54c1\u304c\u5c4a\u304d\u307e\u3057\u305f\u306e\u3067\u3001\u3044\u3058\u304f\u308b\u306e\u518d\u958b\uff01\uff13G\u901a\u4fe1\u304c\u53ef\u80fd\u306b\u306a\u3063\u305f\u3068\u3044\u3046\u3053\u3068\u3067\u3001\u5916\u306b\u6301\u3061\u51fa\u3057\u305f\u304f\u306a\u308a\u307e\u3059\u3002\u305d\u3046\u3059\u308b\u3068\u5fc5\u7136\u7684\u306b\u3001\u4f4d\u7f6e\u60c5\u5831\u3092\u53d6\u5f97\u3057\u305f\u304f\u306a\u308b\u3068\u3044\u3046\u3053\u3068 &hellip; <a href=\"https:\/\/eguchi.jp\/blog\/?p=1273\" class=\"more-link\">\u7d9a\u304d\u3092\u8aad\u3080 <span class=\"screen-reader-text\">M5STACK\u75283G \u62e1\u5f35\u30dc\u30fc\u30c9\u3068GPS\u3092\u7e4b\u3044\u3067\u898b\u305f<\/span> <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[],"class_list":["post-1273","post","type-post","status-publish","format-standard","hentry","category-2"],"_links":{"self":[{"href":"https:\/\/eguchi.jp\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1273","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/eguchi.jp\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/eguchi.jp\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/eguchi.jp\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/eguchi.jp\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1273"}],"version-history":[{"count":1,"href":"https:\/\/eguchi.jp\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1273\/revisions"}],"predecessor-version":[{"id":1275,"href":"https:\/\/eguchi.jp\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1273\/revisions\/1275"}],"wp:attachment":[{"href":"https:\/\/eguchi.jp\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1273"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/eguchi.jp\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1273"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/eguchi.jp\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1273"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}