Arduino and DHT22 (AM2302) Temperature Measurement

Introduction: Arduino and DHT22 (AM2302) Temperature Measurement


The DHT22 (AM2302) is a high precision temperature sensor module, provide calibrated temperature and humidity which is connected to digital IO pin of Arduino. The DHT22 provides the temperature in Celsius format. The Arduino program converts the temperature into Fahrenheit, Kelvin and Rankine, and sends via serial port.

Parts and components

Arduino Uno board = 1 No

DHT22 (AM2302) = 1 No

10K Resistor = 1No

10K Resistor = 1No

Teacher Notes

Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.

Step 1: Schematic

DHT22 digital temperature / humidity sensor delivers temperatures between -40°C and +80°C and humidity between 0% to 100%. The temperature accuracy is ±0.1°C (maximum).

The DHT22 data pin is connected with Arduino digital IO pin, and pulled up to Vcc, via 10K ohm resistor. DHT22 (AM2302) outputs calibrated digital data signal.

Every DHT22 sensor of this model is temperature compensated and calibrated in accurate calibration chamber and the calibration-coefficient is saved in internal OTP memory.

The sensor supports long transmission distance.

Arduino reads the temperature and humidity at 2 second interval and sends to the serial port.

The conversion formula for Celsius to other scale are given below.

Fahrenheit:- T(°F) = T(°C) × 9/5 + 32

Kelvin:- T(K) = T(°C) + 273.15

Rankine:- T(°R) = (T(°C) + 273.15) × 9/5

Step 2: Software

The included DHT library offers the read interface for the sensor.

Arduino reads the temperature and humidity values at 2 seconds interval.

The temperature is in Celsius format, which is converted into Fahrenheit, Kelvin and Rankine format by the software.

All four formats are send to the serial port and will be printed on the serial terminal.

// Experiment of DHT22 digital temperature reader

//DHT11 Data line connected to Arduino digital IO 2

// Name:- M.Pugazhendi // Date:- 19thAug2016 // Version:- V0.1 // e-mail:-

//Libraries #include <DHT.h>

//Constants #define DHTPIN 2 // what pin we're connected to #define DHTTYPE DHT22 // DHT22

DHT dht(DHTPIN, DHTTYPE); // Initialize DHT sensor for normal 16mhz Arduino

//Variables float hum; //Stores humidity value float temp; //Stores temperature value

void setup() { //Initialize serial port Serial.begin(9600);

Serial.println("DHT22 sensor testing"); //Initialize the DHT sensor dht.begin(); }

void loop() { float converted = 0.00; //Read data and store it to variables hum and temp hum = dht.readHumidity(); temp= dht.readTemperature();

Serial.print("Celsius = "); Serial.print(temp); //Print degree symbol Serial.write(176); Serial.println("C");

//Fahrenheit //T(°F) = T(°C) × 9/5 + 32 converted = ( temp * 1.8 ) + 32; Serial.print("Fahrenheit = "); Serial.print(converted); //Print degree symbol Serial.write(176); Serial.println("F");

//Kelvin //T(K) = T(°C) + 273.15 converted = temp + 273.15; Serial.print("Kelvin = "); Serial.print(converted); Serial.println(" K");

//Rankine //T(°R) = (T(°C) + 273.15) × 9/5 converted = temp + 273.15; converted = (converted * 1.8); Serial.print("Rankin = "); Serial.print(converted); //Print degree symbol Serial.write(176); Serial.println("R");

Serial.print("Humidity ="); Serial.println(hum);

//2000mS delay between reads delay(2000); }

Step 3: Conclusion

The project is successfully completed with Arduino UNO and DHT22 module.

The converted temperature, and its serial port screen is given below.

Be the First to Share


    • Finish It Already Speed Challenge

      Finish It Already Speed Challenge
    • Arduino Contest 2020

      Arduino Contest 2020
    • First Time Author Contest

      First Time Author Contest