2018年5月22日 星期二

DHT11 Temperature & Humidity sensor on NodeMCU using Arduino IDE


DHT11 Temperature & Humidity sensor on NodeMCU using Arduino IDE

Robo India presents tutorial on how to read temperature and humidity data through DHT11 sensor using ESP8266 wifi module on NODEMCU LUA platform.

Detailed Tutorial
1. Introduction:
The DHT11 is chosen because it is lab calibrated, accurate and stable and its signal output is digital. Most important of all, it is relatively inexpensive for the given performance. Below is the pinout of the sensor.
2. Understanding DHT11 sensor
DHT11 sensor gives humidity and temperature data. It has got following pin interface.
DHT11-Pinout_
3. Circuit
Make the following connections -
DH11-with-amica_
4. Library File
Following two libraries will be required to run this code. Download the zip file extract the same and copy this to your Arduino library folder.
This library file should be placed at the install folder of Arduino. I have a 64 bit Win7 OS and my arduino library folder address is located at
C:\Program Files (x86)\Arduino\libraries 
5. Programming
#include "DHT.h"        // including the library of DHT11 temperature and humidity sensor
#define DHTTYPE DHT11   // DHT 11

#define dht_dpin 0
DHT dht(dht_dpin, DHTTYPE); 
void setup(void)
{ 
  dht.begin();
  Serial.begin(9600);
  Serial.println("Humidity and temperature\n\n");
  delay(700);

}
void loop() {
    float h = dht.readHumidity();
    float t = dht.readTemperature();         
    Serial.print("Current humidity = ");
    Serial.print(h);
    Serial.print("%  ");
    Serial.print("temperature = ");
    Serial.print(t); 
    Serial.println("C  ");
  delay(800);
}

6. Output
Upload the above code to the NodeMCU and open serial monitor. Following output should be shown on the serial monitor.
Output
If you have any query please write us at support@roboindia.com
Thanks and Regards
Content Development Team 
Robo India
https://roboindia.com

沒有留言:

張貼留言

113 學年度第 1 學期 RFID應用課程 Arduino程式

113 學年度第 1 學期 RFID應用課程 Arduino程式 https://www.mediafire.com/file/zr0h0p3iosq12jw/MFRC522+(2).7z/file 內含修改過後的 MFRC522 程式庫 (原程式有錯誤) //定義MFRC522...