找回密碼
 立即注冊

QQ登錄

只需一步,快速開始

帖子
查看: 4812|回復(fù): 4
打印 上一主題 下一主題
收起左側(cè)

Arduino esp8266 blinker溫濕度監(jiān)控源碼

[復(fù)制鏈接]
跳轉(zhuǎn)到指定樓層
樓主
ID:721896 發(fā)表于 2020-5-7 12:25 | 只看該作者 回帖獎(jiǎng)勵(lì) |倒序?yàn)g覽 |閱讀模式
遠(yuǎn)程溫濕度監(jiān)控,blinker遠(yuǎn)程監(jiān)控,arduino源碼
  1. #define BLINKER_WIFI

  2. #include <Blinker.h>
  3. #include <DHT.h>

  4. char auth[] = "20ce32208396"; //上一步中在app中獲取到的Secret Key(新建設(shè)備的秘鑰)

  5. char ssid[] = "PIG"; //你的WiFi熱點(diǎn)名稱

  6. char pswd[] = "Zq128hw923"; //你的WiFi密碼

  7. BlinkerNumber HUMI("humi");
  8. BlinkerNumber TEMP("temp");

  9. #define DHTPIN 5  //溫濕度接的是GPIO5端口
  10. #define DHTTYPE DHT11   // DHT 11
  11. //#define DHTTYPE DHT22   // DHT 22  (AM2302), AM2321
  12. //#define DHTTYPE DHT21   // DHT 21 (AM2301)

  13. DHT dht(DHTPIN, DHTTYPE);

  14. float humi_read = 0, temp_read = 0;

  15. void heartbeat()
  16. {
  17.     //反饋溫度數(shù)據(jù)
  18.     HUMI.print(humi_read);
  19.     //設(shè)置ui組件圖標(biāo)和顏色
  20.     HUMI.icon("fas fa-thermometer-2");
  21.     HUMI.color("#fddb10");

  22.     //反饋濕度數(shù)據(jù)
  23.     TEMP.print(temp_read);
  24.     TEMP.icon("fas fa-heart");
  25.     HUMI.color("#fddb01");
  26. }

  27. void dataStorage()
  28. {
  29.   Blinker.dataStorage("temp",temp_read);
  30.   Blinker.dataStorage("humi",humi_read);
  31. }

  32. void setup()
  33. {
  34.     Serial.begin(115200);
  35.     pinMode(PIR_sensor,INPUT);
  36.     BLINKER_DEBUG.stream(Serial);
  37.     BLINKER_DEBUG.debugAll();
  38.     pinMode(LED_BUILTIN, OUTPUT);
  39.     digitalWrite(LED_BUILTIN, LOW);

  40.     Blinker.begin(auth, ssid, pswd);
  41.     Blinker.attachHeartbeat(heartbeat);
  42.     Blinker.attachDataStorage(dataStorage);
  43.     dht.begin();
  44. }

  45. void loop()
  46. {
  47.     Blinker.run();
  48.     float h = dht.readHumidity();
  49.     float t = dht.readTemperature();
  50.    
  51.     if (isnan(h) || isnan(t))
  52.     {
  53.         BLINKER_LOG("Failed to read from DHT sensor!");
  54.     }
  55.     else
  56.     {
  57.         BLINKER_LOG("Humidity: ", h, " %");
  58.         BLINKER_LOG("Temperature: ", t, " *C");
  59.         humi_read = h;
  60.         temp_read = t;
  61.     }
  62.     if (t > 20)
  63.     {
  64.         Blinker.wechat("Title:機(jī)房溫度","state:temperature high" ,"Message:機(jī)房溫度過高");
  65.         Blinker.sms("機(jī)房溫度過高!");
  66.     }
  67.     Blinker.delay(2000);
  68. }
復(fù)制代碼

分享到:  QQ好友和群QQ好友和群 QQ空間QQ空間 騰訊微博騰訊微博 騰訊朋友騰訊朋友
收藏收藏3 分享淘帖 頂 踩
回復(fù)

使用道具 舉報(bào)

沙發(fā)
ID:1 發(fā)表于 2020-5-7 16:15 | 只看該作者
本帖需要重新編輯補(bǔ)全電路原理圖,源碼,詳細(xì)說明與圖片即可獲得100+黑幣(帖子下方有編輯按鈕)
回復(fù)

使用道具 舉報(bào)

板凳
ID:615995 發(fā)表于 2020-5-10 21:59 來自觸屏版 | 只看該作者
謝謝分享
回復(fù)

使用道具 舉報(bào)

地板
ID:101726 發(fā)表于 2020-5-11 00:23 | 只看該作者
值得學(xué)習(xí)
回復(fù)

使用道具 舉報(bào)

5#
ID:768465 發(fā)表于 2020-6-3 15:16 來自觸屏版 | 只看該作者
這個(gè)需要app嗎?
回復(fù)

使用道具 舉報(bào)

您需要登錄后才可以回帖 登錄 | 立即注冊

本版積分規(guī)則

小黑屋|51黑電子論壇 |51黑電子論壇6群 QQ 管理員QQ:125739409;技術(shù)交流QQ群281945664

Powered by 單片機(jī)教程網(wǎng)

快速回復(fù) 返回頂部 返回列表