DHT11 Humidity Sensor

Instructional Web Page: DHT11 Humidity Sensor with Arduino Uno

Introduction

If you’ve ever wanted to know how humid or dry your room is, you can do it easily with an Arduino and a DHT11 sensor! The DHT11 is one of the simplest humidity and temperature sensors out there. It’s inexpensive, easy to use, and works perfectly with the Arduino Uno. In this tutorial, we’ll go step-by-step through wiring it up, coding it, and reading real-time humidity and temperature data.


What You’ll Need

Optional: A 10kΩ pull-up resistor between the data pin and VCC for better signal stability.


Pin Connections

DHT11 PinArduino Uno Pin
VCC5V
GNDGND
DATADigital Pin 7

💡 Tip: Always check your DHT11’s pin layout—some modules have a reversed order!


Arduino Code Example

#include "DHT.h"

#define DHTPIN 7        // DHT11 data pin connected to digital pin 7
#define DHTTYPE DHT11   // Define sensor type

DHT dht(DHTPIN, DHTTYPE);

void setup() {
  Serial.begin(9600);
  dht.begin();
  Serial.println("DHT11 Humidity & Temperature Sensor Test");
}

void loop() {
  delay(2000); // Wait 2 seconds between readings

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

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

  Serial.print("Humidity: ");
  Serial.print(humidity);
  Serial.print(" %\t");

  Serial.print("Temperature: ");
  Serial.print(temperature);
  Serial.println(" °C");
}

How It Works

The DHT11 uses a digital signal to send data to your Arduino. The Arduino library handles all the communication, so all you need to do is call readHumidity() and readTemperature() to get live readings. The sensor updates every couple of seconds, making it perfect for small weather stations, room monitors, or plant care projects.


Troubleshooting Tips

  • No readings? Double-check your wiring and make sure the data pin is correctly set in the code.
  • Weird values? Try adding a 10kΩ pull-up resistor on the data line.
  • Slow response? The DHT11 isn’t the fastest sensor—try the DHT22 if you need faster or more precise readings.

Where to Use It

You can use this setup for:

  • DIY weather stations
  • Smart home humidity monitors
  • Greenhouse control systems
  • Room comfort tracking projects

Conclusion

The DHT11 and Arduino Uno make a great beginner-friendly combo for exploring environmental sensors. With just a few lines of code and simple wiring, you can build your own humidity and temperature monitor in no time!