{"id":3139,"date":"2023-11-08T21:37:29","date_gmt":"2023-11-08T12:37:29","guid":{"rendered":"https:\/\/mirror.boy.jp\/?p=3139"},"modified":"2023-11-08T21:38:14","modified_gmt":"2023-11-08T12:38:14","slug":"m5stickcplus-env%e2%85%b2-hat-%e3%81%ab%e3%82%88%e3%82%8b%e6%99%82%e5%88%bb%e3%83%bb%e5%ae%a4%e6%b8%a9%e3%83%bb%e6%b9%bf%e5%ba%a6%e3%82%b5%e3%83%b3%e3%83%97%e3%83%ab","status":"publish","type":"post","link":"https:\/\/mirror.boy.jp\/?p=3139","title":{"rendered":"M5StickCPlus + ENV\u2162 Hat \u306b\u3088\u308b\u6642\u523b\u30fb\u5ba4\u6e29\u30fb\u6e7f\u5ea6\u30b5\u30f3\u30d7\u30eb"},"content":{"rendered":"\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"819\" src=\"https:\/\/mirror.boy.jp\/wp-content\/uploads\/2023\/11\/IMG_5049-1024x819.jpg\" alt=\"\" class=\"wp-image-3140\" srcset=\"https:\/\/mirror.boy.jp\/wp-content\/uploads\/2023\/11\/IMG_5049-1024x819.jpg 1024w, https:\/\/mirror.boy.jp\/wp-content\/uploads\/2023\/11\/IMG_5049-400x320.jpg 400w, https:\/\/mirror.boy.jp\/wp-content\/uploads\/2023\/11\/IMG_5049-768x614.jpg 768w, https:\/\/mirror.boy.jp\/wp-content\/uploads\/2023\/11\/IMG_5049-1536x1229.jpg 1536w, https:\/\/mirror.boy.jp\/wp-content\/uploads\/2023\/11\/IMG_5049-2048x1638.jpg 2048w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>IKEA\u3067\u8cb7\u3063\u305f\u6e29\u5ea6\u30fb\u6e7f\u5ea6\u4ed8\u304d\u306e\u6642\u8a08\u304c\u3059\u3050\u306b\u30ba\u30ec\u308b\u306e\u304c\u6c17\u306b\u306a\u3063\u305f\u306e\u3067\u3001\u624b\u6301\u3061\u306eM5StickCPlus + ENV\u2162 Hat\u3067\u7c21\u5358\u306b\u3064\u304f\u3063\u3066\u307f\u307e\u3057\u305f\u3002ENV Hat\u3092\u672c\u4f53\u306b\u76f4\u4ed8\u3051\u3059\u308b\u3068\u71b1\u304c\u3053\u3082\u308b\u304b\u672c\u4f53\u306e\u6e29\u5ea6\u306b\u5f15\u3063\u5f35\u3089\u308c\u308b\u3088\u3046\u306a\u611f\u3058\u3067+2~3\u2103\u4e0a\u304c\u3063\u3066\u3057\u307e\u3046\u554f\u984c\u304c\u3042\u3063\u305f\u306e\u3067\u9069\u5f53\u306b\u5f15\u304d\u4f38\u3070\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u4e16\u306e\u30b5\u30f3\u30d7\u30eb\u30b3\u30fc\u30c9\u3067SHT3D\u306e\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u306b\u5bfe\u3057\u3066init\u3092\u547c\u3093\u3067\u306a\u3044\u3053\u3068\u304c\u591a\u304b\u3063\u305f\u306e\u3067\u3059\u304c\u3001\u305d\u308c\u3060\u3068\u8d77\u52d5\u6642\u70b9\u3067\u52d5\u4f5c\u304c\u6b62\u307e\u3063\u3066\u3057\u307e\u3046\u306e\u3067 sht30.init()\u547c\u3093\u3067\u3044\u307e\u3059\u3002<\/p>\n\n\n\n<h1 class=\"wp-block-heading\">\u30b5\u30f3\u30d7\u30eb<\/h1>\n\n\n\n<pre class=\"wp-block-code\"><code>#include &lt;M5StickCPlus.h>\n#include &lt;WiFi.h>\n#include &lt;NTPClient.h>\n#include &lt;WiFiUdp.h>\n#include &lt;Wire.h>\n#include \"M5_ENV.h\"\n#include \"Adafruit_Sensor.h\"\n#include &lt;Adafruit_BMP280.h>\n\nWiFiUDP ntpUDP;\nNTPClient timeClient(ntpUDP, \"pool.ntp.org\", 3600 * 9);  \/\/ UTC+9 \u65e5\u672c\u6642\u9593\nString previousTime = \"\";                                \/\/ \u524d\u56de\u306e\u6642\u523b\u3092\u4fdd\u5b58\u3059\u308b\u305f\u3081\u306e\u5909\u6570\n\nSHT3X sht30;\n\nconst char *ssid = \"********\";  \/\/ \u3042\u306a\u305f\u306eWiFi\u306eSSID\nconst char *password = \"********\";       \/\/ \u3042\u306a\u305f\u306eWiFi\u306e\u30d1\u30b9\u30ef\u30fc\u30c9\n\nuint16_t rgbToColor(uint8_t r, uint8_t g, uint8_t b) {\n  return ((r &amp; 0xF8) &lt;&lt; 8) | ((g &amp; 0xFC) &lt;&lt; 3) | (b >> 3);\n}\n\nvoid setup() {\n\n  setCpuFrequencyMhz(80);\n\n  pinMode(33, INPUT_PULLUP); \/\/ GPIO33\u3092\u30d7\u30eb\u30a2\u30c3\u30d7\u5165\u529b\u306b\u8a2d\u5b9a\n\n  M5.begin();\n  M5.Lcd.setRotation(1);\n  M5.Lcd.fillScreen(BLACK);\n  uint16_t color = rgbToColor(100, 100, 100);  \/\/ \u8d64\u8272\u3092\u6307\u5b9a\n  M5.Lcd.setTextColor(color);\n  M5.Lcd.setTextSize(5);  \/\/ \u30d5\u30a9\u30f3\u30c8\u30b5\u30a4\u30ba\u3092\u5927\u304d\u304f\u8a2d\u5b9a\n\/\/  M5.Axp.ScreenBreath(10); \/\/ \u6db2\u6676\u306e\u660e\u308b\u3055\u8a2d\u5b9a\n\n  WiFi.begin(ssid, password);\n  while (WiFi.status() != WL_CONNECTED) {\n    M5.Lcd.print('.');\n    delay(500);\n  }\n\n  timeClient.begin();\n\n  Wire.end();\n  Wire.begin(0, 26);\n  sht30.init(); \/\/\u3053\u306e\u95a2\u6570\u3092\u547c\u3076\u30b5\u30f3\u30d7\u30eb\u304c\u306a\u304f\u3066\u30a8\u30e9\u30fc\u5c65\u3044\u3066\u3044\u305f\u306e\u304c\u3001\u8ffd\u52a0\u3067\u52d5\u4f5c\u3057\u305f\u30fb\u30fb\u30fb\n}\n\nvoid loop() {\n\n  timeClient.update();\n  String currentTime = timeClient.getFormattedTime();\n\n  if (currentTime != previousTime) {\n\n    \/\/ \u6e29\u5ea6\u3068\u6e7f\u5ea6\u306e\u8aad\u307f\u53d6\u308a\n    sht30.get();\n    float temperature = sht30.cTemp;  \/\/Store the temperature obtained from shT30.\n    float humidity = sht30.humidity;  \/\/Store the humidity obtained from the SHT30.\n\n    \/\/ \u30bb\u30f3\u30b5\u30fc\u306e\u5024\u3092\u753b\u9762\u306b\u8868\u793a\n    M5.Lcd.fillScreen(BLACK);\n    M5.Lcd.setCursor(0, 10);\n    M5.Lcd.println(currentTime);\n    M5.Lcd.setCursor(40, 50);\n    M5.Lcd.printf(\"%.1fC\", temperature);\n    M5.Lcd.setCursor(80, 90);\n    M5.Lcd.printf(\"%.1f%%\", humidity);\n\n    previousTime = currentTime;\n  }\n\n  delay(250);\n}<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>IKEA\u3067\u8cb7\u3063\u305f\u6e29\u5ea6\u30fb\u6e7f\u5ea6\u4ed8\u304d\u306e\u6642\u8a08\u304c\u3059\u3050\u306b\u30ba\u30ec\u308b\u306e\u304c\u6c17\u306b\u306a\u3063\u305f\u306e\u3067\u3001\u624b\u6301\u3061\u306eM5StickCPlus + ENV\u2162 Hat\u3067\u7c21\u5358\u306b\u3064\u304f\u3063\u3066\u307f\u307e\u3057\u305f\u3002ENV Hat\u3092\u672c\u4f53\u306b\u76f4\u4ed8\u3051\u3059\u308b\u3068\u71b1\u304c\u3053\u3082\u308b\u304b\u672c\u4f53\u306e\u6e29\u5ea6\u306b\u5f15\u3063\u5f35\u3089\u308c\u308b &hellip; <a href=\"https:\/\/mirror.boy.jp\/?p=3139\" class=\"more-link\">\u7d9a\u304d\u3092\u8aad\u3080 <span class=\"screen-reader-text\">M5StickCPlus + ENV\u2162 Hat \u306b\u3088\u308b\u6642\u523b\u30fb\u5ba4\u6e29\u30fb\u6e7f\u5ea6\u30b5\u30f3\u30d7\u30eb<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[49,8,131],"tags":[],"_links":{"self":[{"href":"https:\/\/mirror.boy.jp\/index.php?rest_route=\/wp\/v2\/posts\/3139"}],"collection":[{"href":"https:\/\/mirror.boy.jp\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mirror.boy.jp\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mirror.boy.jp\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mirror.boy.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3139"}],"version-history":[{"count":5,"href":"https:\/\/mirror.boy.jp\/index.php?rest_route=\/wp\/v2\/posts\/3139\/revisions"}],"predecessor-version":[{"id":3145,"href":"https:\/\/mirror.boy.jp\/index.php?rest_route=\/wp\/v2\/posts\/3139\/revisions\/3145"}],"wp:attachment":[{"href":"https:\/\/mirror.boy.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3139"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mirror.boy.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3139"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mirror.boy.jp\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3139"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}