Interfacing DHT11 Temperature/Humidity Sensor with Arduino

Table of Contents

DHT11 Sensor Features

The DHT11 is a digital temperature and humidity sensor. This sensor is able to measure the humidity in the range of 20% to 80% with an accuracy of 5%. It can also measure the temperature in the range of 0 to 50 degrees Celsius with an accuracy of 2 degrees.


The sampling frequency of this sensor is 1Hz. As a result, there must be at least one second between every readings of the sensor, otherwise the reading values will be incorrect.

You can download the DHT11 temperature and humidity module datasheet here. 

DHT11 Sensor Module Pinout

This module has 3 pins:

  • VCC: Module power supply – 5 V
  • GND: Ground
  • Data: Sensor output
  • TX: Send information via serial protocol

You can see Pinout of this module in the following image

Required Materials

Hardware Components

Arduino UNO R3 × 1
DHT11 Sensor × 1
4.7K Ohm Resistor × 1
Bread Board × 1
Male to Male jumper wire × 1

Software Apps

Arduino IDE

Interfacing DHT11 Sensor Module with Arduino

Step 1: Circuit

Connect the module to Arduino according to the following circuit.

Step 2: Installing Library

Go to Library manager and install DHT11 temperature sensor library.


If you need more help with installing a library on Arduino, read this tutorial: How to Install an Arduino Library

Step 3: Code

Upload the following code to Arduino board. This code reads temperature and humidity and displays that in the serial monitor.

  DHT11 - Tempertature & Hummidity Sensor
  modified on 08 Sep 2020
  by Mohammad Reza Akbari @ Electropeak
Based on Adafruit Example */ #include "DHT.h" #define DHTPIN 8 // Digital pin connected to DHT11 // Uncomment whatever type you're using! #define DHTTYPE DHT11 // DHT 11 DHT dht(DHTPIN, DHTTYPE); void setup() { Serial.begin(9600); dht.begin(); Serial.println("Initializing... Please wait."); delay(2000); } void loop() { float h = dht.readHumidity(); // Read temperature as Celsius (the default) float t = dht.readTemperature(); // Read temperature as Fahrenheit (isFahrenheit = true) float f = dht.readTemperature(true); // Check if any reads failed and exit early (to try again). if (isnan(h) || isnan(t) || isnan(f)) { Serial.println(F("Failed to read from DHT sensor!")); return; } // Compute heat index in Fahrenheit (the default) float hif = dht.computeHeatIndex(f, h); // Compute heat index in Celsius (isFahreheit = false) float hic = dht.computeHeatIndex(t, h, false); Serial.print(F("Humidity: ")); Serial.print(h); Serial.print(F("% Temperature: ")); Serial.print(t); Serial.print(F("°C ")); Serial.println(f); delay(2000); }

The code output is like this:

Liked What You See?​
Get Updates And Learn From The Best​

More To Explore

Leave a Reply

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