Tags: Temperature, Humidity, Sensor, DHT21, AM2301

DHT21 AM2301 Temperature & Humidity Sensor for Arduino

  • 25.00 AED
    • Ex Tax:25.00 AED
    • Product Code: AM2301
    • Availability: In Stock
    Introduction The DHT-21 (also named as AM2301) is a digital-output relative humidity and temperature sensor. It uses a capacitive humidity sensor and a thermistor to measure the surrounding air, and spits out a digital signal on the data pin.In this tutorial you will learn how to use this senso..

    Introduction 

    Picture
    The DHT-21 (also named as AM2301) is a digital-output relative humidity and temperature sensor. It uses a capacitive humidity sensor and a thermistor to measure the surrounding air, and spits out a digital signal on the data pin.
    In this tutorial you will learn how to use this sensor with Arduino uno. The room temperature & humidity will be printed to serial monitor.

    About the  DHT-21 sensor

    The DHT21 is a basic, low-cost digital temperature and humidity sensor. It uses a capacitive humidity sensor and a thermistor to measure the surrounding air, and spits out a digital signal on the data pin (no analog input pins needed). Its fairly simple to use, but requires careful timing to grab data. The only real downside of this sensor is you can only get new data from it once every 2 seconds, so when using our library, sensor readings can be up to 2 seconds old.


    ​Technical details:
    • Power: 3.3 - 5.2V
    • Humidity: 0-99.9%,  3%RH accuracy
    • Temperature: -40 to 80°C, ±0.5°C accuracy
    Picture

    What you will need - Hardware

    For this tutorial you will need:
    Picture

    The Circuit

    The connections are pretty easy:
    • Red cable to Arduino 3.3V or 5V pin 
    • Black cable to Arduino GND pin 
    • Yellow cable to Arduino 2 digital pin

    The code

    /* How to use the DHT-21 sensor with Arduino uno
       Temperature and humidity sensor
       More info: http://www.ardumotive.com/how-to-use-dht-21-sensor-en.html
       Dev: Michalis Vasilakis // Date: 19/11/2016 // www.ardumotive.com */
    
    //Libraries
    #include <dht.h>
    dht DHT;
    //Constants
    #define DHT21_PIN 2     // DHT 22  (AM2302) - what pin we're connected to
    
    //Variables
    float hum;  //Stores humidity value
    float temp; //Stores temperature value
    
    void setup()
    {
        Serial.begin(9600);
    }
    
    void loop()
    {
        int chk = DHT.read21(DHT21_PIN);
        //Read data and store it to variables hum and temp
        hum = DHT.humidity;
        temp= DHT.temperature;
        //Print temp and humidity values to serial monitor
        Serial.print("Humidity: ");
        Serial.print(hum);
        Serial.print(" %, Temp: ");
        Serial.print(temp);
        Serial.println(" Celsius");
        delay(2000); //Delay 2 sec.
    }
    
    Download the code from here and open it with Arduino IDE. Inside you will also find and the DHT.h library.
    dht21_tutorial.zip
    Download File

    Open the serial monitor from tools menu of Arduino IDE.

    ​The result:
    Picture

    Well done!

    Picture

    There are no reviews for this product.

    Write a review

    Please login or register to review