Using DHT11

Using DHT11 © MPL-2.0

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

  • 16,435 views
  • 5 comments
  • 22 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'reunderwater. 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 dessert.

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

  • 3,275 views
  • 2 comments
  • 10 respects

DHT11 Temperature/Humidity Sensor

Project tutorial by Zachary Haslam

  • 13,177 views
  • 1 comment
  • 30 respects

How to read temperature and humidity on Blynk with DHT11

Project tutorial by Tech with Matthew

  • 10,711 views
  • 3 comments
  • 14 respects

DHT11 /DHT22 Temperature Sensor

Project tutorial by Daniel Porrey

  • 82,653 views
  • 106 comments
  • 133 respects

DHT11 Humidity + Temperature Sensor with 16x2 LCD display

Project showcase by onatto22

  • 9,054 views
  • 1 comment
  • 17 respects
Add projectSign up / Login