Categories

DHT11 and DHT22 comparison

In this example I wanted to compare the readings of a DHT11 and a DHt22 (AM2032) temperature sensor. The sensors were positioned side by side with the same length of wire connecting them to my Arduino. Basically i was keeping the conditions as similar as possible.

This also shows how to connect 2 of these types of sensors.
The DHT11 costs about $1 using the links at the bottom, the DHT22 costs $5. So as you can see there is also a price difference that you may consider.

 

Schematic

Here is a simple schematic showing both devices connected to your Arduino

dhts breadboard

dhts breadboard

Code

This uses the adafruit DHT library

#include "DHT.h"
 
//DHT11
#define DHTPIN11 6     // what pin we're connected to
#define DHTTYPE11 DHT11   // DHT 11
DHT dht11(DHTPIN11, DHTTYPE11);
 
//DHT22
#define DHTPIN22 7     // what pin we're connected to
#define DHTTYPE22 DHT22   // DHT 22
DHT dht22(DHTPIN22, DHTTYPE22);
 
void setup() 
{
  Serial.begin(9600); 
  dht11.begin();
  dht22.begin();
}
 
void loop() 
{
  // Wait a few seconds between measurements.
  delay(2000);
 
  // Read DHT11 temperature as Celsius
  float tempDHT11 = dht11.readTemperature();
  // Check if readings have failed
  if (isnan(tempDHT11)) 
  {
    Serial.println("Failed to read from DHT 11 sensor!");
    return;
  }    
 
  Serial.print("DHT11 Temperature: "); 
  Serial.print(tempDHT11);
  Serial.println(" *C ");
 
  // Read DHT22 temperature as Celsius
  float tempDHT22 = dht22.readTemperature();
  // Check if readings have failed
  if (isnan(tempDHT22)) 
  {
    Serial.println("Failed to read from DHT 22 sensor!");
    return;
  }    
 
  Serial.print("DHT22 Temperature: "); 
  Serial.print(tempDHT22);
  Serial.println(" *C ");
 
}

 

Output

This was the output from the serial monitor, as you can see a slight difference in the readings

DHT11 Temperature: 26.00 *C
DHT22 Temperature: 25.40 *C
DHT11 Temperature: 26.00 *C
DHT22 Temperature: 25.40 *C
DHT11 Temperature: 26.00 *C
DHT22 Temperature: 25.40 *C
DHT11 Temperature: 26.00 *C
DHT22 Temperature: 25.40 *C
DHT11 Temperature: 26.00 *C
DHT22 Temperature: 25.40 *C

 

Links
1x DHT11 DHT-11 Digital Temperature and Humidity Temperature sensor with Cable for Arduino

DHT22 Digital Humidity AM2302 and Temperature Sensor Module For Arduino

Share

Comments are closed.