dsi2598收dht11訊號收不到

astro1abe發佈於2020-05-29 14:19:20

瀏覽4615

回覆6

最後編輯於2024-04-27 15:18:02

有把DHT.h都下載下來並放到library 裡面了,代碼也是參考網上資源的,

有導通〈但不持續,綠色LED是只閃一下〉,甚至有信號回傳〈黃色LED也是同綠色LED閃一下〉,信號收到卻都是NAN

以下是代碼

#include "DHT.h"           // Include the DHT library 
#define DHTPIN 13        // Where you have connected you DHT Sensor
#define DHTTYPE DHT11    // Defines the type of the sensor
DHT dht(DHTPIN, DHTTYPE);

//LiquidCrystal lcd(12, 11, 5, 4, 3, 2);  // LCD connection
void setup() {
  Serial.begin(115200);             // Begins serial communication
  Serial.println("Temperature");  // prints the message Temperature on the serial monitor
  dht.begin();                    // Begins the communications with the temperature sensor
}

void loop() {
  float h = dht.readHumidity();         // reads the humidy and stores on the float variable named h
  float t = dht.readTemperature();      // reads the temperature and stores on the float variable named t

  Serial.print("Humidity: ");           // prints the message Humidity: on the serial monitor
  Serial.print(h);                      // prints the humidity value on the serial monitor
  Serial.print(" %\t");
  Serial.println();                     // goes to the next line on the serial monitor

  Serial.print("Temperature: ");        // prints the message Temperature: on the serial monitor 
  Serial.print(t);                      // prints the temperature value on the serial monitor
  Serial.print(" *C ");
  Serial.println();                     // goes to the next line on the serial monitor

  if (isnan(h) || isnan(t)) {                    //This if statement check to see if the DHT sensor is connected or disconnected
    Serial.println("Sensor is not connected");   //prints the message sensor is not connected on the serial monitor  
  }

  delay(2000);                                  // wait for two seconds
}

共6條回覆 最後由EricYang回覆於2020-05-29 20:39:46
#1
EricYang 回覆於 2020-06-06 00:26:50

太好了

#2
astro1abe 回覆於 2020-06-05 21:56:53

是嘛 原本只是想看有沒有電路導通 哈

感謝大神 成功了!!!

 

#3
EricYang 回覆於 2020-06-01 19:01:39

有兩個部分:

1. 請您 到 github 下載 使用 SimpleDHT.h 這個library

2. 建議您不能pin 腳直接接 LED 再接DHT 11 模組,您應該是要用 杜邦線 接吧; 且 DHT 11 的輸出 也會因為您接上LED 後 而無法讀到微量變化吧? 請問您這接法 是參考 哪個技術文件...

#4
astro1abe 回覆於 2020-06-01 15:19:54

我這邊的代碼內容就是先把DHT11數據訊號讀取並顯示出來而已 還沒透過BC26把資料傳到網上
錯誤代碼就是這個 Sensor is not connected 兩秒多一行 

#5
EricYang 回覆於 2020-05-29 20:40:34

是否能把錯誤訊息提供,謝謝!

#6
EricYang 回覆於 2020-05-29 20:39:46

有先開通SIM的網路嗎? 先使用 AT Command 確定 NB-IoT 是否啟用成功 

請參考 https://drive.google.com/drive/folders/1ON6T8TI-LGfHqivCGoIMjs2GVp2Hixni?usp=sharing