DHT22 Temperature and Humidity Sensor Module

65,00 DH 75,00 DH

Availability:

121 in stock

SKU: 0136-B Categories: ,

Description

DHT22 Temperature and Humidity Sensor Module

The DHT22 is a digital temperature and humidity sensor. The source describes it as offering improved accuracy over the DHT11. It uses a capacitive humidity sensor and a thermistor for temperature, and sends readings over a single-wire digital interface.

Specifications (as listed)

  • Temperature range: −40°C to 80°C
  • Temperature accuracy: ±0.5°C
  • Humidity range: 0% to 100% RH
  • Humidity accuracy: ±2% RH
  • Operating voltage: 3.5–5.5 V
  • Operating current: up to 2.5 mA during conversion
  • Digital single-wire output
  • Sampling rate: 0.5 Hz (one reading every two seconds)

How it works

An onboard microcontroller converts the sensor readings to digital data that a controller such as Arduino can read.

Applications

  • Local weather stations
  • Automatic climate-control systems
  • Environmental monitoring
  • Educational and hobby projects

Pinout

The DHT22 is available as a four-pin bare sensor or a three-pin module. Pin arrangements differ between the versions.

Bare DHT22 sensor (4 pins):

  1. VCC: supply, 3.5–5.5 V
  2. Data: digital data output
  3. NC: not connected
  4. GND: ground

DHT22 module (3 pins):

  1. VCC: supply, 3.5–5.5 V
  2. Data: digital data
  3. GND: ground

Using it with Arduino Uno

Basic example: required components
  • Arduino Uno
  • DHT22 temperature and humidity sensor
  • 10 kΩ resistor (for the bare sensor only)
  • Jumper wires
Basic Arduino code example
#include "DHT.h"


#define DHTPIN 2     // Broche à laquelle le capteur est connecté
#define DHTTYPE DHT22   // Définir le type de capteur


DHT dht(DHTPIN, DHTTYPE);


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


void loop() {
  float h = dht.readHumidity();
  float t = dht.readTemperature();
  
  if (isnan(h) || isnan(t)) {
    Serial.println("Échec de lecture !");
    return;
  }
  
  Serial.print("Humidité: ");
  Serial.print(h);
  Serial.print(" %\t");
  Serial.print("Température: ");
  Serial.print(t);
  Serial.println(" *C");
  
  delay(2000);
}
Explanation of the basic example
  1. Include the library: #include "DHT.h" adds the DHT library.
  2. Set the pin and sensor type: DHTPIN 2 and DHTTYPE DHT22 identify the data pin and sensor.
  3. Initialize: dht.begin() starts the sensor library.
  4. Read values: dht.readHumidity() and dht.readTemperature() read humidity and temperature.
  5. Display readings: values are sent to the serial monitor.
Basic wiring
  • DHT22 VCC: Arduino 5V
  • DHT22 Data: Arduino pin 2, with a 10 kΩ pull-up resistor for the bare sensor
  • DHT22 GND: Arduino GND
Advanced Arduino code example
#include "DHT.h"
#include <Wire.h>
#include <LiquidCrystal_I2C.h>


#define DHTPIN 2     // Broche à laquelle le capteur est connecté
#define DHTTYPE DHT22   // Définir le type de capteur


DHT dht(DHTPIN, DHTTYPE);
LiquidCrystal_I2C lcd(0x27, 16, 2);


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


void loop() {
  float h = dht.readHumidity();
  float t = dht.readTemperature();
  
  if (isnan(h) || isnan(t)) {
    lcd.setCursor(0, 0);
    lcd.print("Échec de lecture!");
    Serial.println("Échec de lecture !");
    return;
  }
  
  lcd.setCursor(0, 0);
  lcd.print("Hum: ");
  lcd.print(h);
  lcd.print(" %");


  lcd.setCursor(0, 1);
  lcd.print("Temp: ");
  lcd.print(t);
  lcd.print(" C");


  Serial.print("Humidité: ");
  Serial.print(h);
  Serial.print(" %\t");
  Serial.print("Température: ");
  Serial.print(t);
  Serial.println(" *C");
  
  delay(2000);
}
Components for the advanced example
  • Arduino Uno
  • DHT22 temperature and humidity sensor
  • 1602 I2C LCD
  • 10 kΩ resistor (for the bare sensor only)
  • Jumper wires
Explanation of the advanced example
  1. Include libraries: DHT.h, Wire.h and LiquidCrystal_I2C.h provide the sensor and LCD support.
  2. Set the pin and sensor type: DHTPIN 2 and DHTTYPE DHT22 select the sensor connection.
  3. Initialize: dht.begin() starts the sensor and lcd.begin() initializes the display.
  4. Read values: the DHT library reads humidity and temperature.
  5. Display readings: values are shown on the LCD and serial monitor.
Advanced wiring
  • DHT22 VCC: Arduino 5V
  • DHT22 Data: Arduino pin 2, with a 10 kΩ pull-up resistor for the bare sensor
  • DHT22 GND: Arduino GND
  • LCD VCC: Arduino 5V
  • LCD GND: Arduino GND
  • LCD SDA: Arduino A4
  • LCD SCL: Arduino A5

Installing libraries

Install the DHT and LiquidCrystal_I2C libraries in the Arduino IDE:

  1. Open the Arduino IDE.
  2. Open the Library Manager from Sketch → Include Library → Manage Libraries.
  3. Search for “DHT” and install Adafruit’s “DHT sensor library”.
  4. Search for “LiquidCrystal_I2C” and install a compatible library.

Datasheet

Thank you for your loyalty!

EN