Using DHT11

Using DHT11 © MPL-2.0

This tutorial will show you how to use DHT11 with Arduino.

  • 80,926 views
  • 30 comments
  • 46 respects

Components and supplies

Apps and online services

Ide web
Arduino IDE
Or Arduino Web Editor

About this project

Ever wanted to know the temperature and humidity around you? If yes, this project will be very helpful for you. If no, it'll be cool anyway. What I mean is, you can use this in anything from home automations to smart watches.

What is humidity?

Humidity is the water vapor around you mixed with air. It is measured in per cents. So, if the humidity is 60 per cent(which is the average humidity), then 60 per cent of the air around you is water vapor. If it is 100%, then it means either the sensor is not correct, the sensor is broken/damaged, the Arduino crashed, the Arduino can't receive any signal, there's an error in the code or you're underwater*. If it's 0%, it means all the reasons above except the last one, you're in space or you're in the middle of a desert**.

* Correction: it means the air cannot hold any more water.

** The air in a desert does contain some water but it is a very little amount compared to a normal place. The Sahara Desert has a mean humidity of 25%.

The world's lowest recorded relative humidity value occurred at Coober Pedy in the South Australia desert when the temperature was 93 degrees and the dew point was minus 21 degrees producing a relative humidity of 1 percent. (source: 'www.chicagotribune.com')

Is your sensor different?

My sensor is like this:

My sensor has 3 pins and it's fitted on a board. If yours has 4 pins, then you need to build this circuit after the sensor:

If it is same as mine, then just ignore the resistor.

Then, build the circuit!

Details about the code

You need to follow these instructions to make it work:

1. You need to add the library to the Arduino IDE.

2. Upload the code.

3. When the code is uploaded, open the Serial Monitor and set the baud rate to 9600.

4. You will see the humidity and temperature.

Code

DHT11.inoArduino
The code for receiving the data from the DHT11 and printing it out on the serial monitor.
#include <dht11.h>
#define DHT11PIN 4

dht11 DHT11;

void setup()
{
  Serial.begin(9600);
 
}

void loop()
{
  Serial.println();

  int chk = DHT11.read(DHT11PIN);

  Serial.print("Humidity (%): ");
  Serial.println((float)DHT11.humidity, 2);

  Serial.print("Temperature (C): ");
  Serial.println((float)DHT11.temperature, 2);

  delay(2000);

}
DHT11 Library
Don't forget to add this library to the Arduino IDE.

Schematics

Schematics
Arduino and dht11 bb1 3vsonloxcb

Comments

Similar projects you might like

Weather Sensors, Between DHT11 and DHT22

by Achraf Oukheir

  • 6,028 views
  • 2 comments
  • 12 respects

DHT11 Temperature/Humidity Sensor

Project tutorial by Zachary Haslam

  • 58,855 views
  • 5 comments
  • 61 respects

DHT11 Humidity + Temperature Sensor with 16x2 LCD display

Project showcase by onatto22

  • 28,420 views
  • 6 comments
  • 44 respects

How to read temperature and humidity on Blynk with DHT11

Project tutorial by Tech with Matthew

  • 19,933 views
  • 5 comments
  • 20 respects

Temperature and Humidity Data Logger

Project tutorial by Wimpie van den Berg

  • 32,428 views
  • 2 comments
  • 31 respects
Add projectSign up / Login