Sensors & Detectors Digital 1-Wire -40°C to +80°C Range 0-100% RH

DHT22 (AM2302) Temperature & Humidity Sensor - Wiring, Code & 3D STL Case

Loading 3D STL Model...
Drag to rotate | Scroll to zoom | Double-click to reset

Advertisement

Module Overview & Precision

The DHT22 (also known by its component name AM2302) is a calibrated digital relative humidity and temperature sensor. It incorporates a capacitive humidity sensing element and a high-precision NTC thermistor linked to a dedicated 8-bit microcontroller that outputs a single-bus digital signal.

Compared to the budget DHT11, the DHT22 features a substantially wider measurement range (-40°C to 80°C and 0 to 100% RH) and higher accuracy (±0.5°C and ±2% RH), making it the gold standard for DIY weather stations, terrariums, and home HVAC monitoring.

Technical Specifications

Parameter Specification
Operating Voltage 3.3V – 6.0V DC (Works natively with 3.3V ESP32 and 5V Arduino)
Humidity Range 0 to 100% RH ± 2% accuracy
Temperature Range -40°C to +80°C ± 0.5°C accuracy
Sampling Rate 0.5 Hz (One measurement every 2 seconds)
Current Consumption 1.5 mA measuring, 50 μA standby
Output Protocol Custom single-bus digital protocol

Pinout Table & Pull-Up Resistor

Looking at the front patterned grid with pins pointing downward from left to right:

Pin # Name Function Wiring Details
1 VDD (VCC) Power Input (3.3V - 5V) Connect to 3.3V (ESP32) or 5V (Arduino)
2 DATA Single-bus serial signal Digital pin + 4.7kΩ - 10kΩ pull-up to VCC
3 NC Null / Not connected Leave unconnected
4 GND Ground Connect to Common GND (0V)

Tip: If you are using the 3-pin breakout board version (with an onboard resistor), you do not need to add an external pull-up resistor.

Arduino Sample Code (Adafruit DHT Library)

DHT22_Reader.ino C++ / Arduino
#include "DHT.h"

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

DHT dht(DHTPIN, DHTTYPE);

void setup() {
  Serial.begin(115200);
  Serial.println(F("DHT22 Climate Sensor Initialized!"));
  dht.begin();
}

void loop() {
  // Wait at least 2 seconds between measurements
  delay(2000);

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

  // Check if any reads failed
  if (isnan(humidity) || isnan(tempC)) {
    Serial.println(F("Failed to read from DHT22 sensor! Check wiring."));
    return;
  }

  Serial.print(F("Humidity: "));
  Serial.print(humidity);
  Serial.print(F("%  |  Temperature: "));
  Serial.print(tempC);
  Serial.println(F("°C"));
}

3D Printing & Enclosure Recommendations

Accurate climate readings require natural convection air circulation around the white sensing grid while shielding the sensor from radiant heat and solar radiation:

  • Louvered Vents: Our 3D model features 45-degree angled chevron slats allowing airflow while preventing direct indoor dust ingress.
  • Wall Mount: Built-in keyhole slot on the rear panel for toolless hanging on drywall screws.
  • Thermal Isolation: Designed with an internal separator baffle that prevents heat from ESP32 microcontrollers or power regulators from skewing temperature readings.