DHT11 Temperature & Humidity Climate Monitor
Sample digital ambient temperature and relative humidity over a single-wire bus and compute real-time heat index.
Interface the DHT11 digital climate sensor with your Arduino Uno R3. Explore single-wire timing handshakes, verify 40-bit checksum integrity, stream calibrated °C/°F and %RH telemetry to the Serial Monitor, and trigger comfort alerts.
Key Learning Objectives & Robotics Concepts
By building and programming this project, you will master the following core engineering skills:
Power Architecture & Voltage Staging
5V / 3.3V Regulated PowerThe DHT11 operates cleanly from the Arduino Uno 5V pin, drawing under 2.5mA during brief 18ms measurement bursts and 150µA in standby. A 10kΩ pull-up keeps the bidirectional DATA line idle HIGH. Module PCB includes a 10kΩ pull-up resistor on DATA and decoupling capacitor; sample no faster than once every 2 seconds.
Bill of Materials (BOM) & Hardware Components
| Component | Specifications & Alternative | Qty | Approx Cost |
|---|---|---|---|
| Arduino Uno R3 | ATmega328P @ 16MHz | 1 | $8.00 |
| DHT11 Temperature & Humidity Module | 0–50°C (±2°C), 20–90% RH (±5%) | 1 | $2.00 |
| 10kΩ Pull-Up Resistor | Required only for bare 4-pin blue DHT11 sensor | 1 | $0.05 |
| Breadboard & Jumper Wires | 3× Male-to-Female or Male-to-Male leads | 1 | $2.00 |
Electrical & System Architecture
DHT11 VCC connects to Uno 5V, GND to Uno GND, and DATA to digital pin D4. Bare 4-pin DHT11 sensors require an external 10kΩ pull-up resistor between DATA and 5V.
Autonomous Behavior & Finite State Machine (FSM)
Deterministic Arduino loop handling DHT11 3-Pin Digital Temp & Humidity Module acquisition, filtering, and real-time output updates.
Step-by-Step Physical Assembly & Wiring Tutorial
Follow each of the 5 sequential milestone stages with technical photos, wiring checks, and pre-flight tests.
Verify DHT11 Pinout Order (3-Pin vs 4-Pin)
Check PCB silkscreen markings (+, S, - or VCC, DATA, GND) since breakout boards vary by manufacturer.
- Inspect the three pins on the DHT11 module: +, OUT/S, and -.
- If using a bare 4-pin blue housing (grid facing you), pins left-to-right are VCC, DATA, NC, GND.
- Install a 10kΩ pull-up resistor between VCC and DATA if using a bare 4-pin element.
Wire DHT11 to Arduino Uno D4
Connect power, ground, and signal lines cleanly using short jumper leads.
- Connect DHT11 VCC (+) to Arduino Uno 5V.
- Connect DHT11 GND (-) to Arduino Uno GND.
- Connect DHT11 DATA (S) to Arduino Uno Digital Pin D4.
Install Required Arduino Library
Add the Adafruit DHT Sensor Library and Adafruit Unified Sensor dependency via Library Manager.
- Open Arduino IDE → Sketch → Include Library → Manage Libraries.
- Search for "DHT sensor library" by Adafruit and install it with all dependencies.
- Verify compilation succeeds before uploading.
Upload Climate Telemetry Firmware
Flash the DHT11 climate monitor sketch and inspect live readings on the Serial Monitor.
- Flash the code below to the Arduino Uno.
- Open Serial Monitor at 115200 baud.
- Observe temperature (°C / °F), relative humidity (%), and Heat Index updating every 2 seconds.
Dynamic Response Bench Test
Exhale gently near the blue sensing grille to verify rapid humidity and temperature climb.
- Record baseline ambient room temperature and humidity.
- Gently breathe across the sensor vents and watch %RH spike by 15–30%.
- Confirm readings return cleanly toward ambient baseline within 60 seconds.
Subsystem Benchtop Verification Scripts
Test each hardware subsystem independently before deploying the full autonomous firmware.
1Bench Diagnostic: DHT11 3-Pin Digital Temp & Humidity Module Hardware Check
Subsystem DiagnosticMinimal standalone sketch to verify pin wiring and signal response for DHT11 3-Pin Digital Temp & Humidity Module before running the full project firmware.
// Diagnostic: Raw DHT11 Single-Wire Connection Test
#include <DHT.h>
DHT dht(4, DHT11);
void setup() {
Serial.begin(115200);
dht.begin();
}
void loop() {
delay(2000);
float h = dht.readHumidity();
float t = dht.readTemperature();
if (isnan(h) || isnan(t)) Serial.println("ERR: Check DHT11 wiring!");
else { Serial.print("RH: "); Serial.print(h); Serial.print("% T: "); Serial.print(t); Serial.println("C"); }
}Complete Production Firmware
Full working C++ source code with pin mappings, non-blocking timers, and FSM avoidance routines.
/**
* Project 3: DHT11 Digital Climate & Heat-Index Monitor
* Board: Arduino Uno R3 | Pin: D4 (DHT11 DATA)
* Library: Adafruit DHT sensor library
*/
#include <DHT.h>
const uint8_t DHT_PIN = 4;
const uint8_t DHT_TYPE = DHT11;
const unsigned long SAMPLE_MS = 2000;
DHT dht(DHT_PIN, DHT_TYPE);
unsigned long lastSample = 0;
void setup() {
Serial.begin(115200);
dht.begin();
Serial.println(F("DHT11 Climate Monitor Started (2s sample interval)"));
}
void loop() {
if (millis() - lastSample < SAMPLE_MS) return;
lastSample = millis();
float humidity = dht.readHumidity();
float tempC = dht.readTemperature();
if (isnan(humidity) || isnan(tempC)) {
Serial.println(F("[WARN] DHT11 read timeout - verify D4 & pull-up resistor."));
return;
}
float tempF = dht.readTemperature(true);
float heatIndexC = dht.computeHeatIndex(tempC, humidity, false);
Serial.print(F("Humidity: ")); Serial.print(humidity, 1); Serial.print(F("% | "));
Serial.print(F("Temp: ")); Serial.print(tempC, 1); Serial.print(F("C ("));
Serial.print(tempF, 1); Serial.print(F("F) | Heat Index: "));
Serial.print(heatIndexC, 1); Serial.println(F("C"));
}Firmware Architecture Explanation:
- Enforces a strict 2000ms non-blocking sampling cadence matching the DHT11 hardware conversion spec.
- Guards against bus noise using isnan() before calculating Heat Index or transmitting telemetry.
- Outputs both Celsius and Fahrenheit alongside perceived Heat Index.
Operational Verification & Pin State Matrix
Input Signal vs. System Output Truth Table:
| Input / State | Pin / Signal | Detected Condition | Expected Output |
|---|---|---|---|
| 20–60% RH | 18–27°C | Comfortable Indoor Band | Status: NOMINAL |
| > 75% RH | > 30°C | High Heat/Humidity Stress | Status: VENTILATE ALERT |
| NaN | NaN | Bus Timeout / Bad Wiring | Emit Diagnostic Warning |
Engineering Troubleshooting Matrix
| Problem | Likely Cause | Diagnostic Check | Engineering Solution |
|---|---|---|---|
| Serial outputs NaN or read timeout continuously | DATA connected to wrong pin or missing 10kΩ pull-up on bare 4-pin sensor | Verify D4 continuity and check 5V at sensor VCC | Match DHT_PIN to wiring and add a 10kΩ pull-up between DATA and 5V. |
| Sensor feels warm and reports inflated temperatures | VCC and GND pins reversed | Unplug immediately and inspect silkscreen markings | Correct polarity; replace sensor if internally damaged. |
| Readings freeze after first measurement | Polling interval shorter than 2 seconds | Inspect SAMPLE_MS constant in loop() | Keep polling interval at 2000ms or higher. |
Engineering Challenges & Upgrades
Take your build to the next level with these progressive engineering upgrades:
Add a red LED on D8 that illuminates automatically whenever relative humidity exceeds 70%.
Combine with Project 4 (SSD1306 OLED) to render live temperature, humidity, and a comfort bar graph on screen.
Track and display the highest and lowest temperature recorded since Arduino boot.