Menu Close

DHT series Temperature & Humidity sensor on Arduino

Robo India presents tutorial on how to read temperature and humidity data through DHT series sensor Arduino platform.

Detailed Tutorial

1. Introduction:

This tutorial explains how to read temperature and humidity data through DHT series sensor on Arduino platform.

DHT series sensors have their other names too –

  • DHT11 = RHT01
  • DHT21 = RHT02= AM2301 = HM2301
  • DHT22 = RHT03= AM2302
  • DHT33 = RHT04 = AM2303
  • DHT44 = RHT05

DHT library included here in this tutorial supports following sensor of DHT series

  1. DHT11
  2. DHT22
  3. AM2302
  4. RHT03

This library automatically detects if any one of the above mentioned sensor is connected to Arduino.

2. Understanding DHT11 sensor
DHT11 sensor gives humidity and temperature data. It has got following pin interface.

3. Circuit

Make following connections of DHT sensor to Arduino in the following manner.

4. DHT Library

Download DHT library from here. Install the same.

5. Programming

You may download following code from here.

// Robo India Tutorial for DHT series sensors. 
// This library supports DHT11, DHT22, AM2302 and RHT03 sensors
// Auto detects sensor model/type

#include "DHT.h"

DHT dht;

void setup()
{
  Serial.begin(9600);
  Serial.println();
  Serial.println("Status\tHumidity (%)\tTemperature (C)\t(F)");

  dht.setup(2); // data pin 2
}

void loop()
{
  delay(dht.getMinimumSamplingPeriod());

  float humidity = dht.getHumidity();
  float temperature = dht.getTemperature();

  Serial.print(dht.getStatusString());
  Serial.print("\t");
  Serial.print(humidity, 1);
  Serial.print("\t\t");
  Serial.print(temperature, 1);
  Serial.print("\t\t");
  Serial.println(dht.toFahrenheit(temperature), 1);
}



6. Output

Run the following code and you will get the following output.

This is how to use DHT series sensors on Arduino.

If you have any query please write us at support@roboindia.com

Thanks and Regards
Content Development Team 
Robo India
http://roboindia.com

Leave a Reply