How to Interface Humidity and Temperature (DHT11) Sensor to Arduino and Including DHT11 Library.

122K5745

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

hi

i have a issue while running the program its giving me a error saying

board at com1 is not avaliable...

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.
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.

i tried so many programs, but still i got zero results
i got zero results in humi and temp sir :(
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>

getting zero as output for both temperature and humidity..!! suggestions please.

Did you maybe also fry your sensor like did?

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

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.

FOR ME COMPILING IS DONE BUT IN SERIAL MONITOR OUTPUT IS NOT SHOWING .PLZ REPLAY FAST.THANKING YOU

Greetings!!

You can also check it out here, https://github.com/ianuj03/DHT11

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?

Hello

I keep getting zero for both readings.

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

i didn't used resistor, still getting zero.

suggest something else

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

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?
More Comments