Introduction

images not found

DHT22

The DHT-22 (also named as AM2302) is a digital-output, relative humidity, and temperature sensor.

So, what is humidity? I guess that’s the first question pops up in your head

Humidity is the measure of water vapour present in the air. The level of humidity in air affects various physical, chemical and biological processes. The sensor is calibrated and doesn’t require extra components so you can get the right to measuring relative humidity and temperature.

In industrial applications, humidity can affect the business cost of the products, health and safety of the employees. In the control system, measurement of humidity is very important.

Humidity measurement determines the amount of moisture present in the gas that can be a mixture of water vapour, nitrogen, argon or pure gas etc… This sensor uses a capacitive humidity sensor and a thermistor to measure the surrounding air, and sends a digital signal on the data pin.

It is quite simple to use but requires careful timing to grab data. You can only get new data from it once every 2 seconds.

When you have a DHT 22 that has 3 pins, it means the NC pin is removed, as you can observe that when connecting our device to Arduino, you just ignore the 3rd pin.

Types of temperature sensor

DHT11 DHT22
DHT11 is cheap compared to DHT22 The DHT22 is the more expensive version which obviously has better specifications.
The DHT11 temperature range is from 0 to 50 degrees Celsius with +-2 degrees accuracy. Its temperature measuring range is from -40 to +125 degrees Celsius with +-0.5 degrees accuracy
The DHT11 humidity range is from 20 to 80% with 5% accuracy. The DHT22 sensor has better humidity measuring range, from 0 to 100% with 2-5% accuracy
it works in small range compared to DHT 22 It senses within wide range

APPLICATION OF DHT22

These are some applications of DHT22.

  • It is used for temperature and humidity measurement.
  • It is used as a weather station to measure temperature and humidity in the air.
  • It is an automatic climate control sensor.
  • It is also used as an environmental monitoring device…
  • Below is interfacing diagram of Arduino and DHT22, it is a guide which shows how to connect the sensor correctly. And a sample code to upload in Arduino, I strongly believe that this will work.

    ARDUINO CIRCUIT

    This shows how the actual connection of temperature sensor to the Arduino board

    Temperature Sensors(Arduino Code)

         // REQUIRES the following Arduino librarie:
        // - cactus_io_DHT22.h
        
        #include "cactus_io_DHT22.h"
     
        #define DHT22_PIN 2 // what pin on the arduino is the DHT22 data line connected to
        // Initialize DHT sensor for normal 16mhz Arduino.
        DHT22 dht(DHT22_PIN);
        // Note: If you are using a board with a faster processor than 16MHz then you need
        // to declare an instance of the DHT22 using
        // DHT22 dht(DHT22_DATA_PIN, 30);
        // The additional parameter, in this case here is 30 is used to increase the number of
        // cycles transitioning between bits on the data and clock lines. For the
        // Arduino boards that run at 84MHz the value of 30 should be about right.
      
        void setup(){
          Serial.begin(9600);
          Serial.println("DHT22 Humidity - Temperature Sensor");
          Serial.println("RH\tTemp (C)\tTemp (F)\tHeat Index (C)\tHeat Index (F)");
      
          dht.begin();
        }
      
        void loop(){
          // Reading temperature or humidity takes about 250 milliseconds!
          // Sensor readings may also be up to 2 seconds 'old' (its a very slow sensor)
          dht.readHumidity();
          dht.readTemperature();
          
          // Check if any reads failed and exit early (to try again).
          if (isnan(dht.humidity) || isnan(dht.temperature_C)) {
            Serial.println("DHT sensor read failure!");
            return;
          }
          
          Serial.print(dht.humidity); Serial.print(" %\t\t");
          Serial.print(dht.temperature_C); Serial.print(" *C\t");
          Serial.print(dht.temperature_F); Serial.print(" *F\t");
          Serial.print(dht.computeHeatIndex_C()); Serial.print(" *C\t");
          Serial.print(dht.computeHeatIndex_F()); Serial.println(" *F");
          
          // Wait a few seconds between measurements. The DHT22 should not be read at a higher frequency of
          // about once every 2 seconds. So we add a 3 second delay to cover this.
          delay(3000);
        }   
          

    Demonstration Photo