DHT11 Sensor with Arduino UNO

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
Tools Required
Software Required
| Item Name | Action |
|---|---|
Arduio IDE | Download |
Circuit Diagram
Source Code
#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:
DHT11 | Arduino UNO |
|---|---|
VCC | 5V |
GND | GND |
DATA | D2 |
Step 2: Install Required Libraries
Open Arduino IDE.
Go to Sketch → Include Library → Manage Libraries.
Search for DHT Sensor Library.
Install DHT Sensor Library by Adafruit.
Install Adafruit Unified Sensor Library.
Step 3: Open Arduino IDE
Connect Arduino UNO using USB.
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
Open Serial Monitor.
Set the baud rate to 9600.
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°CConclusion
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.









