Electronics

DHT22 Temperature and Humidity Sensor Module

AED 30.95

1

Description

The DHT22 Humidity and Temperature Sensor is an affordable and reliable digital sensor designed to measure temperature and humidity. it accurately detects and interprets the surrounding air conditions. With its convenient digital signal pin, obtaining data from the sensor is straightforward. The DHT22 sensor offers an uncomplicated and user-friendly experience, making it suitable for various applications. Whether you need to monitor environmental conditions or integrate it into a larger system, this sensor provides an accessible solution for measuring temperature and humidity.

 

Package Includes:

  • 1 x DHT22 Temperature And Humidity Module.
  • 3 x Female to Female Dupont cable.

 

Features:

  • Dual functionality: The DHT22 sensor is capable of measuring both humidity and temperature in a single module, making it convenient for applications that require monitoring of both parameters.
  • High accuracy: The DHT22 sensor provides high accuracy measurements for both humidity and temperature. The temperature accuracy is typically within ±0.5°C, while the humidity accuracy is usually within ±2% RH.
  • Wide measurement range: The DHT22 sensor has a wide measurement range, making it suitable for various environments and applications. The temperature measurement range is generally between -40°C to 125°C, and the humidity measurement range is typically between 0% to 100% RH.
  • Digital output: The DHT22 sensor utilizes a digital output interface, which simplifies the process of reading and integrating the sensor data into microcontrollers or other digital systems. It uses a single-wire digital communication protocol, allowing for easy integration with popular microcontrollers like Arduino.
  • Low power consumption: The DHT22 sensor operates on low power and has a sleep mode that further conserves energy when not actively measuring. This makes it suitable for battery-powered applications or situations where power efficiency is crucial.
  • Fast response time: The DHT22 sensor has a fast response time, allowing it to provide real-time humidity and temperature readings. This feature is particularly useful in applications that require quick monitoring and control of environmental conditions.
  • Built-in calibration: The DHT22 sensor comes pre-calibrated from the factory, which eliminates the need for additional calibration by the user. This ensures accurate measurements without the hassle of calibration procedures.
  • Compact and easy to use: The DHT22 sensor module is compact and typically comes with pre-soldered pins for easy connection. It is designed for straightforward integration into projects and can be mounted or placed in various orientations.
  • 3 pins Module: The sensor comes in a convenient 3-pin module, making it easy to connect and integrate into various projects or systems. The three pins are typically used for power supply, data communication, and ground connections.

 

Description:

The DHT22 Humidity and Temperature Sensor is an affordable digital sensor module specifically designed for measuring temperature and humidity in various applications. It utilizes a combination of a capacitive humidity sensor and a thermistor to accurately monitor the surrounding air conditions. The sensor module operates by providing a digital output signal on a single data pin, making it relatively easy to integrate into microcontrollers or other digital systems. To use the sensor, you simply connect the first pin to a power source (ranging from 3V to 5V), connect another pin to your data input pin, and connect the last pin to the ground. While the DHT22 sensor module shares some similarities with Dallas One Wire sensors, it is important to note that it is not compatible with the Dallas One Wire protocol. Instead, it uses its own proprietary communication protocol. In terms of performance, the DHT22 sensor module offers higher accuracy and precision compared to its counterpart, the DHT11 sensor. It has a wider operating range, with the ability to measure relative humidity from 0% to 100% and temperatures ranging from -40 to 125 degrees Celsius. The resolution of the sensor module is 0.1 for both humidity (RH) and temperature (degrees Celsius), meaning it can detect even small changes in these parameters. The accuracy of the humidity readings is typically within +/- 2%, while the temperature accuracy is usually within +/- 0.3 degrees Celsius. The DHT22 sensor module is well-documented, and its datasheet provides detailed specifications and usage instructions. It is a reliable choice for projects that require precise temperature and humidity monitoring, and it offers a cost-effective solution without compromising performance.

 

Principle of Work:

By utilizing asynchronous serial communication and a standardized data format, the DHT22 sensor module ensures a straightforward and reliable process for reading temperature and humidity values with minimal effort on the part of the user:

  • The DHT22 Humidity and Temperature Sensor module employs an asynchronous serial communication mode, similar to RS-232, to transmit data to a microcontroller. Unlike I2C or SPI protocols, there is no dedicated clock pin. Therefore, it operates in what is known as single-bus communication.
  • To enable communication, a pull-up resistor is necessary. The sensor module is designed to work with both 3.3V and 5V power sources, thanks to the pull-up resistor requirement. This flexibility allows the sensor to be compatible with a wide range of microcontrollers.
  • The S pin (data pin) on the DHT22 module can be connected to any available digital pin on the microcontroller. This flexibility in pin selection simplifies the wiring process and facilitates integration into various projects.
  • The DHT22 sensor module comes pre-calibrated from the factory, ensuring accuracy and ease of setup. To read the temperature and humidity values, a 5K pull-up resistor connects the data pin of the sensor to an I/O pin on the microcontroller. The data pin serially transmits the values, including an 8-bit humidity integer, an 8-bit humidity decimal, an 8-bit temperature integer, an 8-bit fractional temperature, and an 8-bit parity bit.
  • To request data from the DHT22 module, the microcontroller's I/O pin must briefly be set low and then maintained high. The specific timing and length of each host signal required for communication are explained in detail in the datasheet, providing precise instructions for successful data retrieval.

 

Pinout of the Board:

1

VCC

Power supply 3.5V to 5.5V

2

Data

Outputs both Temperature and Humidity through serial Data

3

Ground

Connected to the ground of the circuit

 

Note: The sensor will burn down if you connect VCC and GND in the wrong Wiring.


Applications:

  1. Environmental monitoring: The DHT22 module is widely used in environmental monitoring systems to measure and track temperature and humidity levels in indoor and outdoor environments. It helps ensure optimal conditions in greenhouses, warehouses, data centers, and other controlled environments.
  2. HVAC systems: Heating, Ventilation, and Air Conditioning (HVAC) systems utilize the DHT22 sensor module to provide accurate temperature and humidity readings. This enables efficient regulation of temperature and humidity levels, ensuring comfort and energy efficiency in homes, offices, and commercial buildings.
  3. Weather stations: The DHT22 module is employed in weather stations to measure temperature and humidity. By collecting data from multiple locations, weather patterns, and trends can be analyzed, aiding in weather forecasting and research.
  4. Agriculture and farming: The DHT22 sensor module is used in agricultural applications such as greenhouse cultivation, crop management, and livestock monitoring. It helps farmers maintain optimal conditions for plant growth and animal well-being by providing real-time temperature and humidity data.
  5. Indoor air quality monitoring: In indoor environments, the DHT22 module is utilized to monitor and assess air quality. It helps identify potential issues related to humidity levels, such as mold growth or excessive dryness, allowing for timely interventions to maintain a healthy indoor environment.
  6. Home automation: The DHT22 module is integrated into home automation systems to enable smart control of temperature and humidity. This allows homeowners to regulate their environment automatically, improving energy efficiency and comfort.
  7. Industrial applications: The DHT22 module is employed in various industrial processes where temperature and humidity control is critical. It is used in manufacturing facilities, laboratories, pharmaceutical industries, and food storage areas to ensure optimal conditions for production, storage, and quality control.
  8. IoT (Internet of Things) projects: The DHT22 module is a popular choice for IoT projects involving environmental monitoring. It can be connected to microcontrollers or IoT platforms to gather and transmit temperature and humidity data wirelessly, enabling remote monitoring and analysis.

 

Circuit:

  • To utilize the DHT22 sensor with an Arduino, we'll follow a simple connection setup. First, we'll connect the VCC (power) pin of the sensor module to the 5V pin on the Arduino board. This ensures that the sensor receives the required power supply.
  • Next, we'll establish a ground connection by connecting the GND (ground) pin of the sensor module to the GND pin on the Arduino. This connection completes the electrical circuit and ensures a common reference for both devices.
  • Finally, we'll connect the data pin of the sensor module to the A0 (analog input) pin on the Arduino. This enables the Arduino to read the temperature data from the DHT22 sensor.
  • Once the connections are made, we can write a simple Arduino program to read the temperature data from the sensor and display it on the serial monitor. This allows us to observe the temperature readings in real-time and monitor changes.

 

Library: 

  1. Download the DHT library: You can find the library at this link: DHT Library. Click on the link and it will start downloading the library as a ZIP file.
  2. Open the Arduino IDE: Launch your Arduino IDE (Integrated Development Environment) software on your computer. If you don't have it installed yet, you can download it from the official Arduino website: Arduino IDE Download.
  3. Install the library: Once you have the Arduino IDE open, navigate to the menu bar and click on "Sketch." From the drop-down menu, select "Include Library" and then click on "Add .ZIP Library."
  4. Select the downloaded ZIP library: A file browser window will appear. Locate the downloaded DHT library ZIP file on your computer and select it. The Arduino IDE will automatically install the library for you.

That's it! You have successfully installed the DHT library

 

Code:

This code reads temperature and humidity data from the DHT22 sensor using the read2 function, which provides float values for both temperature and humidity. The data is then printed on the serial monitor. The delay between readings is set to 2 seconds to match the DHT22 sampling rate:

#include "SimpleDHT.h"

// Define the pin connected to DHT22
int pinDHT22 = 2;

// Create an instance of the SimpleDHT22 class
SimpleDHT22 dht22(pinDHT22);

void setup() {
  Serial.begin(115200);
}

void loop() {
  // Start working...
  Serial.println("=================================");
  Serial.println("Sample DHT22...");
  
  // Read temperature and humidity
  float temperature = 0;
  float humidity = 0;
  int err = SimpleDHTErrSuccess;
  
  // Use the read2 function to get float data for temperature and humidity
  if ((err = dht22.read2(&temperature, &humidity, NULL)) != SimpleDHTErrSuccess) {
    Serial.print("Read DHT22 failed, err="); 
    Serial.println(err);
    delay(2000);
    return;
  }
  
  Serial.print("Sample OK: ");
  Serial.print((float)temperature);
  Serial.print(" *C, ");
  Serial.print((float)humidity);
  Serial.println(" RH%");
  
  // DHT22 sampling rate is 0.5Hz (2 seconds delay)
  delay(2000);
} 

Remember to verify and upload the code to your Arduino board, and open the serial monitor at a baud rate of 115200 to view the temperature and humidity readings.

  1. #include "SimpleDHT.h": This line includes the SimpleDHT library, which provides functions to interact with the DHT22 sensor.
  2. int pinDHT22 = 2;: Here, the variable pinDHT22 is defined and set to the Arduino pin number (in this case, pin 2) to which the DHT22 sensor is connected. You can modify this value if you have connected the sensor to a different pin.
  3. SimpleDHT22 dht22(pinDHT22);: This line creates an instance of the SimpleDHT22 class called dht22 using the pin number specified earlier. This instance will be used to interact with the DHT22 sensor.
  4. void setup(): This is the setup function in Arduino. It runs once at the start of the program.
  5. Serial.begin(115200);: This line initializes the serial communication with a baud rate of 115200. It is used to communicate with the serial monitor in the Arduino IDE.
  6. void loop(): This is the loop function in Arduino. It runs repeatedly after the setup function.
  7. Serial.println("=================================");: This line prints a separator line in the serial monitor to distinguish each reading.
  8. Serial.println("Sample DHT22...");: This line prints a message indicating that the DHT22 sensor is being sampled.
  9. float temperature = 0; and float humidity = 0;: These lines declare two float variables to store the temperature and humidity values obtained from the sensor.
  10. int err = SimpleDHTErrSuccess;: This line declares an integer variable called err and initializes it to SimpleDHTErrSuccess. It will be used to store any error code returned by the DHT22 sensor.
  11. if ((err = dht22.read2(&temperature, &humidity, NULL)) != SimpleDHTErrSuccess) { ... }: This conditional statement uses the read2 function from the SimpleDHT22 library to read the temperature and humidity values from the sensor. If the read operation fails (indicated by a non-zero error code), the code inside the curly braces will be executed.
  12. Serial.print("Read DHT22 failed, err="); and Serial.println(err);: These lines print an error message and the error code to the serial monitor if the sensor reading fails.
  13. Serial.print("Sample OK: ");, Serial.print((float)temperature);, Serial.print(" *C, ");, Serial.print((float)humidity);, and Serial.println(" RH%");: These lines print the sampled temperature and humidity values to the serial monitor if the sensor reading is successful.
  14. delay(2000);: This line adds a delay of 2 seconds before the next iteration of the loop. It ensures that the DHT22 sensor is sampled at a rate of approximately 0.5Hz, as specified in the comments.

 

Technical Details:

  • Supply voltage: 5V (operates within the range of 3 to 5V for power and I/O)
  • Temperature range: -40°C to 80°C
  • Temperature resolution: 0.1°C
  • Temperature error: Less than ±0.5°C
  • Humidity range: 0% to 100% RH (relative humidity)
  • Humidity resolution: 0.1% RH
  • Humidity error: ±2% RH
  • Pin sequence: VCC (power), GND (ground), S (data)
  • Size: 38 x 20mm

 

Resources:

 

Comparisons:

When comparing the DHT22 module to the DHT11 module, if accuracy, wider measurement range, and higher-quality measurements are important for your project, the DHT22 module would be the preferable choice. However, if you have budget constraints or need measurements within the narrower range of the DHT11 module, it can still be a suitable option:

  1. Accuracy: The DHT22 module generally offers higher accuracy compared to the DHT11 module. The DHT22 has an accuracy of ±0.5°C for temperature and ±2% RH for humidity, while the DHT11 has an accuracy of ±2°C for temperature and ±5% RH for humidity. Therefore, the DHT22 provides more precise and reliable measurements.
  2. Temperature and Humidity Range: The DHT22 module has a wider measurement range for both temperature (-40°C to 80°C) and humidity (0% to 100% RH) compared to the DHT11. The DHT11 module has a temperature range of 0°C to 50°C and a humidity range of 20% to 80% RH. If you require measurements outside these ranges, the DHT22 would be a better choice.
  3. Resolution: Both modules have a resolution of 0.1°C for temperature and 0.1% RH for humidity, providing similar precision in terms of the smallest detectable change in temperature and humidity.
  4. Cost: The DHT11 module is generally less expensive than the DHT22 module, making it a more budget-friendly option. However, the tradeoff is the lower accuracy and narrower measurement range.
  5. Physical Size: In terms of physical size, both modules are relatively compact, but the DHT22 module is slightly larger than the DHT11 module.
  6. Compatibility: The DHT22 module, with its proprietary communication protocol, is not compatible with the Dallas One Wire protocol. On the other hand, the DHT11 module is compatible with the One Wire protocol, which may be advantageous for certain projects and applications.