{"id":1210,"date":"2019-06-11T13:13:13","date_gmt":"2019-06-11T04:13:13","guid":{"rendered":"https:\/\/eguchi.jp\/blog\/?p=1210"},"modified":"2019-06-11T13:22:25","modified_gmt":"2019-06-11T04:22:25","slug":"m5stick-c%e3%81%a7gps%e5%8f%97%e4%bf%a1","status":"publish","type":"post","link":"https:\/\/eguchi.jp\/blog\/?p=1210","title":{"rendered":"M5STICK-C\u3067GPS\u53d7\u4fe1"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">M5STICK-C\u306e\u6c4e\u7528I\/O\u30dd\u30fc\u30c8\u304c\u3069\u3053\u307e\u3067\u6c4e\u7528\u306a\u306e\u304b\uff1f\u3092\u77e5\u308a\u305f\u3044\u306e\u3067\u3001<a href=\"https:\/\/eguchi.jp\/blog\/?p=1203\">\u524d\u56de<\/a>\u306fI2C\u63a5\u7d9a\u3067\u3057\u305f\u304c\u3001\u4eca\u56de\u306f\u3001UART\u63a5\u7d9a\u306b\u6311\u6226\u3057\u3066\u307f\u307e\u3059\uff01<br>\u307e\u305f\u3001\u624b\u5143\u306b\u3042\u3063\u305f\u79cb\u6708\u96fb\u5b50\u306eGPS\u30e2\u30b8\u30e5\u30fc\u30eb(<a href=\"http:\/\/akizukidenshi.com\/catalog\/g\/gK-09991\/\">AE-GPS<\/a>)\u3092M5STICK-C\u306b\u7e4b\u3044\u3067\u3001\u4f4d\u7f6e\u60c5\u5831\u3092\u53d6\u5f97\u3057\u3066\u307f\u307e\u3057\u3087\u3046\uff01<\/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\/06\/IMG_2303-1024x768.jpg\" alt=\"\" class=\"wp-image-1211\" srcset=\"https:\/\/eguchi.jp\/blog\/wp-content\/uploads\/2019\/06\/IMG_2303-1024x768.jpg 1024w, https:\/\/eguchi.jp\/blog\/wp-content\/uploads\/2019\/06\/IMG_2303-300x225.jpg 300w, https:\/\/eguchi.jp\/blog\/wp-content\/uploads\/2019\/06\/IMG_2303-768x576.jpg 768w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><figcaption>AE-GPS\u3068\u306e\u63a5\u7d9a\uff08RXD\u3092G26,TXD\u3092G36)\u306b\u7e4b\u3044\u3067\u3044\u307e\u3059\u3002<\/figcaption><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/github.com\/mikalhart\/TinyGPSPlus\">TinyGPS Plus\u306e\u30e9\u30a4\u30d6\u30e9\u30ea\u30fc<\/a>\u3092\u4f7f\u7528\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n\/\/ M5STICK-C\u3067\u3001GPS(UART\u63a5\u7d9a)\u3092\u7e4b\u3044\u3067\u5024\u3092\u53d6\u5f97\u3059\u308b\n\/\/ Programed by Kazuyuki Eguchi\n\n#include &amp;lt;M5StickC.h&gt;\n#include &amp;lt;TinyGPS++.h&gt;\n\nHardwareSerial GPSUART(1);\nTinyGPSPlus gps;\n\nvoid setup() {\n  M5.begin();\n  M5.Axp.ScreenBreath(9); \/\/ \u30d0\u30c3\u30af\u30e9\u30a4\u30c8\u306e\u660e\u308b\u3055(7-15)\n  M5.Lcd.setRotation(1);\n  M5.Lcd.fillScreen(TFT_BLACK);\n  M5.Lcd.setTextSize(2);\n  M5.Lcd.setTextColor(TFT_YELLOW);\n  M5.Lcd.setCursor(0, 0);\n\n  GPSUART.begin(9600, SERIAL_8N1, 26, 36);  \n}\n\nvoid loop() {\n   if (GPSUART.available()) {\n    int inByte = GPSUART.read();\n    \/\/ Serial.write(inByte);\n    \n    if(gps.encode(inByte)){\n      displayInfo();\n    }\n  }\n}\n\nvoid displayInfo()\n{\n  M5.Lcd.fillScreen(TFT_BLACK);\n  M5.Lcd.setCursor(0, 0);\n  \n  Serial.print(F(&quot;Location: &quot;));\n  M5.Lcd.print(F(&quot;Location: &quot;));\n   \n  if (gps.location.isValid())\n  {\n    M5.Lcd.print(gps.location.lat(), 6);\n    M5.Lcd.print(F(&quot;,&quot;));\n    M5.Lcd.print(gps.location.lng(), 6);\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    M5.Lcd.print(F(&quot;INVALID&quot;));\n    Serial.print(F(&quot;INVALID&quot;));\n  }\n\n  M5.Lcd.print(F(&quot;  Date\/Time: &quot;));\n  Serial.print(F(&quot;  Date\/Time: &quot;));\n  \n  if (gps.date.isValid())\n  {\n    M5.Lcd.print(gps.date.month());\n    M5.Lcd.print(F(&quot;\/&quot;));\n    M5.Lcd.print(gps.date.day());\n    M5.Lcd.print(F(&quot;\/&quot;));\n    M5.Lcd.print(gps.date.year());\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    M5.Lcd.print(F(&quot;INVALID&quot;));\n    Serial.print(F(&quot;INVALID&quot;));\n  }\n\n  M5.Lcd.print(F(&quot; &quot;));\n  Serial.print(F(&quot; &quot;));\n  \n  if (gps.time.isValid())\n  {\n    if (gps.time.hour() &amp;lt; 10) {\n      M5.Lcd.print(F(&quot;0&quot;));\n      Serial.print(F(&quot;0&quot;));\n    }\n    \n    M5.Lcd.print(gps.time.hour());\n    M5.Lcd.print(F(&quot;:&quot;));\n\n    Serial.print(gps.time.hour());\n    Serial.print(F(&quot;:&quot;));\n    \n    if (gps.time.minute() &amp;lt; 10) {\n      M5.Lcd.print(F(&quot;0&quot;));\n      Serial.print(F(&quot;0&quot;));\n    }\n    \n    M5.Lcd.print(gps.time.minute());\n    M5.Lcd.print(F(&quot;:&quot;));\n\n    Serial.print(gps.time.minute());\n    Serial.print(F(&quot;:&quot;));\n    \n    if (gps.time.second() &amp;lt; 10) {\n      M5.Lcd.print(F(&quot;0&quot;));\n      Serial.print(F(&quot;0&quot;));\n    }\n    \n    M5.Lcd.print(gps.time.second());\n    M5.Lcd.print(F(&quot;.&quot;));\n\n    Serial.print(gps.time.second());\n    Serial.print(F(&quot;.&quot;));\n    \n    if (gps.time.centisecond() &amp;lt; 10) {\n      M5.Lcd.print(F(&quot;0&quot;));\n      Serial.print(F(&quot;0&quot;));\n    }\n    \n    M5.Lcd.print(gps.time.centisecond());\n    Serial.print(gps.time.centisecond());\n  }\n  else\n  {\n    M5.Lcd.print(F(&quot;INVALID&quot;));\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\u30a4\u30e1\u30fc\u30b8<\/h2>\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\/06\/IMG_2302-1024x768.jpg\" alt=\"\" class=\"wp-image-1212\" srcset=\"https:\/\/eguchi.jp\/blog\/wp-content\/uploads\/2019\/06\/IMG_2302-1024x768.jpg 1024w, https:\/\/eguchi.jp\/blog\/wp-content\/uploads\/2019\/06\/IMG_2302-300x225.jpg 300w, https:\/\/eguchi.jp\/blog\/wp-content\/uploads\/2019\/06\/IMG_2302-768x576.jpg 768w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">\u4ee5\u4e0a\u3001\u3054\u53c2\u8003\u307e\u3067\u306b<\/p>\n","protected":false},"excerpt":{"rendered":"<p>M5STICK-C\u306e\u6c4e\u7528I\/O\u30dd\u30fc\u30c8\u304c\u3069\u3053\u307e\u3067\u6c4e\u7528\u306a\u306e\u304b\uff1f\u3092\u77e5\u308a\u305f\u3044\u306e\u3067\u3001\u524d\u56de\u306fI2C\u63a5\u7d9a\u3067\u3057\u305f\u304c\u3001\u4eca\u56de\u306f\u3001UART\u63a5\u7d9a\u306b\u6311\u6226\u3057\u3066\u307f\u307e\u3059\uff01\u307e\u305f\u3001\u624b\u5143\u306b\u3042\u3063\u305f\u79cb\u6708\u96fb\u5b50\u306eGPS\u30e2\u30b8\u30e5\u30fc\u30eb(AE-GPS)\u3092M5STICK-C\u306b &hellip; <a href=\"https:\/\/eguchi.jp\/blog\/?p=1210\" class=\"more-link\">\u7d9a\u304d\u3092\u8aad\u3080 <span class=\"screen-reader-text\">M5STICK-C\u3067GPS\u53d7\u4fe1<\/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-1210","post","type-post","status-publish","format-standard","hentry","category-2"],"_links":{"self":[{"href":"https:\/\/eguchi.jp\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1210","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=1210"}],"version-history":[{"count":2,"href":"https:\/\/eguchi.jp\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1210\/revisions"}],"predecessor-version":[{"id":1214,"href":"https:\/\/eguchi.jp\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1210\/revisions\/1214"}],"wp:attachment":[{"href":"https:\/\/eguchi.jp\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1210"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/eguchi.jp\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1210"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/eguchi.jp\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1210"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}