How to use the DHT11 Temperature and Humidity Sensor for Arduino
How to use the DHT11 Temperature and Humidity Sensor for Arduino
INTRODUCTION
A temperature and humidity sensor measures air moisture levels as well as air temperature. It is also known as a hygrometer.
APPLICATIONS
They are used in the care of wooden musical instruments such as pianos, guitars, violins, etc. They are also used in some incubators and museums and greenhouses.
WIRING DIAGRAM
VCC – 5V
OUT – Digital Pin 2
GND - GND
CODE
Note: Download the required library and follow these steps below:
- Download the DHT.h library here https://github.com/adafruit/DHT-sensor-library
- Rename the folder to name without “-master” and put the folder in “arduino/libraries.”
- Put the DHT-sensor-library folder in “arduino/libraries.”
#include<dht.h> dht DHT; // if you require to change the pin number, Edit the pin with your arduino pin. #define DHT11_PIN 2 void setup() { Serial.begin(9600); Serial.println("welcome to TechPonder Humidity and temperature Detector"); } void loop() { // READ DATA int chk = DHT.read11(DHT11_PIN); Serial.println(" Humidity " ); Serial.println(DHT.humidity, 1); Serial.println(" Temparature "); Serial.println(DHT.temperature, 1); delay(2000); }
END RESULT
Open serial monitor. The current humidity and temperature should be displayed.
ADDITIONAL RESOURCES
https://www.instructables.com/How-to-interface-Humidity-and-Temperature-DTH11-Se/