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

How to Use DHT22 (Wokwi Compatible): Examples, Pinouts, and Specs

Image of DHT22 (Wokwi Compatible)
Cirkit Designer LogoDesign with DHT22 (Wokwi Compatible) in Cirkit Designer

Introduction

The DHT22 is a reliable sensor for measuring temperature and humidity. It is a digital sensor that provides high accuracy and long-term stability, making it suitable for a wide range of applications, including weather stations, home automation systems, and environmental monitoring.

Explore Projects Built with DHT22 (Wokwi Compatible)

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 R4 WiFi Controlled Temperature and Humidity Sensor with LED Indicator
Image of Z1 P2: A project utilizing DHT22 (Wokwi Compatible) in a practical application
This circuit features an Arduino UNO R4 WiFi microcontroller connected to a DHT22 sensor for measuring temperature and humidity. The DHT22's data line is connected to digital pin D2 on the Arduino, while its power and ground are supplied by the Arduino's 5V and GND pins, respectively. Additionally, there is a red LED with a series resistor connected to digital pin D3 on the Arduino, which could be used for status indication.
Cirkit Designer LogoOpen Project in Cirkit Designer
Arduino Mega 2560 with Multiple DHT Sensors for Environmental Monitoring
Image of Schematic Diagram: A project utilizing DHT22 (Wokwi Compatible) in a practical application
This circuit is designed to monitor temperature and humidity using two DHT22 sensors and one DHT11 sensor, all controlled by an Arduino Mega 2560. The sensors are powered by the Arduino and communicate with it through digital pins D2, D3, and D4. The provided code is a template for implementing the sensor data acquisition logic.
Cirkit Designer LogoOpen Project in Cirkit Designer
Battery-Powered Wi-Fi Temperature and Humidity Monitor with Wemos D1 Mini and DHT22
Image of Temp, humidity battery powered D1 sensor: A project utilizing DHT22 (Wokwi Compatible) in a practical application
This circuit appears to be a sensor node with a DHT22 temperature and humidity sensor interfaced with a Wemos D1 Mini microcontroller. The Wemos D1 Mini is powered by a 18650 Li-ion battery, which is charged and protected by a TP4056 charging module. The sensor's data output is connected to the D4 pin of the Wemos D1 Mini for digital signal processing, and voltage dividers made of resistors are likely used for level shifting or pull-up/pull-down purposes.
Cirkit Designer LogoOpen Project in Cirkit Designer
Wi-Fi Controlled Weather Station with Wemos D1 Mini and OLED Display
Image of izdelie_3: A project utilizing DHT22 (Wokwi Compatible) in a practical application
This circuit is a weather monitoring system that uses a Wemos D1 Mini microcontroller to read temperature and humidity data from four DHT22 sensors and display the information on an Adafruit OLED screen. The data is also transmitted via WiFi to an MQTT server for remote monitoring. The system is powered by a 2000mAh battery, which is managed by a TP4056 charging module and a Mtiny Power module.
Cirkit Designer LogoOpen Project in Cirkit Designer

Explore Projects Built with DHT22 (Wokwi Compatible)

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 Z1 P2: A project utilizing DHT22 (Wokwi Compatible) in a practical application
Arduino UNO R4 WiFi Controlled Temperature and Humidity Sensor with LED Indicator
This circuit features an Arduino UNO R4 WiFi microcontroller connected to a DHT22 sensor for measuring temperature and humidity. The DHT22's data line is connected to digital pin D2 on the Arduino, while its power and ground are supplied by the Arduino's 5V and GND pins, respectively. Additionally, there is a red LED with a series resistor connected to digital pin D3 on the Arduino, which could be used for status indication.
Cirkit Designer LogoOpen Project in Cirkit Designer
Image of Schematic Diagram: A project utilizing DHT22 (Wokwi Compatible) in a practical application
Arduino Mega 2560 with Multiple DHT Sensors for Environmental Monitoring
This circuit is designed to monitor temperature and humidity using two DHT22 sensors and one DHT11 sensor, all controlled by an Arduino Mega 2560. The sensors are powered by the Arduino and communicate with it through digital pins D2, D3, and D4. The provided code is a template for implementing the sensor data acquisition logic.
Cirkit Designer LogoOpen Project in Cirkit Designer
Image of Temp, humidity battery powered D1 sensor: A project utilizing DHT22 (Wokwi Compatible) in a practical application
Battery-Powered Wi-Fi Temperature and Humidity Monitor with Wemos D1 Mini and DHT22
This circuit appears to be a sensor node with a DHT22 temperature and humidity sensor interfaced with a Wemos D1 Mini microcontroller. The Wemos D1 Mini is powered by a 18650 Li-ion battery, which is charged and protected by a TP4056 charging module. The sensor's data output is connected to the D4 pin of the Wemos D1 Mini for digital signal processing, and voltage dividers made of resistors are likely used for level shifting or pull-up/pull-down purposes.
Cirkit Designer LogoOpen Project in Cirkit Designer
Image of izdelie_3: A project utilizing DHT22 (Wokwi Compatible) in a practical application
Wi-Fi Controlled Weather Station with Wemos D1 Mini and OLED Display
This circuit is a weather monitoring system that uses a Wemos D1 Mini microcontroller to read temperature and humidity data from four DHT22 sensors and display the information on an Adafruit OLED screen. The data is also transmitted via WiFi to an MQTT server for remote monitoring. The system is powered by a 2000mAh battery, which is managed by a TP4056 charging module and a Mtiny Power module.
Cirkit Designer LogoOpen Project in Cirkit Designer

Common Applications and Use Cases

  • Home and building automation for climate control
  • Weather monitoring stations
  • Environmental data logging
  • Agricultural and soil monitoring
  • HVAC systems

Technical Specifications

Key Technical Details

  • Humidity Measurement Range: 0-100% RH
  • Humidity Measurement Accuracy: ±2% RH
  • Temperature Measurement Range: -40 to 80°C
  • Temperature Measurement Accuracy: ±0.5°C
  • Operating Voltage: 3.3 to 6V DC
  • Max Current: 2.5mA during conversion (while requesting data)
  • Sampling Rate: ≤ 0.5 Hz (once every 2 seconds)
  • Interface: Digital, Single-bus

Pin Configuration and Descriptions

Pin Number Name Description
1 VDD Power supply (3.3 to 6V DC)
2 DATA Digital data output
3 NC Not connected (no function)
4 GND Ground

Usage Instructions

How to Use the DHT22 in a Circuit

  1. Powering the Sensor: Connect the VDD pin to a 3.3V or 5V power supply, and the GND pin to the ground.
  2. Data Pin Connection: Connect the DATA pin to a digital input pin on your microcontroller.
  3. Pull-up Resistor: A pull-up resistor (typically 10kΩ) is required between the DATA pin and VDD for reliable communication.
  4. Reading Data: Initiate a data reading request from your microcontroller and wait for the DHT22 to send back the temperature and humidity data.

Important Considerations and Best Practices

  • Avoid placing the sensor in direct sunlight or near heat sources to prevent inaccurate readings.
  • Ensure the sensor is not exposed to condensing humidity conditions.
  • Allow the sensor to acclimate to the environment for accurate readings.
  • Use a decoupling capacitor close to the sensor's power supply pins to stabilize voltage.

Example Code for Arduino UNO

#include "DHT.h"

#define DHTPIN 2     // Digital pin connected to the DHT sensor
#define DHTTYPE DHT22 // DHT 22 (AM2302)

DHT dht(DHTPIN, DHTTYPE);

void setup() {
  Serial.begin(9600);
  dht.begin();
}

void loop() {
  // Wait a few seconds between measurements.
  delay(2000);

  // Reading temperature or humidity takes about 250 milliseconds!
  float humidity = dht.readHumidity();
  // Read temperature as Celsius (the default)
  float temperature = dht.readTemperature();

  // Check if any reads failed and exit early (to try again).
  if (isnan(humidity) || isnan(temperature)) {
    Serial.println("Failed to read from DHT sensor!");
    return;
  }

  // Compute heat index in Celsius (isFahrenheit = false)
  float heatIndex = dht.computeHeatIndex(temperature, humidity, false);

  Serial.print("Humidity: ");
  Serial.print(humidity);
  Serial.print("%  Temperature: ");
  Serial.print(temperature);
  Serial.print("°C  Heat index: ");
  Serial.print(heatIndex);
  Serial.println("°C");
}

Troubleshooting and FAQs

Common Issues

  • Inaccurate Readings: Ensure the sensor is not in an environment with rapid temperature changes and is not affected by heat sources.
  • No Data: Check the wiring, especially the pull-up resistor on the data line. Ensure the power supply is stable.
  • Erratic Data: Make sure there is a decoupling capacitor to filter out noise on the power supply line.

Solutions and Tips for Troubleshooting

  • Sensor Not Responding: Reset the power to the sensor and ensure the microcontroller pin is correctly configured.
  • Long Cable Runs: Use shielded cable for long runs to prevent signal degradation.
  • Intermittent Communication: Verify that the timing of the data request is in accordance with the sensor's sampling rate.

FAQs

Q: Can the DHT22 be used outdoors? A: Yes, but it should be protected from direct sunlight and water.

Q: How long does the DHT22 last? A: With proper care, the DHT22 can last for several years, although the accuracy may degrade over time.

Q: Is calibration required for the DHT22? A: The DHT22 comes pre-calibrated from the factory. However, for critical applications, periodic recalibration may be necessary.

Q: Can I use multiple DHT22 sensors on the same microcontroller? A: Yes, each DHT22 sensor can be connected to a separate digital pin on the microcontroller. Ensure each data line has its own pull-up resistor.