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

How to Use DHT22: Examples, Pinouts, and Specs

Image of DHT22
Cirkit Designer LogoDesign with DHT22 in Cirkit Designer

Introduction

The DHT22 is a reliable sensor for measuring temperature and humidity. This sensor is suitable for a wide range of applications due to its ability to provide long-term stability and relatively high measurement accuracy. Common applications include HVAC systems, weather stations, home environment monitoring, and IoT projects.

Explore Projects Built with DHT22

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 DHT22 Temperature and Humidity Sensor
Image of TEMPERATURA HUMEDAD: A project utilizing DHT22 in a practical application
This circuit consists of an Arduino UNO microcontroller connected to a DHT22 temperature and humidity sensor. The DHT22 sensor is powered by the Arduino's 5V output through a 4.7k Ohm resistor, and its data pin is connected to the digital pin D2 of the Arduino. The embedded code on the Arduino reads the temperature and humidity values from the DHT22 sensor and outputs them to the serial monitor at regular intervals.
Cirkit Designer LogoOpen Project in Cirkit Designer
Arduino UNO-Based Temperature and Humidity Sensor with DHT22
Image of firsttry: A project utilizing DHT22 in a practical application
This circuit uses an Arduino UNO to read data from a DHT22 temperature and humidity sensor. The DHT22 is powered by the Arduino's 3.3V and GND pins, with its data output connected to the Arduino's digital pin D2 through a 1.5k Ohm pull-up resistor.
Cirkit Designer LogoOpen Project in Cirkit Designer
Arduino UNO and DHT22 Temperature and Humidity Sensor with Serial Monitoring
Image of dht22 test: A project utilizing DHT22 in a practical application
This circuit uses an Arduino UNO to interface with a DHT22 temperature and humidity sensor. The Arduino reads data from the DHT22 sensor and outputs the temperature and humidity readings to the Serial Monitor. The DHT22 is powered by the Arduino's 5V and GND pins, and its data pin is connected to digital pin 2 on the Arduino.
Cirkit Designer LogoOpen Project in Cirkit Designer
Arduino UNO with DHT22 Temperature and Humidity Sensor
Image of Temperature and humidity: A project utilizing DHT22 in a practical application
This circuit connects a DHT22 temperature and humidity sensor to an Arduino UNO microcontroller. The DHT22's data pin is connected to digital pin 4 (D4) on the Arduino, allowing the microcontroller to read temperature and humidity data. The sensor is powered by the Arduino's 5V output, and both devices share a common ground.
Cirkit Designer LogoOpen Project in Cirkit Designer

Explore Projects Built with DHT22

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 TEMPERATURA HUMEDAD: A project utilizing DHT22 in a practical application
Arduino UNO Based DHT22 Temperature and Humidity Sensor
This circuit consists of an Arduino UNO microcontroller connected to a DHT22 temperature and humidity sensor. The DHT22 sensor is powered by the Arduino's 5V output through a 4.7k Ohm resistor, and its data pin is connected to the digital pin D2 of the Arduino. The embedded code on the Arduino reads the temperature and humidity values from the DHT22 sensor and outputs them to the serial monitor at regular intervals.
Cirkit Designer LogoOpen Project in Cirkit Designer
Image of firsttry: A project utilizing DHT22 in a practical application
Arduino UNO-Based Temperature and Humidity Sensor with DHT22
This circuit uses an Arduino UNO to read data from a DHT22 temperature and humidity sensor. The DHT22 is powered by the Arduino's 3.3V and GND pins, with its data output connected to the Arduino's digital pin D2 through a 1.5k Ohm pull-up resistor.
Cirkit Designer LogoOpen Project in Cirkit Designer
Image of dht22 test: A project utilizing DHT22 in a practical application
Arduino UNO and DHT22 Temperature and Humidity Sensor with Serial Monitoring
This circuit uses an Arduino UNO to interface with a DHT22 temperature and humidity sensor. The Arduino reads data from the DHT22 sensor and outputs the temperature and humidity readings to the Serial Monitor. The DHT22 is powered by the Arduino's 5V and GND pins, and its data pin is connected to digital pin 2 on the Arduino.
Cirkit Designer LogoOpen Project in Cirkit Designer
Image of Temperature and humidity: A project utilizing DHT22 in a practical application
Arduino UNO with DHT22 Temperature and Humidity Sensor
This circuit connects a DHT22 temperature and humidity sensor to an Arduino UNO microcontroller. The DHT22's data pin is connected to digital pin 4 (D4) on the Arduino, allowing the microcontroller to read temperature and humidity data. The sensor is powered by the Arduino's 5V output, and both devices share a common ground.
Cirkit Designer LogoOpen Project in Cirkit Designer

Technical Specifications

Key Technical Details

  • Temperature Range: -40 to 80°C
  • Humidity Range: 0 to 100% RH
  • Voltage: 3.3 to 6V DC
  • Current: 2.5mA max during conversion (while requesting data)
  • Accuracy: ±0.5°C (temperature), ±2-5% RH (humidity)
  • Resolution: 0.1°C (temperature), 0.1% RH (humidity)
  • Sampling Rate: ≤ 0.5 Hz (once every 2 seconds)
  • Output: Digital signal via a single data pin

Pin Configuration and Descriptions

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

Usage Instructions

Integration with a Circuit

  1. Connect the VDD pin to a 3.3V or 5V power supply.
  2. Connect the DATA pin to a digital I/O pin on a microcontroller.
  3. Connect a pull-up resistor (typically 10kΩ) between the DATA pin and VDD.
  4. Connect the GND pin to the ground of the power supply.

Best Practices

  • Ensure that the power supply is stable and within the specified voltage range.
  • Avoid placing the sensor in direct sunlight or near heat sources to prevent inaccurate readings.
  • Use a pull-up resistor on the DATA pin to ensure reliable data transmission.
  • Allow the sensor to acclimatize to the environment for accurate readings.

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");
}

Note: This code requires the DHT sensor library, which can be installed via the Arduino Library Manager.

Troubleshooting and FAQs

Common Issues

  • Inaccurate Readings: Ensure the sensor is not exposed to direct sunlight or heat sources. Allow it to acclimatize to the environment.
  • No Data: Check the wiring, especially the pull-up resistor on the DATA pin. Ensure the power supply is within the specified range.
  • Erratic Readings: Ensure there are no sources of electromagnetic interference near the sensor. Use shielded cables if necessary.

FAQs

Q: Can I use the DHT22 sensor outdoors? A: Yes, but it should be protected from direct sunlight, rain, and condensation.

Q: How long should I wait between readings? A: The DHT22 has a sampling rate of up to once every 2 seconds. It is recommended to wait at least this long to avoid self-heating and to ensure accurate measurements.

Q: What should I do if the sensor is not responding? A: Check the power supply, wiring, and pull-up resistor. If the issue persists, replace the sensor as it may be defective.

For further assistance, consult the manufacturer's datasheet and technical support resources.