DHT11 Temperature and Humidity Sensor using arduino

In this tutorial we will learn how to use the DHT11 sensor for measuring temperature and humidity with the arduino board.  The following video shows the results of this project. Please read the tutorial below for more details.


This sensor is very popular for electronics hobbyists because it is very cheap but still providing great performance. The DHT11 temperature range is from 0 to 50 degrees Celsius with +-2 degrees accuracy and humidity range is from 20 to 80% with 5% accuracy. When you have finished reading this tutorial, you will be familiar with:

  • Connecting and using a DHT11/22 (Temperature and Humidity) sensor
  • Connecting and using a I2C LCD

What You Will Need

We will need the following parts and libraries in this tutorial:



The following libraries will be used in this tutorial. Please refer to this tutorial on how to add an Arduino library in eclipse

We will be using Eclipse for Arduino, if you haven’t setup please refer to my previous tutorial on eclipse for Arduino.

Circuit Schematics

The DHT11 sensor has four pins, VCC, GND, data pin and a not connected pin which has no usage. A pull-up resistor from 5K to 10K Ohms is required to keep the data line high and in order to enable the communication between the sensor and the Arduino Board. There are some versions of these sensors that come with a breakout boards with built-in pull-up resistor and they have just 3 pins. In this tutorial we going to use breakout board so no need for pull-up resister

Source Code

First we need to include the DHT library which can be downloaded from here, then define the pin number to which our sensor is connected and create a DHT object. We also have to add the I2C library and initialize it in order to print the results. Using the getHumidity( ) and getTemperature( ) functions we will read the data from the sensor and put the values of the temperature and the humidity into the temperature and humidity variables. At the end we will print the temperature and the humidity values on the LCD.