Cirkit Designer Logo
Cirkit Designer
Your all-in-one circuit design IDE
Home / 
Component Documentation

How to Use DHT 22: Examples, Pinouts, and Specs

Image of DHT 22
Cirkit Designer LogoDesign with DHT 22 in Cirkit Designer

Introduction

The DHT 22 is a digital temperature and humidity sensor that provides accurate readings of temperature in Celsius and humidity in percentage. It is widely used in applications requiring environmental monitoring, such as weather stations, HVAC systems, greenhouses, and IoT projects. The sensor is known for its reliability, ease of use, and ability to provide precise measurements with minimal power consumption.

Explore Projects Built with DHT 22

Use Cirkit Designer to design, explore, and prototype these projects online. Some projects support real-time simulation. Click "Open Project" to start designing instantly!
Arduino UNO-Based Weather Station with DHT22 Sensor and 16x2 I2C LCD Display
Image of IISc_Intern: A project utilizing DHT 22 in a practical application
This circuit uses an Arduino UNO to read temperature and humidity data from a DHT22 sensor and display the information on a 16x2 I2C LCD. The Arduino is connected to the DHT22 sensor via digital pin D7 and to the LCD via the I2C interface on analog pins A4 (SCL) and A5 (SDA).
Cirkit Designer LogoOpen Project in Cirkit Designer
ESP32-Based NTP Clock with DHT22 Temperature Sensor and WS2812 LED Matrix Display
Image of date time and temperature display : A project utilizing DHT 22 in a practical application
This circuit features an ESP32 Devkit V1 microcontroller connected to a DHT22 temperature and humidity sensor and an 8x8 WS2812 RGB LED matrix. The ESP32 reads temperature data from the DHT22 sensor and displays the current date, time, and temperature on the LED matrix, with date and time synchronized via NTP (Network Time Protocol). The ESP32 provides power to both the DHT22 and the LED matrix and communicates with the DHT22 via GPIO 4 and with the LED matrix via GPIO 5.
Cirkit Designer LogoOpen Project in Cirkit Designer
DHT22 Temperature and Humidity Monitor with I2C LCD Display
Image of Measure Temp and Humidity With DHT22: A project utilizing DHT 22 in a practical application
This circuit utilizes a DHT22 temperature and humidity sensor connected to an Arduino UNO, which processes the sensor data. The readings are displayed on a 16x2 I2C LCD, allowing for real-time monitoring of environmental conditions. A resistor is included in the circuit to ensure proper signal integrity from the DHT22 sensor.
Cirkit Designer LogoOpen Project in Cirkit Designer
ESP32-Based Smart Weather Station with LCD Display and Gas Sensor
Image of rpp: A project utilizing DHT 22 in a practical application
This circuit is a sensor monitoring system that uses an ESP32 microcontroller to read data from a DHT22 temperature and humidity sensor and an MQ-4 gas sensor. The data is then displayed on a 16x2 I2C LCD screen. The system is powered by a Mtiny Power module providing 5V and 3.3V outputs.
Cirkit Designer LogoOpen Project in Cirkit Designer

Explore Projects Built with DHT 22

Use Cirkit Designer to design, explore, and prototype these projects online. Some projects support real-time simulation. Click "Open Project" to start designing instantly!
Image of IISc_Intern: A project utilizing DHT 22 in a practical application
Arduino UNO-Based Weather Station with DHT22 Sensor and 16x2 I2C LCD Display
This circuit uses an Arduino UNO to read temperature and humidity data from a DHT22 sensor and display the information on a 16x2 I2C LCD. The Arduino is connected to the DHT22 sensor via digital pin D7 and to the LCD via the I2C interface on analog pins A4 (SCL) and A5 (SDA).
Cirkit Designer LogoOpen Project in Cirkit Designer
Image of date time and temperature display : A project utilizing DHT 22 in a practical application
ESP32-Based NTP Clock with DHT22 Temperature Sensor and WS2812 LED Matrix Display
This circuit features an ESP32 Devkit V1 microcontroller connected to a DHT22 temperature and humidity sensor and an 8x8 WS2812 RGB LED matrix. The ESP32 reads temperature data from the DHT22 sensor and displays the current date, time, and temperature on the LED matrix, with date and time synchronized via NTP (Network Time Protocol). The ESP32 provides power to both the DHT22 and the LED matrix and communicates with the DHT22 via GPIO 4 and with the LED matrix via GPIO 5.
Cirkit Designer LogoOpen Project in Cirkit Designer
Image of Measure Temp and Humidity With DHT22: A project utilizing DHT 22 in a practical application
DHT22 Temperature and Humidity Monitor with I2C LCD Display
This circuit utilizes a DHT22 temperature and humidity sensor connected to an Arduino UNO, which processes the sensor data. The readings are displayed on a 16x2 I2C LCD, allowing for real-time monitoring of environmental conditions. A resistor is included in the circuit to ensure proper signal integrity from the DHT22 sensor.
Cirkit Designer LogoOpen Project in Cirkit Designer
Image of rpp: A project utilizing DHT 22 in a practical application
ESP32-Based Smart Weather Station with LCD Display and Gas Sensor
This circuit is a sensor monitoring system that uses an ESP32 microcontroller to read data from a DHT22 temperature and humidity sensor and an MQ-4 gas sensor. The data is then displayed on a 16x2 I2C LCD screen. The system is powered by a Mtiny Power module providing 5V and 3.3V outputs.
Cirkit Designer LogoOpen Project in Cirkit Designer

Technical Specifications

The DHT 22 sensor has the following key technical specifications:

Parameter Value
Operating Voltage 3.3V to 6V
Operating Current 0.3mA (measuring), 60µA (standby)
Temperature Range -40°C to +80°C
Temperature Accuracy ±0.5°C
Humidity Range 0% to 100% RH
Humidity Accuracy ±2% RH
Sampling Rate 0.5 Hz (1 reading every 2 seconds)
Communication Protocol Single-wire digital signal
Dimensions 15.1mm x 25mm x 7.7mm

Pin Configuration and Descriptions

The DHT 22 has four pins, as described in the table below:

Pin Number Name Description
1 VCC Power supply pin (3.3V to 6V)
2 DATA Digital data output pin
3 NC Not connected (leave unconnected)
4 GND Ground pin

Note: A pull-up resistor (typically 10kΩ) is required between the DATA pin and VCC for proper communication.

Usage Instructions

How to Use the DHT 22 in a Circuit

  1. Power the Sensor: Connect the VCC pin to a 3.3V or 5V power source and the GND pin to ground.
  2. Connect the DATA Pin: Attach the DATA pin to a digital input pin on your microcontroller (e.g., Arduino UNO). Use a 10kΩ pull-up resistor between the DATA pin and VCC.
  3. Install Required Libraries: If using an Arduino, install the "DHT sensor library" by Adafruit from the Arduino Library Manager.
  4. Write the Code: Use the library functions to read temperature and humidity data.

Example Code for Arduino UNO

Below is an example Arduino sketch to read data from the DHT 22 sensor:

#include "DHT.h"

// Define the pin where the DHT 22 is connected
#define DHTPIN 2  // Connect DATA pin to digital pin 2

// Define the type of DHT sensor
#define DHTTYPE DHT22  // DHT 22 (AM2302)

// Initialize the DHT sensor
DHT dht(DHTPIN, DHTTYPE);

void setup() {
  Serial.begin(9600);  // Start serial communication at 9600 baud
  Serial.println("DHT 22 Sensor Test");
  dht.begin();  // Initialize the DHT sensor
}

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

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

  // Check if the readings are valid
  if (isnan(temperature) || isnan(humidity)) {
    Serial.println("Failed to read from DHT sensor!");
    return;
  }

  // Print the readings to the Serial Monitor
  Serial.print("Temperature: ");
  Serial.print(temperature);
  Serial.println(" °C");

  Serial.print("Humidity: ");
  Serial.print(humidity);
  Serial.println(" %");
}

Important Considerations and Best Practices

  • Sampling Rate: The DHT 22 has a sampling rate of 0.5 Hz, meaning you should wait at least 2 seconds between readings to avoid inaccurate data.
  • Pull-Up Resistor: Ensure a 10kΩ pull-up resistor is connected between the DATA pin and VCC for stable communication.
  • Cable Length: Keep the cable length between the sensor and microcontroller as short as possible to minimize signal degradation.
  • Environmental Factors: Avoid placing the sensor in direct sunlight or near heat sources, as this may affect accuracy.

Troubleshooting and FAQs

Common Issues and Solutions

  1. No Data or Incorrect Readings:

    • Ensure the pull-up resistor is properly connected between the DATA pin and VCC.
    • Verify that the sensor is powered with the correct voltage (3.3V to 6V).
    • Check the wiring and ensure the DATA pin is connected to the correct digital pin on the microcontroller.
  2. "Failed to Read from DHT Sensor" Error:

    • Ensure the DHT sensor library is installed and correctly included in your code.
    • Verify that the correct sensor type (DHT22) is defined in the code.
    • Check for loose or incorrect connections.
  3. Slow Response Time:

    • The DHT 22 has a fixed sampling rate of 0.5 Hz. Ensure your code includes a delay of at least 2 seconds between readings.

FAQs

Q: Can I use the DHT 22 with a 3.3V microcontroller?
A: Yes, the DHT 22 operates within a voltage range of 3.3V to 6V, making it compatible with 3.3V microcontrollers like the ESP8266 or ESP32.

Q: What is the maximum cable length for the DHT 22?
A: The recommended maximum cable length is 20 meters. However, for longer distances, use a lower pull-up resistor value (e.g., 4.7kΩ) to maintain signal integrity.

Q: How does the DHT 22 compare to the DHT 11?
A: The DHT 22 is more accurate and has a wider range for both temperature and humidity measurements compared to the DHT 11. However, it is slightly more expensive.

Q: Can I use multiple DHT 22 sensors in the same project?
A: Yes, you can use multiple sensors by connecting each DATA pin to a separate digital pin on the microcontroller.

By following this documentation, you can effectively integrate the DHT 22 sensor into your projects for reliable temperature and humidity monitoring.