{"id":1241,"date":"2022-05-15T20:26:32","date_gmt":"2022-05-15T12:26:32","guid":{"rendered":"http:\/\/hower.forwebs.net\/robot\/?p=1241"},"modified":"2022-05-22T20:10:01","modified_gmt":"2022-05-22T12:10:01","slug":"%e4%b8%8b%e6%9c%9f%e7%ac%ac11%e5%a0%82line%e5%82%b3%e8%a8%8a%e6%a9%9f%e5%99%a8%e4%ba%ba","status":"publish","type":"post","link":"https:\/\/hower.forwebs.net\/robot\/archives\/1241","title":{"rendered":"\u4e0b\u671f\u7b2c11\u5802[IOT\u6a5f\u5668\u4eba] [Line\u63a5\u6536\u6578\u64da]"},"content":{"rendered":"\n<p>\u4eca\u5929\u8981\u5229\u7528Line\u50b3\u8a0a\u6a5f\u5668\u4eba\uff0c\u628a\u7269\u806f\u7db2\u8490\u96c6\u5230\u7684\u6578\u64da\uff0c\u50b3\u9001\u5230\u804a\u5929\u5ba4\uff0c\u7528\u624b\u6a5f\u5c31\u53ef\u4ee5\u96a8\u6642\u638c\u63e1\u8a0a\u606f\u3002<\/p>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<p><a href=\"http:\/\/hower.forwebs.net\/robot\/archives\/1080\" target=\"_blank\" rel=\"noreferrer noopener\">\u5efa\u7f6e\u4e3b\u677f<\/a><\/p>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<p>\u9023\u63a5DHT11<\/p>\n\n\n\n<p>\u63a5\u7dda:<br>GND\u2014 G<br>VCC\u2014 3V<br>S \u2014 D1<\/p>\n\n\n\n<p class=\"has-pale-cyan-blue-background-color has-background\">\u6ce8\u610f : D1\u4e0d\u662f\u7b2c1\u8173<\/p>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<p>\u6e2c\u8a66\u611f\u6e2c\u6eab\u5ea6<\/p>\n\n\n\n<p><a href=\"http:\/\/hower.forwebs.net\/robot\/archives\/1057\" target=\"_blank\" rel=\"noreferrer noopener\">http:\/\/hower.forwebs.net\/robot\/archives\/1057<\/a><\/p>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<p>\u7533\u8acb Line Notify<\/p>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<p>\u4e0b\u8f09<\/p>\n\n\n\n<p><a href=\"https:\/\/github.com\/TridentTD\/TridentTD_LineNotify\">https:\/\/github.com\/TridentTD\/TridentTD_LineNotify<\/a><\/p>\n\n\n\n<p>\u653e\u5728<\/p>\n\n\n\n<figure class=\"wp-duotone-000000-00a5ff-1 wp-block-image size-full\"><img decoding=\"async\" loading=\"lazy\" width=\"479\" height=\"424\" src=\"http:\/\/hower.forwebs.net\/robot\/wp-content\/uploads\/sites\/2\/2022\/05\/image-7.png\" alt=\"\" class=\"wp-image-1251\" srcset=\"https:\/\/hower.forwebs.net\/robot\/wp-content\/uploads\/sites\/2\/2022\/05\/image-7.png 479w, https:\/\/hower.forwebs.net\/robot\/wp-content\/uploads\/sites\/2\/2022\/05\/image-7-300x266.png 300w\" sizes=\"(max-width: 479px) 100vw, 479px\" \/><\/figure>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<pre class=\"wp-block-code\"><code>#include &lt;ESP8266WiFi.h&gt;\n#include &lt;WiFiClient.h&gt;\n#include &lt;DHT.h&gt;\n#include &lt;TridentTD_LineNotify.h&gt;\n\n#define DHTTYPE DHT11\n#define DHTPIN  5\n\n\/\/ \u4fee\u6539 Token\u865f\u78bc\n#define LINE_TOKEN \"\"\n\n\/\/ \u7121\u7dda\u57fa\u5730\u53f0SSID\u8ddf\u5bc6\u78bc\nconst char* ssid     = \"\";\nconst char* password = \"\";\n\nDHT dht(DHTPIN, DHTTYPE, 11);    \/\/ 11 works fine for ESP8266\n \nfloat humidity, temp_f;   \/\/ \u5f9e DHT-11 \u8b80\u53d6\u7684\u503c\n\nunsigned long previousMillis = 0;        \/\/ will store last temp was read\nconst long interval = 2000;              \/\/ interval at which to read sensor\n\n \nvoid setup(void)\n{\n  Serial.begin(9600);  \/\/ \u8a2d\u5b9a\u901f\u7387 \u611f\u6e2c\u5668\n  dht.begin();           \/\/ \u521d\u59cb\u5316\n\n  WiFi.mode(WIFI_STA);\n  \/\/ \u9023\u63a5\u7121\u7dda\u57fa\u5730\u53f0\n  WiFi.begin(ssid, password);\n  Serial.print(\"\\n\\r \\n\\rWorking to connect\");\n\n  \/\/ \u7b49\u5f85\u9023\u7dda\uff0c\u4e26\u5f9e Console\u986f\u793a IP\n  while (WiFi.status() != WL_CONNECTED) {\n    delay(500);\n    Serial.print(\".\");\n  }\n  Serial.println(\"\");\n  Serial.println(\"DHT Weather Reading Server\");\n  Serial.print(\"Connected to \");\n  Serial.println(ssid);\n  Serial.print(\"IP address: \");\n  Serial.println(WiFi.localIP());\n}\n \nvoid loop(void)\n{\n  \/\/ \u91cf\u6e2c\u9593\u7b49\u5f85\u81f3\u5c11 2 \u79d2\n  unsigned long currentMillis = millis();\n \n  if(currentMillis - previousMillis &gt;= interval) {\n    \/\/ \u5c07\u6700\u5f8c\u8b80\u53d6\u611f\u6e2c\u503c\u7684\u6642\u9593\u7d00\u9304\u4e0b\u4f86 \n    previousMillis = currentMillis;   \n\n    \/\/ \u8b80\u53d6\u6eab\u5ea6\u5927\u7d04 250 \u5fae\u79d2!\n    humidity = dht.readHumidity();          \/\/ \u8b80\u53d6\u6fd5\u5ea6(\u767e\u5206\u6bd4)\n    temp_f = dht.readTemperature(true);     \/\/ \u8b80\u53d6\u6eab\u5ea6(\u83ef\u6c0f)\n    \n \n    \/\/ \u6aa2\u67e5\u5169\u500b\u503c\u662f\u5426\u70ba\u7a7a\u503c\n    if (isnan(humidity) || isnan(temp_f)) {\n       Serial.println(\"Failed to read from DHT sensor!\");\n       return;\n    }\n  }\n\n  String tempe=\"\u6eab\u5ea6:\"+String((int)(temp_f-32)*5\/9)+\"\u2103\";   \n  String humid=\"\u6fd5\u5ea6:\"+String((int)humidity)+\"\uff05\";\n\n  \/\/ \u986f\u793a Line\u7248\u672c\n  Serial.println(LINE.getVersion());\n \n  LINE.setToken(LINE_TOKEN);\n\n  \/\/ \u5148\u63db\u884c\u518d\u986f\u793a\n  LINE.notify(\"\\n\" + tempe + \" \uff1b\" + humid);\n      \n  \/\/ \u6bcf2\u5206\u9418\u767c\u9001\u4e00\u6b21\n  delay(120000);\n}<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" loading=\"lazy\" width=\"460\" height=\"1024\" src=\"http:\/\/hower.forwebs.net\/robot\/wp-content\/uploads\/sites\/2\/2022\/05\/162445-460x1024.jpg\" alt=\"\" class=\"wp-image-1255\" srcset=\"https:\/\/hower.forwebs.net\/robot\/wp-content\/uploads\/sites\/2\/2022\/05\/162445-460x1024.jpg 460w, https:\/\/hower.forwebs.net\/robot\/wp-content\/uploads\/sites\/2\/2022\/05\/162445-135x300.jpg 135w, https:\/\/hower.forwebs.net\/robot\/wp-content\/uploads\/sites\/2\/2022\/05\/162445-768x1710.jpg 768w, https:\/\/hower.forwebs.net\/robot\/wp-content\/uploads\/sites\/2\/2022\/05\/162445-690x1536.jpg 690w, https:\/\/hower.forwebs.net\/robot\/wp-content\/uploads\/sites\/2\/2022\/05\/162445.jpg 857w\" sizes=\"(max-width: 460px) 100vw, 460px\" \/><\/figure>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<p>\u7df4\u7fd2\u4e00\u4e0b<\/p>\n\n\n\n<p>\u6539\u500b\u6b61\u8fce\u8a5e\u5427<\/p>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><img decoding=\"async\" loading=\"lazy\" src=\"http:\/\/hower.forwebs.net\/robot\/wp-content\/uploads\/sites\/2\/2022\/05\/image-8.png\" alt=\"\" class=\"wp-image-1260\" width=\"494\" height=\"494\" srcset=\"https:\/\/hower.forwebs.net\/robot\/wp-content\/uploads\/sites\/2\/2022\/05\/image-8.png 659w, https:\/\/hower.forwebs.net\/robot\/wp-content\/uploads\/sites\/2\/2022\/05\/image-8-300x300.png 300w, https:\/\/hower.forwebs.net\/robot\/wp-content\/uploads\/sites\/2\/2022\/05\/image-8-150x150.png 150w, https:\/\/hower.forwebs.net\/robot\/wp-content\/uploads\/sites\/2\/2022\/05\/image-8-80x80.png 80w, https:\/\/hower.forwebs.net\/robot\/wp-content\/uploads\/sites\/2\/2022\/05\/image-8-320x320.png 320w\" sizes=\"(max-width: 494px) 100vw, 494px\" \/><\/figure>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<p>2\u5206\u9418\u9593\u9694\u662f\u70ba\u4e86\u6e2c\u8a66\uff0c\u5be6\u969b\u4f7f\u7528\u4e0d\u8981\u5982\u6b64\u5bc6\u96c6\uff0c<\/p>\n\n\n\n<p>\u66f4\u9ad8\u7d1a\u7684\u65b9\u6cd5\uff0c\u53ef\u4ee5\u601d\u8003\u5982\u4f55\u5beb\u6210&#8221;\u6eab\u5ea6\u6709\u6240\u8b8a\u52d5\u624d\u767c\u8a0a&#8221;<\/p>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<p>\u8acb\u4e0a Google Classroom \u56de\u7b54\u4eca\u65e5\u554f\u984c<\/p>\n\n\n\n<p>\u8acb\u5c0f\u7d44\u898f\u756b\u4e00\u500bIOT\u7684\u4f5c\u54c1<\/p>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n","protected":false},"excerpt":{"rendered":"<p>\u4eca\u5929\u8981\u5229\u7528Line\u50b3\u8a0a\u6a5f\u5668\u4eba\uff0c\u628a\u7269\u806f\u7db2\u8490\u96c6\u5230\u7684\u6578\u64da\uff0c\u50b3\u9001\u5230\u804a\u5929\u5ba4\uff0c\u7528&#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":1260,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[2],"tags":[],"_links":{"self":[{"href":"https:\/\/hower.forwebs.net\/robot\/wp-json\/wp\/v2\/posts\/1241"}],"collection":[{"href":"https:\/\/hower.forwebs.net\/robot\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/hower.forwebs.net\/robot\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/hower.forwebs.net\/robot\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/hower.forwebs.net\/robot\/wp-json\/wp\/v2\/comments?post=1241"}],"version-history":[{"count":14,"href":"https:\/\/hower.forwebs.net\/robot\/wp-json\/wp\/v2\/posts\/1241\/revisions"}],"predecessor-version":[{"id":1267,"href":"https:\/\/hower.forwebs.net\/robot\/wp-json\/wp\/v2\/posts\/1241\/revisions\/1267"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/hower.forwebs.net\/robot\/wp-json\/wp\/v2\/media\/1260"}],"wp:attachment":[{"href":"https:\/\/hower.forwebs.net\/robot\/wp-json\/wp\/v2\/media?parent=1241"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/hower.forwebs.net\/robot\/wp-json\/wp\/v2\/categories?post=1241"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/hower.forwebs.net\/robot\/wp-json\/wp\/v2\/tags?post=1241"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}