Random Nerd Tutorials
Shares

Complete Guide for DHT11/DHT22 Humidity and Temperature Sensor With Arduino

Shares

This post aims to be a complete guide for the popular DHT11/DHT22. I’ll explain how it works, show some features and share an Arduino Project example that you can take and apply to your own projects.

I have more complete guides for other popular sensors, check them below:

Description

These DHTXX sensors are very popular among the Arduino Tinkerers. The DHT sensors are inexpensive sensors for measuring temperature and humidity.

These sensors contain a chip that does analog to digital conversion and spits out a digital signal with the temperature and humidity.

These signals are easy to read with any microcontroller (MCU).

humidity sensor

Specifications DHT11 vs DHT22

There are two versions of the DHT sensor.

DHT11

  • Range: 20-90%
  • Absolute accuracy: ±5%
  • Repeatability: ±1%
  • Long term stability: ±1% per year
  • Price: $1 to $5

DHT22

  • Range: 0-100%
  • Absolute accuracy: ±2%
  • Repeatability: ±1%
  • Long term stability: ±0.5% per year
  • Price: $4 to $10

As you can see from the specs above, the DHT22 is a bit more accurate.

Where to buy?

You can purchase these modules from eBay for just a few dollars:

rsz_dht-11

Arduino with DHT11 Temperature and Humidity Sensor

You need the following components to make this circuit:

  • Arduino (eBay)
  • DHT11 (eBay)
  • Breadboard (eBay)
  • 10K Resistor

Here’s how to connect the DHT11 to an Arduino:

humidity_schematics

Pins:

  • VCC (3V to 5V)
  • Data OUT
  • Don’t connect
  • GND

Source code

Here’s the code you need for this project:

  1. Download the DHT11 library here
  2. Unzip the DHT library
  3. Rename the extracted folder and remove the “-“. Otherwise your Arduino IDE won’t recognize your library
  4. Install the DHT11 in your Arduino IDE
  5. Restart your Arduino IDE
  6. Go to Files / Examples / DHT_SENSOR_LIB / DHT Tester
  7. Upload the code

Demonstration

In this project the Arduino is measuring the temperature and humidity. Those two measures are being displayed in the serial monitor. Here’s what you should see in your Arduino IDE serial monitor.

serial_monitor

I hope you found this guide useful.

Share this post with a friend that also likes electronics!

You can contact me by leaving a comment. If you like this post probably you might like my next ones, so please support me by subscribing my blog and my Facebook Page.

Thanks for reading,

-Rui Santos

Recommended Resources

Home Automation using ESP8266 »
Build IoT projects and home automation gadgets with the ESP8266 Wi-Fi module.

Build a Home Automation System »
Learn how to build a automation system using open-source hardware and software from scratch.

Arduino Step-by-Step Projects »
Build 25 cool Arduino projects with our couse even with no prior experience!

Leave a Comment:

Add Your Reply

⏰ Early Black Friday 2017 Special ⏰
Download all our courses up to 35% off