DHT11 Sensor with Arduino UNO

DHT11 Sensor with Arduino UNO
Atribot team

Written by

Atribot team

Last updated

June 18, 2026

Introduction

The DHT11 is a low-cost digital sensor used to measure temperature and humidity. It is widely used in weather monitoring systems, smart home projects, environmental monitoring, and IoT applications. The sensor provides calibrated digital output, making it easy to interface with Arduino boards.

In this tutorial, you will learn how to connect the DHT11 Sensor to an Arduino UNO, install the required library, upload the code, and display temperature and humidity readings using the Serial Monitor. By the end of this guide, you'll understand how to collect environmental data using the DHT11 sensor.

Components Required

Swipe right to view full table
Item NameQtyAction
1
1
USB Cable
1
Breadboard
1
Jumper Wires
3

Tools Required

Swipe right to view full table
Item NameAction
Soldering Iron
Screwdriver

Software Required

Swipe right to view full table
Item NameAction
Arduio IDE

Circuit Diagram

DHT11 Sensor with Arduino UNO Circuit Connections
DHT11 Sensor with Arduino UNO Circuit Connections

Source Code

DHT11_Sensor_with_Arduino_UNO.inocpp
#include <DHT.h>

#define DHTPIN 2
#define DHTTYPE DHT11

DHT dht(DHTPIN, DHTTYPE);

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

void loop()
{
  float humidity = dht.readHumidity();
  float temperature = dht.readTemperature();

  Serial.print("Humidity: ");
  Serial.print(humidity);
  Serial.print("%  ");

  Serial.print("Temperature: ");
  Serial.print(temperature);
  Serial.println("°C");

  delay(2000);
}

Step by Step Instructions

Step 1: Connect the DHT11 Sensor

Make the following connections:

Swipe right to view full table

DHT11

Arduino UNO

VCC

5V

GND

GND

DATA

D2

Step 2: Install Required Libraries

  1. Open Arduino IDE.

  2. Go to Sketch → Include Library → Manage Libraries.

  3. Search for DHT Sensor Library.

  4. Install DHT Sensor Library by Adafruit.

  5. Install Adafruit Unified Sensor Library.

Step 3: Open Arduino IDE

  1. Connect Arduino UNO using USB.

  2. Select:

    • Board → Arduino UNO

    • Port → Correct COM Port

Step 4: Create a New Sketch

Create a new Arduino sketch and paste the provided code.

Step 5: Verify the Code

Click the Verify button to check for syntax errors.

Step 6: Upload the Code

Click Upload and wait until the upload process completes successfully.

Step 7: Open Serial Monitor

  1. Open Serial Monitor.

  2. Set the baud rate to 9600.

  3. Wait a few seconds for the sensor to initialize.

The Serial Monitor will display temperature and humidity values.

Expected Output

Humidity: 58.00%  Temperature: 29.00°C
Humidity: 58.00%  Temperature: 29.00°C
Humidity: 59.00%  Temperature: 30.00°C

Conclusion

In this tutorial, you learned how to interface the DHT11 Sensor with Arduino UNO and measure temperature and humidity. This basic setup can be used in various Arduino projects that require environmental monitoring and weather data collection.