Free Nationwide Doorstep Delivery on orders over ₹499
← All 10 Projects•Intermediate•45 mins

Temperature & Humidity Monitoring with DHT11

Interface a single-bus digital sensor to acquire calibrated environmental humidity and temperature telemetry in real time.

Real-World Engineering Application

Greenhouse climate regulators, museum HVAC preservation systems, and food cold-chain storage monitoring.

Physics & Working Principle

The DHT11 uses a capacitive humidity sensing element and a thermistor connected to an onboard 8-bit chip. It transmits 40 bits of serial data over a single bidirectional wire with parity checksum.

Key Learning Outcome:Understand single-bus serial communication protocols, checksum data verification, and handling decimal floating-point metrics.

Pin Connection & Wiring Table

Component Pin / TerminalMicrocontroller Pin (ESP32 / Arduino)Wiring Note
VCC (+)3.3V or 5VPower supply
DATA / OUTGPIO 15 / Pin 2Digital single-bus data line
GND (-)GNDCommon ground

Step-by-Step Plug & Play Assembly

1

Identify the 3 pins on the DHT11 breakout board: VCC, DATA, and GND.

2

Connect VCC to 3.3V and GND to the GND terminal on ESP32.

3

Connect the DATA pin to GPIO 15.

4

Install the "DHT sensor library by Adafruit" via Arduino Library Manager.

Complete Tested Source Code

// NovaCircuit Project 3: DHT11 Temperature & Humidity Sensor
#include "DHT.h"

#define DHTPIN 15
#define DHTTYPE DHT11

DHT dht(DHTPIN, DHTTYPE);

void setup() {
  Serial.begin(115200);
  Serial.println("DHT11 Environmental Sensor Initializing...");
  dht.begin();
}

void loop() {
  delay(2000); // DHT11 requires at least 1-2 seconds between readings

  float humidity = dht.readHumidity();
  float temperature = dht.readTemperature(); // Celsius

  if (isnan(humidity) || isnan(temperature)) {
    Serial.println("Error: Failed to read from DHT sensor! Check wiring.");
    return;
  }

  Serial.print("Humidity: ");
  Serial.print(humidity, 1);
  Serial.print("% | Temperature: ");
  Serial.print(temperature, 1);
  Serial.println(" °C");
}
Code Logic Breakdown:

The DHT library handles the timing-sensitive microsecond pulses required by the sensor protocol. readHumidity() and readTemperature() parse the 40-bit frame into human-readable metric values.

Expected Physical Output

Serial Monitor prints current ambient temperature and relative humidity every 2 seconds without checksum dropouts.
Troubleshooting Tips
  • •NaN readings: Verify DATA pin connection and check if DHT11 is receiving adequate voltage (try 5V if 3.3V is unstable).
  • •Readings update too slowly: DHT11 hardware response time is 1-2 seconds; avoid querying faster than once per 2000ms.
Electrical Safety Directives
  • •Keep the sensor away from liquid water immersion; it measures airborne water vapor, not direct liquid immersion.
Companion Resources

Related Book Chapter & Hardware Kit

Covered in depth within Chapter 6: Sensors and Their Applications. Build this easily with the Sensor Explorer Kit.