Introduction: 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
6 years ago
hi
i have a issue while running the program its giving me a error saying
board at com1 is not avaliable...
Reply 6 years ago
In Arduino IDE. Go to Tools-> Port Select the COM port on which your Arduino is connected to the System. In order to check the COM port in Computer go to Control Panel->Hardware-> Device Manger-> Ports You will find the Exact COM Port. Please select the port and upload.
3 years ago
Pls help.. it says this.. im a beginner
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.
Question 4 years ago
i tried so many programs, but still i got zero results
4 years ago on Step 2
i got zero results in humi and temp sir :(
4 years ago
Hallo TechPonder. I've typed the code and used the Adafruit DHT library. Downloading it went succesfully and got the circuit to work. Some other time when I wanted to use another DHT library from the GitsHub, it then shows an error that there is no such file as #include <Adafruit_sensor.h>
5 years ago
getting zero as output for both temperature and humidity..!! suggestions please.
Reply 4 years ago
Did you maybe also fry your sensor like did?
Reply 5 years ago
I had the same problem till I increased the delay.
delay(2000) seems ideal, but you can increase it in case your board needs more time to process the data
4 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.
Question 5 years ago
FOR ME COMPILING IS DONE BUT IN SERIAL MONITOR OUTPUT IS NOT SHOWING .PLZ REPLAY FAST.THANKING YOU
5 years ago
Greetings!!
You can also check it out here, https://github.com/ianuj03/DHT11
5 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?
5 years ago
it worked nice... thanks
5 years ago
Hello
I keep getting zero for both readings.
Reply 5 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
Reply 5 years ago
i didn't used resistor, still getting zero.
suggest something else
Reply 5 years ago
Me too
5 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
6 years ago
Hi,
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?