How to Interface Humidity and Temperature (DHT11) Sensor to Arduino and Including DHT11 Library.
Intro: How to Interface Humidity and Temperature (DHT11) Sensor to Arduino and Including DHT11 Library.
DTH11 includes both Humidity and Temperature sensor.
Hardware Components required:-
1) DTH11 Humidity and Temperature Sensor
2) Arduino UNO
3)Connecting Wires
4) DTH library
You can get the sensor DTH11 Data Sheet from the below link
http://www.micro4you.com/files/sensor/DHT11.pdf
Hardware Connections
DTH11 To Arduino
Vcc --- 5v
GND --- GND
Data Pin --- 3rd Pin of Arduino
STEP 1: How to Include DHT Library
Please download the DHT library from the below link.
https://drive.google.com/file/d/0B1paTI5fzcHodno5azFOSVVDT0E/view?usp=sharing
Go to Sketch--> Include Library --> Add Zip File
As shown in the above screen shot please browse the ZIP file and include the library after including the library.
Close the Arduino IDE and open it again then you will find the library included.
STEP 2: Program and Results
Program
#include<dht.h>
dht DHT;
// if you require to change the pin number, Edit the pin with your arduino pin.
#define DHT11_PIN 3
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);
}
Results are shown in above screen shots..
Thanks,
TechPonder.
21 Comments
gorav mengji 7 years ago
hi
i have a issue while running the program its giving me a error saying
board at com1 is not avaliable...
TechPonder 7 years ago
JLaurence022 4 years ago
Arduino: 1.8.9 (Windows Store 1.8.21.0) (Windows 10), Board: "Arduino/Genuino Uno"
Build options changed, rebuilding all
STUDY_2_humidity_and_temperature:3:1: error: 'dht' does not name a type
dht DHT;
^
C:\Users\JL\Documents\Arduino\libraries\STUDY_2_humidity_and_temperature\STUDY_2_humidity_and_temperature.ino: In function 'void loop()':
STUDY_2_humidity_and_temperature:16:14: error: expected primary-expression before '.' token
int chk = DHT.read11(DHT11_PIN);
^
STUDY_2_humidity_and_temperature:19:19: error: expected primary-expression before '.' token
Serial.println(DHT.humidity, 1);
^
STUDY_2_humidity_and_temperature:21:19: error: expected primary-expression before '.' token
Serial.println(DHT.temperature, 1);
^
exit status 1
'dht' does not name a type
This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.
immanueldante 4 years ago
immanueldante 4 years ago
BC29 5 years ago
PoojaS41 6 years ago
getting zero as output for both temperature and humidity..!! suggestions please.
JaronF2 5 years ago
Did you maybe also fry your sensor like did?
KwadwoA4 6 years ago
delay(2000) seems ideal, but you can increase it in case your board needs more time to process the data
JaronF2 5 years ago
Uhhm. I don't think I will try the project again. Good that I smellled how burned it suddenly smelled because your schematics without resistor fried my sensor.
That is no curvature from the camera. That is actually how close I came to burning my house down.
SravanP3 6 years ago
AnujJ9 6 years ago
Greetings!!
You can also check it out here, https://github.com/ianuj03/DHT11
danielsan01 6 years ago
how can I display time and date without using anything else, but the internal PC clock. and how could I save the data and open it on excel?
danielsan01 6 years ago
it worked nice... thanks
EnaborO 6 years ago
Hello
I keep getting zero for both readings.
mugendi__ 6 years ago
I was having a similar problem some few minutes ago, and I just revisited how I had set-up my circuit. Unlike how they put it in Google pictures, try using the 5V without a a resistor.
Now it works perfectly fine
PoojaS41 6 years ago
i didn't used resistor, still getting zero.
suggest something else
mugendi__ 6 years ago
Me too
kavya1697 6 years ago
Arduino: 1.6.7 (Windows 10), Board: "Arduino/Genuino Uno"
C:\Users\Kavya\Desktop\sketch_jul27a\sketch_jul27a.ino:34:19: fatal error: dht11.h: No such file or directory
#include <dht11.h>
^
compilation terminated.
exit status 1
Error compiling.
This report would have more information with
"Show verbose output during compilation"
enabled in File > Preferences.
i have downloaded the dht library
this is error message i get could u please help me correct them
Ajioz 7 years ago
I Have issues with the Arduino recognizing the file dht.h. Was told no such file exist, meanwhile I have uploaded the zip file into the Arduino IDE, which showed in the file directory.
How do I solve this?