Tutorial – DHT11 temperature module with Arduino

Tutorial – DHT11 temperature module with Arduino

In this tutorial we will explain how to use the DHT11 temperature module with Arduino. It is a module used to mesure humidity and temperature.

This module is not as accurate as the DHT22 (click to read the tutorial for DHT22). Infact the DHT22 has a better accuracy, but of course it’s price is higher.

Accuracy for DHT11

  • Humidity: range 20-90% , error 5%
  • Temperature: range 0 to 50°C, error ±2°C

How the DHT11 works

This module mesures both temperature and humidity. We can use it to make some very cool projects like measuring the temperature and humidity inside and outside a house!

It would be a very cool IoT project that we will make in the next days! Just follow us on instagram to read all the news! Or maybe you may click on the red bell in the right corner of the page! It enables the notifications so that you will receive a notification when we publish something new on the website!

Schematics for DHT11

Now we have to make a simple schematic for that Tutorial!

It is very simple, just follow do as follows:

From the left to the right

  • Arduino’s 5V -> “+” pin
  • digital pin5 -> out pin
  • Arduino’s GND -> “-” pin

Then we have to make a simple Sketch!

Sketch for DHT11

First of all you have to add the DHT.h library. If you don’t know how to add a library to the Arduino IDE, follow this guide -> How to add a Library to Arduino IDE.

//Libraries
#include <DHT.h>;

//Constants
#define DHTpin 5     // which pin we're connected to
#define DHTtype DHT11   // DHT 11
DHT dht(DHTpin, DHTtype); // Initialize DHT sensor


//Variables
float hum;  //Stores humidity value
float temp; //Stores temperature value

void setup()
{
  Serial.begin(9600);
  dht.begin();
  delay(1000); //the module needs a while before working properly
}

void loop()
{
    //Read data and store it to variables hum and temp
    hum = dht.readHumidity();
    temp = dht.readTemperature();

    //Print temp and humidity values to serial monitor
    Serial.print("Humidity: ");
    Serial.print(hum);
    Serial.print(" %, Temp: ");
    Serial.print(temp);
    Serial.println(" Celsius");
    delay(2000); //Delay 2 sec.
}

I hope that after your read this tutorial on the DHT11 temperature module with Arduino you know how to use it in your projects!

Davide Busco

Davide Busco is an engineering student at Federico II University of Naples. He uses his passion and studies to create his projects. He loves be a maker and spread his knowledge. Moreover he has gained the second place in a national makers-tournament between Italian's Universities.

Leave a Reply

Your email address will not be published. Required fields are marked *

en_GBEnglish (UK)
it_ITItaliano en_GBEnglish (UK)
%d bloggers like this: