DHT11 (Digital Temperature and Humidity sensor) is a composite Sensor that contains a calibrated digital signal output of the temperature and humidity.
In this tutorial, How to interface DHT11 (Temperature and Humidity Sensor) sensor to arduino is explained.
CONNECTIONS :
ARDUINO DHT 11
5v - 5v
Gnd - Gnd
2 - Data pin
PROCEDURE :
- Download the Dht library from https://github.com/adafruit/DHT-sensor-library.
- And paste it in the library folder of Arduino(It will be in C:/Program Files (x86)/Arduino/libraries).
- While compling if it shows Adafruit_Sensor.h missing download it from https://github.com/adafruit/Adafruit_Sensor and paste it into the library folder.
Program for Arduino:
- Open the Arduino software and open the DHTtester file from File–>Examples–>DHT sensor library–>DHTtester.
2. Comment the DHT22 dht type line and uncomment the DHT11 dht type line as shown below
1 2 3 4 | // Uncomment whatever type you're using! #define DHTTYPE DHT11 // DHT 11 //#define DHTTYPE DHT22 // DHT 22 (AM2302), AM2321 //#define DHTTYPE DHT21 // DHT 21 (AM2301) |
3. Then the program looks like
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 | #include "DHT.h" #define DHTPIN 2 // what digital pin we're connected to // Uncomment whatever type you're using! #define DHTTYPE DHT11 // DHT 11 //#define DHTTYPE DHT22 // DHT 22 (AM2302), AM2321 //#define DHTTYPE DHT21 // DHT 21 (AM2301) DHT dht(DHTPIN, DHTTYPE); void setup() { Serial.begin(9600); Serial.println("DHT11 test!"); dht.begin(); } void loop() { // Wait a few seconds between measurements. delay(2000); float h = dht.readHumidity(); // Read temperature as Celsius (the default) float t = dht.readTemperature(); // Read temperature as Fahrenheit (isFahrenheit = true) float f = dht.readTemperature(true); // Check if any reads failed and exit early (to try again). if (isnan(h) || isnan(t) || isnan(f)) { Serial.println("Failed to read from DHT sensor!"); return; } float hif = dht.computeHeatIndex(f, h); // Compute heat index in Celsius (isFahreheit = false) float hic = dht.computeHeatIndex(t, h, false); Serial.print("Humidity: "); Serial.print(h); Serial.print(" % "); Serial.print("Temperature: "); Serial.print(t); Serial.print(" *C "); Serial.print("Heat index: "); Serial.print(hic); Serial.print(" *C "); Serial.println(""); } |
4. Upload the program and open the Serial Monitor using Ctrl+Shift+M.
THANK YOU
SHARE THIS!!!
8 Comments
sma
(February 14, 2018 - 1:19 pm)thanks bro.it is very useful to me.i need to know how to download arduino software.
Gowtham S
(February 14, 2018 - 2:48 pm)Thanks for Commenting.
To download Arduino software go the Arduino official website software page from here and download the windows installer and install it.
Feel free to comment!!!
with warm regards
MYBTECHPROJECTS.
Bryon Recker
(February 21, 2018 - 6:21 pm)I don’t even know the way I ended up right here, but I believed this post was good. I don’t realize who you’re however definitely you’re going to a well-known blogger in case you aren’t already. Cheers!|
Gowtham S
(February 21, 2018 - 7:17 pm)Thank You!!!
Jeanine Bache
(February 22, 2018 - 12:41 am)Wow! After all I got a website from where I know how to actually obtain useful facts concerning my study and knowledge.
Gowtham S
(February 22, 2018 - 3:07 am)Thank you!!!
Stepanie Lenling
(February 21, 2018 - 7:14 pm)I have to thank you for the efforts you’ve put in writing this blog. I am hoping to see the same high-grade content by you in the future as well. In fact, your creative writing abilities has encouraged me to get my own, personal blog now ;)|
AIMBOT
(March 16, 2018 - 9:00 am)Yeah bookmaking this wasn’t a risky decision outstanding post!