Read real-world temperature and humidity with a DHT11 sensor and display live readings via the Serial Monitor.
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.
| Component | Specification | Qty | Notes |
|---|---|---|---|
| Arduino Uno R3 | ATmega328P, 5V | 1 | Any Uno-compatible board works |
| DHT11 Sensor | 3.3–5V, ±2°C accuracy | 1 | DHT22 also works (more accurate) |
| Resistor | 10kΩ pull-up | 1 | Between data pin and VCC |
| Breadboard | 400 tie-points min | 1 | Half-size is fine |
| Jumper Wires | Male-to-Male | ~5 | Various lengths |
| USB Cable | Type A to B | 1 | For uploading code |
DHT sensor library by Adafruit and install it along with Adafruit Unified Sensor.2.10kΩ resistor between the DATA pin and VCC (5V). This ensures reliable signal levels.9600. Temperature and humidity readings will appear every 2 seconds.// 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: ");
Serial.print(tempC);
Serial.print(" °C | Humidity: ");
Serial.print(humidity);
Serial.println(" %");
}Sign in to leave a review
No reviews yet. Be the first to share your experience!