{"id":18253,"date":"2020-04-09T14:00:34","date_gmt":"2020-04-09T05:00:34","guid":{"rendered":"https:\/\/www.skyarch.net\/blog\/?p=18253"},"modified":"2020-04-21T17:12:51","modified_gmt":"2020-04-21T08:12:51","slug":"m5stack%e3%81%a7%e9%96%8b%e7%99%ba%e7%92%b0%e5%a2%83%e6%a7%8b%e7%af%89-wifi%e6%8e%a5%e7%b6%9a%e5%8f%8a%e3%81%b3httpclient%e5%8b%95%e4%bd%9c%e3%82%92%e8%a9%a6%e3%81%99","status":"publish","type":"post","link":"https:\/\/www.skyarch.net\/blog\/m5stack%e3%81%a7%e9%96%8b%e7%99%ba%e7%92%b0%e5%a2%83%e6%a7%8b%e7%af%89-wifi%e6%8e%a5%e7%b6%9a%e5%8f%8a%e3%81%b3httpclient%e5%8b%95%e4%bd%9c%e3%82%92%e8%a9%a6%e3%81%99\/","title":{"rendered":"M5Stack\u3067\u958b\u767a\u74b0\u5883\u69cb\u7bc9 &#8211; Wifi\u63a5\u7d9a\u53ca\u3073HttpClient\u52d5\u4f5c\u3092\u8a66\u3059"},"content":{"rendered":"<h1>\u306f\u3058\u3081\u306b<\/h1>\n<p>1\u5e74\u307b\u3069\u653e\u7f6e\u3057\u3066\u3044\u305fM5Stack\u3092\u4f7f\u3063\u3066\u3001\u958b\u767a\u74b0\u5883\u4f5c\u6210\/Wifi\u63a5\u7d9a\u3001HttpClient\u52d5\u4f5c\u3092\u8a66\u3057\u3066\u307f\u307e\u3057\u305f\u3002<br \/>\n(\u7a4d\u3093\u8aad\u3001\u7a4d\u307f\u30b2\u30fc\u3001\u8cb7\u3063\u305f\u30c7\u30d0\u30a4\u30b9\u306a\u308a\u57fa\u76e4\u3092\u4f7f\u308f\u306a\u3044\u653e\u7f6e\u72b6\u614b\u3063\u3066\u5358\u8a9e\u3042\u308b\u3093\u3067\u3059\u304b\u306d\u3047)<\/p>\n<p>\u60c5\u5831\u3082\u8272\u3005\u3068\u3042\u308b\u4e8b\u3068\u3001\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30eb\u30c9\u30ad\u30e5\u30e1\u30f3\u30c8\u3001ArduinoIDE\u306e\u30b9\u30b1\u30c3\u30c1\u30d6\u30c3\u30af\u6a5f\u80fd\u306e\u304a\u304b\u3052\u3067\u30011\u6642\u9593\u639b\u304b\u3089\u305a\u306b\u958b\u767a\u74b0\u5883\u69cb\u7bc9\u3001HttpClient\u52d5\u4f5c\u307e\u3067\u6f15\u304e\u7740\u3051\u305f\u306e\u3067\u3084\u308a\u305f\u3044\u4e8b\u3092\u5f62\u306b\u3059\u308b\u306e\u304c\u624b\u3063\u53d6\u308a\u65e9\u304f\u3066\u3088\u3044\u3067\u3059\u306d\u3002<\/p>\n<p>\u5c0f\u3055\u3044\u3067\u3059\u304c\u30dc\u30bf\u30f3\u304c3\u3064\u4ed8\u3044\u3066\u3044\u308b\u306e\u3067\u30ea\u30e2\u30fc\u30c8\u30ef\u30fc\u30af\u304c\u677f\u306b\u3064\u3044\u3066\u304d\u305f\u6240\u3067\u3001\u96e2\u5e2d\u4e2d\u3067\u3042\u308b\u4e8b\u3092Slack\u306b\u901a\u77e5\u3059\u308bThing\u3092\u4f5c\u3063\u3066\u307f\u305f\u3044\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n<h2>\u51fa\u6765\u305f\u3082\u306e<\/h2>\n<p>\u3053\u3061\u3089\u306e\u30d6\u30ed\u30b0\u306eRSS\u60c5\u5831\u3092\u53d6\u5f97\u3057\u3066\u8868\u793a\u3057\u3066\u307f\u307e\u3057\u305f\u3002 (\u65e5\u672c\u8a9e\u5316\u3051\u3057\u3066\u307e\u3059)<br \/>\n<img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.skyarch.net\/blog\/wp-content\/uploads\/2020\/04\/IMG_20200409_131854-768x1024.jpg\" alt=\"\" width=\"728\" height=\"971\" class=\"aligncenter size-large wp-image-18259\" \/><\/p>\n<p>M5Stack\u306e\u7d39\u4ecb\u8a18\u4e8b\u306f\u6ca2\u5c71\u51fa\u3066\u304d\u307e\u3059\u306e\u3067\u5272\u611b\u3057\u307e\u3059\u3002<br \/>\n<a href=\"https:\/\/m5stack.com\/\">https:\/\/m5stack.com\/<\/a><\/p>\n<h2>\u76ee\u6b21<\/h2>\n<ul>\n<li><a href=\"#overview\">\u624b\u9806\u306e\u6982\u8981<\/a><\/li>\n<li><a href=\"#env\">\u5b9f\u884c\u74b0\u5883<\/a><\/li>\n<li><a href=\"#tejun\">\u624b\u9806<\/a><\/li>\n<li><a href=\"#matome\">\u307e\u3068\u3081<\/a><\/li>\n<\/ul>\n<h2 id=\"overview\">\u624b\u9806\u306e\u6982\u8981<\/h2>\n<ol>\n<li>\u30c9\u30e9\u30a4\u30d0\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb<\/li>\n<li>ArduinoIDE\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb<\/li>\n<li>ArduinoIDE\u5185\u306eBoardManager\u3078M5 Stack\u3092\u8ffd\u52a0<\/li>\n<li>ArduinoIDE\u5185\u306eLibraryManager\u3078M5 Stack\u3092\u8ffd\u52a0<\/li>\n<li>ArduinoIDE\u3067\u30dc\u30fc\u30c9(M5Stack-Core-ESP32)\/\u30b7\u30ea\u30a2\u30eb\u30dd\u30fc\u30c8\u9078\u629e(\/dev\/cu.SLAB_USBtoUART)<\/li>\n<li>\u30b3\u30fc\u30c9\u66f8\u304f<\/li>\n<li>\u30b3\u30f3\u30d1\u30a4\u30eb&amp;M5Stack\u3078\u8ee2\u9001<\/li>\n<\/ol>\n<p>\u5168\u3066\u4e0b\u8a18\u516c\u5f0f\u30c9\u30ad\u30e5\u30e1\u30f3\u30c8\u306b\u6cbf\u3063\u3066\u5b9f\u65bd<br \/>\n<a href=\"https:\/\/docs.m5stack.com\/#\/en\/arduino\/arduino_development\">https:\/\/docs.m5stack.com\/#\/en\/arduino\/arduino_development<\/a><\/p>\n<h3>\u63a5\u7d9a\u3057\u305fM5Stack\u304c\u8a8d\u8b58\u3055\u308c\u3066\u3044\u308b\u304b\u78ba\u8a8d<\/h3>\n<p>\u203b\u30c9\u30e9\u30a4\u30d0\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u5f8c<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n\u63a5\u7d9a\u524d\n~ $ ls -la \/dev | grep UART\n\n\u63a5\u7d9a\u5f8c\n~ $ ls -la \/dev | grep UART\ncrw-rw-rw- 1 root wheel 18, 19 4 9 12:42 cu.SLAB_USBtoUART\ncrw-rw-rw- 1 root wheel 18, 18 4 9 12:42 tty.SLAB_USBtoUART\n<\/pre>\n<h2 id=\"env\">\u5b9f\u884c\u74b0\u5883<\/h2>\n<p>MacOS\u4e0a\u3067\u5b9f\u65bd\u3057\u307e\u3057\u305f\u3002<\/p>\n<h2 id=\"tejun\">\u624b\u9806<\/h2>\n<p>\u30b3\u30fc\u30c9\u306b\u3064\u3044\u3066\u4e88\u3081\u7528\u610f\u3055\u308c\u3066\u3044\u308b\u30b9\u30b1\u30c3\u30c1\u30d6\u30c3\u30af\u304b\u3089\u4e0b\u8a18\u3092\u53c2\u8003\u306b\u4f5c\u6210\u3057\u307e\u3057\u305f\u3002<br \/>\n- BasicHTTPClient<br \/>\n- Display<\/p>\n<h3>\u30b3\u30fc\u30c9<\/h3>\n<p>\u203b10\u79d2\u6bce\u306bHTTP\u30ea\u30af\u30a8\u30b9\u30c8\u304c\u5b9f\u65bd\u3055\u308c\u307e\u3059<br \/>\n\u8ffd\u8a18: \u5185\u8535\u30b9\u30d4\u30fc\u30ab\u30fc\u304b\u3089\u9ad8\u97f3\u304c\u30d4\u30fc\u30d4\u30fc\u306a\u308b\u305f\u3081\u3001\u304a\u307e\u3058\u306a\u3044\u3068\u3057\u3066SperkerOff\u547d\u4ee4\u3092\u8ffd\u8a18<\/p>\n<pre>\n#include &lt;Arduino.h&gt;\n#include &lt;WiFi.h&gt;\n#include &lt;WiFiMulti.h&gt;\n#include &lt;HTTPClient.h&gt;\n#include &lt;M5Stack.h&gt;\n \n#define WIFI_SSID \"[\u3054\u81ea\u8eab\u306e\u74b0\u5883\u306eWifiSSID]\"\n#define WIFI_PASS \"[\u3054\u81ea\u8eab\u306e\u74b0\u5883\u306eWifiPassowrd]\"\n\nconst char* ca = \\ \n\"-----BEGIN CERTIFICATE-----\\n\" \\  \n\"MII...\\n\" \\  \/\/ CA\u306e\u4e2d\u8eab\u306b\u3064\u3044\u3066\u306f\u3001M5Stack\/M5Stick\u306eBasicHTTPClient\u30b9\u30b1\u30c3\u30c1\u7b49\u304b\u3089\u53d6\u5f97\u4e0b\u3055\u3044\n\"-----END CERTIFICATE-----\\n\";\n\nWiFiMulti wifiMulti;\nHTTPClient http;\n\n\/\/ the setup routine runs once when M5Stack starts up\nvoid setup() {\n  \/\/ initialize the M5Stack object\n  M5.begin();\n  dacWrite(25, 0); \/\/ Speaker Off\n\n  \/*\n    Power chip connected to gpio21, gpio22, I2C device\n    Set battery charging voltage and current\n    If used battery, please call this function in your project\n  *\/\n  M5.Power.begin();\n  \n  \/\/ text print\n  M5.Lcd.fillScreen(BLACK);\n  M5.Lcd.setCursor(10, 10);\n  M5.Lcd.setTextColor(WHITE);\n  M5.Lcd.setTextSize(1);\n  M5.Lcd.printf(\"Boot Complete\");\n\n  \/\/ WifiSetup\n  wifiMulti.addAP(WIFI_SSID, WIFI_PASS);\n}\n\n\/\/ the loop routine runs over and over again forever\nvoid loop(){\n  \/\/ wait for WiFi connection\n  if((wifiMulti.run() == WL_CONNECTED)) {\n\n      HTTPClient http;\n      \/\/HTTPS\n      http.begin(\"https:\/\/www.skyarch.net\/blog\/?feed=rss2\", ca);\n\n      \/\/ start connection and send HTTP header\n      int httpCode = http.GET();\n\n      \/\/ httpCode will be negative on error\n      if(httpCode > 0) {\n          \/\/ HTTP header has been send and Server response header has been handled\n          M5.Lcd.printf(\"[HTTP] GET... code: %d\\n\", httpCode);\n\n          \/\/ file found at server\n          if(httpCode == HTTP_CODE_OK) {\n              String payload = http.getString();\n              M5.Lcd.println(payload);\n          }\n      } else {\n          M5.Lcd.printf(\"[HTTP] GET... failed, error: %s\\n\", http.errorToString(httpCode).c_str());\n      }\n\n      http.end();\n  }\n\n  \/\/ Wait\n  delay(10000);\n}\n<\/pre>\n<h4>\u30b3\u30f3\u30d1\u30a4\u30eb<\/h4>\n<p>\u5de6\u4e0a\u306e\u30c1\u30a7\u30c3\u30af\u30de\u30fc\u30af\u306e\u30dc\u30bf\u30f3\u3092\u62bc\u4e0b<br \/>\n<img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.skyarch.net\/blog\/wp-content\/uploads\/2020\/04\/compile-967x1024.png\" alt=\"\" width=\"728\" height=\"771\" class=\"aligncenter size-large wp-image-18288\" \/><\/p>\n<h4>M55Stack\u3078\u8ee2\u9001<\/h4>\n<p>\u5de6\u4e0a\u306e\u53f3\u77e2\u5370\u30dc\u30bf\u30f3\u3092\u62bc\u4e0b<br \/>\n<img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.skyarch.net\/blog\/wp-content\/uploads\/2020\/04\/transfer-963x1024.png\" alt=\"\" width=\"728\" height=\"774\" class=\"aligncenter size-large wp-image-18289\" \/><\/p>\n<h2 id=\"matome\">\u307e\u3068\u3081<\/h2>\n<p>\u3084\u308a\u305f\u3044\u4e8b\u3092\u30b7\u30f3\u30d7\u30eb\u306b\u5b9f\u88c5\u3067\u304d\u308b\u305f\u3081\u3002PoC\u4f5c\u6210\u7b49\u304c\u6357\u308a\u305d\u3046\u3067\u3059\u3002<br \/>\nLCD\u5468\u308a\u306e\u30e9\u30a4\u30d6\u30e9\u30ea\u306b\u3064\u3044\u3066\u3082\u3001\u753b\u50cf\u8868\u793a\u3001QR\u30b3\u30fc\u30c9\u8868\u793a\u30e9\u30a4\u30d6\u30e9\u30ea\u7b49\u3082\u6700\u521d\u304b\u3089\u5b9f\u88c5\u3055\u308c\u3066\u304a\u308a\u3001\u5922\u304c\u5e83\u304c\u308a\u307e\u3059\u306d\uff01<br \/>\n<a href=\"https:\/\/github.com\/m5stack\/m5-docs\/blob\/master\/docs\/ja\/api\/lcd.md\">https:\/\/github.com\/m5stack\/m5-docs\/blob\/master\/docs\/ja\/api\/lcd.md<\/a><\/p>\n<p>\u4e00\u65b9\u3067\u3001\u4e00\u822c\u7684\u306a\u30de\u30a4\u30b3\u30f3\u7b49\u3067\u30dc\u30bf\u30f3\u62bc\u4e0b\u51e6\u7406\u7b49\u306b\u4f7f\u308f\u308c\u308b\u5272\u308a\u8fbc\u307f\u6a5f\u80fd\u7b49\u306f\u5c11\u3057\u8abf\u3079\u3066\u3082\u3042\u307e\u308a\u30b5\u30f3\u30d7\u30eb\u7b49\u304c\u51fa\u3066\u3044\u306a\u3044\u306e\u3067\u642d\u8f09\u3055\u308c\u3066\u3044\u308bESP32\u30c1\u30c3\u30d7\u306b\u3064\u3044\u3066\u3082\u3046\u5c11\u3057\u77e5\u308b\u5fc5\u8981\u304c\u3042\u308a\u305d\u3046\u3067\u3059\u3002<\/p>\n<p>\u6b21\u306f\u30dc\u30bf\u30f3\u3092\u62bc\u3057\u305f\u3089\u3001Slack\u3078\u30e1\u30c3\u30bb\u30fc\u30b8\u9001\u4fe1\u3092\u5b9f\u65bd\u3057\u3066\u307f\u305f\u3044\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n<p>\u5b9f\u65bd\u3057\u3066\u307f\u307e\u3057\u305f<br \/>\n<a href=\"https:\/\/www.skyarch.net\/blog\/?p=18315\">https:\/\/www.skyarch.net\/blog\/?p=18315<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u306f\u3058\u3081\u306b 1\u5e74\u307b\u3069\u653e\u7f6e\u3057\u3066\u3044\u305fM5Stack\u3092\u4f7f\u3063\u3066\u3001\u958b\u767a\u74b0\u5883\u4f5c\u6210\/Wifi\u63a5\u7d9a\u3001HttpClient\u52d5\u4f5c\u3092\u8a66\u3057\u3066\u307f\u307e\u3057\u305f\u3002 (\u7a4d\u3093\u8aad\u3001\u7a4d\u307f\u30b2\u30fc\u3001\u8cb7\u3063\u305f\u30c7\u30d0\u30a4\u30b9\u306a\u308a\u57fa\u76e4\u3092\u4f7f\u308f\u306a\u3044\u653e\u7f6e\u72b6\u614b\u3063\u3066\u5358\u8a9e\u3042\u308b\u3093\u3067\u3059\u304b\u306d\u3047) \u60c5\u5831\u3082&#8230;<\/p>\n","protected":false},"author":2,"featured_media":18254,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_locale":"ja","_original_post":"https:\/\/www.skyarch.net\/blog\/?p=18253","footnotes":""},"categories":[115],"tags":[],"class_list":{"0":"post-18253","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"has-post-thumbnail","7":"category-iot","8":"ja"},"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.skyarch.net\/blog\/wp-json\/wp\/v2\/posts\/18253","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.skyarch.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.skyarch.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.skyarch.net\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.skyarch.net\/blog\/wp-json\/wp\/v2\/comments?post=18253"}],"version-history":[{"count":16,"href":"https:\/\/www.skyarch.net\/blog\/wp-json\/wp\/v2\/posts\/18253\/revisions"}],"predecessor-version":[{"id":18388,"href":"https:\/\/www.skyarch.net\/blog\/wp-json\/wp\/v2\/posts\/18253\/revisions\/18388"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.skyarch.net\/blog\/wp-json\/wp\/v2\/media\/18254"}],"wp:attachment":[{"href":"https:\/\/www.skyarch.net\/blog\/wp-json\/wp\/v2\/media?parent=18253"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.skyarch.net\/blog\/wp-json\/wp\/v2\/categories?post=18253"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.skyarch.net\/blog\/wp-json\/wp\/v2\/tags?post=18253"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}