Project tutorial
DHT11 Temperature/Humidity Sensor

DHT11 Temperature/Humidity Sensor © GPL3+

Take readings from the DHT11 Temperature/Humidity sensor and see them from the Arduino IDE Serial Monitor.

  • 46,813 views
  • 5 comments
  • 54 respects

Components and supplies

Apps and online services

About this project

In this project, we will use the KY-015 Arduino DHT11 Temperature/Humidity sensor and display it to the Arduino IDE serial monitor. This project is really simple and shouldn't take us very long.

Materials

The materials are here as follows:

  • Arduino Uno (Any "Uno" will work, I have a Geekcreit Uno)
  • KY-015 Arduino DHT11 Temperature/Humidity
  • Jumper Wires
  • Breadboard
  • Cable (USB 2.0)

Step 1: Place the sensor

The first thing you are going to do is place the sensor on the breadboard. If you place the breadboard in the orientation the way it was made, the blue part of the sensor should be facing you.

Step 2: Connect everything

Wow, we're already almost done! The pins on the sensor are S, for signal, the one in the middle is voltage, and the minus sign is ground. The signal pin goes to header A0 on the Arduino. The middle pin goes to 5V, and the minus sign goes to GND. Our yellow cable is our Analog cable, our red cable is power, and our black one is ground.

Step 3: Adding the DHT library

Okay this part is actually kind of important. Go to the credits on this post and click on the link for Brainy Bits. You should come to this page:

Scroll all the way down, and click the button to download the DHT_Library.zip. The link is highlighted in this photo.

Now download our code attached to the post. In the Arduino IDE, go to Sketch >> Include Library >> Add ZIP file.

When you click the 'Add .ZIP library', you should get a file window that pops up. Add the DHT_Library.zip.

If you'll notice in the code, another line of code pops up that says:

#include <dht.h>

There now should be two duplicate lines. One of the duplicate lines that was there before, that should be underneath the new duplicate line - delete it. Now the code should work.

Okay, NOW upload the code. When it is finished, go to the top right of the Arduino IDE window and click the little magnifying glass button. That will open the serial monitor, and the data of the sensor should be displaying itself and updating every 5 seconds.

Well, that's it! Enjoy your temperature/humidity sensor!

Code

DHT11 Temperature/Humidity SensorArduino
#include <dht.h>


#define dht_apin A0 // Analog Pin sensor is connected to
 
dht DHT;
 
void setup(){
 
  Serial.begin(9600);
  delay(500);//Delay to let system boot
  Serial.println("DHT11 Humidity & temperature Sensor\n\n");
  delay(1000);//Wait before accessing Sensor
 
}//end "setup()"
 
void loop(){
  //Start of Program 
 
    DHT.read11(dht_apin);
    
    Serial.print("Current humidity = ");
    Serial.print(DHT.humidity);
    Serial.print("%  ");
    Serial.print("temperature = ");
    Serial.print(DHT.temperature); 
    Serial.println("C  ");
    
    delay(5000);//Wait 5 seconds before accessing sensor again.
 
  //Fastest should be once every two seconds.
 
}// end loop(

Comments

Similar projects you might like

Arduino Temperature - Humidity - Rain Sensor

Project showcase by Rick_Findus

  • 13,445 views
  • 6 comments
  • 18 respects

Portable Arduino Temp/Humidity Sensor with LCD

Project tutorial by ThothLoki

  • 200,710 views
  • 130 comments
  • 271 respects

How To Use DS18B20 Water Proof Temperature Sensor

Project showcase by Team IoTBoys

  • 78,130 views
  • 13 comments
  • 23 respects

Using DHT11

by Arca_Ege

  • 21,600 views
  • 5 comments
  • 24 respects

DHT11 Humidity + Temperature Sensor with 16x2 LCD display

Project showcase by onatto22

  • 22,245 views
  • 6 comments
  • 40 respects

Weather Sensors, Between DHT11 and DHT22

by Achraf Oukheir

  • 5,615 views
  • 2 comments
  • 12 respects
Add projectSign up / Login