← Back to Basic Projects
Basic . Project #02

🌑️ Room Temperature Monitor

Read real-world temperature and humidity with a DHT11 sensor and display live readings via the Serial Monitor.

πŸ“‹ Overview

The DHT11 is a remarkably accurate sensor that measures both temperature and humidity using a single digital pin. At under $2, it's one of the best value sensors in electronics.

What you'll learn: Including libraries, reading sensor data, printing to Serial Monitor, and understanding digital communication protocols.

Estimated time: 20–30 minutes. Difficulty: ⭐ Beginner-friendly.

🧩 Components Needed

ComponentSpecificationQtyNotes
Arduino Uno R3ATmega328P, 5V1Any Uno-compatible board works
DHT11 Sensor3.3???5V, +/-2 deg C accuracy1DHT22 also works (more accurate)
Resistor10k Ohm pull-up1Between data pin and VCC
Breadboard400 tie-points min1Half-size is fine
Jumper WiresMale-to-Male~5Various lengths
USB CableType A to B1For uploading code

πŸ“– Step-by-Step Tutorial

1

Install DHT Library

Open Arduino IDE -> Sketch -> Include Library -> Manage Libraries. Search for DHT sensor library by Adafruit and install it along with Adafruit Unified Sensor.
2

Wire the DHT11

DHT11 has 3 useful pins: VCC -> Arduino 5V, GND -> Arduino GND, DATA -> Arduino digital pin 2.
3

Add Pull-up Resistor

Connect a 10k Ohm resistor between the DATA pin and VCC (5V). This ensures reliable signal levels.
4

Upload the Code

Paste the code below, select your board, and click Upload.
5

Open Serial Monitor

Go to Tools -> Serial Monitor, set baud rate to 9600. Temperature and humidity readings will appear every 2 seconds.
πŸ’‘
The DHT11 needs at least 1–2 seconds between readings. Reading it faster can cause errors or incorrect values.

πŸ’» Arduino Code

temperature_monitor.ino
INO
// Room Temperature Monitor β€” Volt X
#include <DHT.h>

#define DHTPIN 2
#define DHTTYPE DHT11

DHT dht(DHTPIN, DHTTYPE);

void setup() {
  Serial.begin(9600);
  dht.begin();
  Serial.println("Volt X β€” Temperature Monitor");
}

void loop() {
  delay(2000);
  float humidity = dht.readHumidity();
  float tempC = dht.readTemperature();

  if (isnan(humidity) || isnan(tempC)) {
    Serial.println("Sensor read error!");
    return;
  }

  Serial.print("Temperature: ");

⭐Reviews & Ratings

β€”0 reviews
5β˜…
0
4β˜…
0
3β˜…
0
2β˜…
0
1β˜…
0
⏳

Loading reviews…