Table of Contents

DHT22

The DHT22 is perhaps the best iteration of the DHT22 sensors giving maximal performance for the buck with a very low and negligible error.

Code Hints

The DHT22 library by dam74 (dvarrel) works best for this device:

#include <DHT22.h>
 
//DHT_PIN_ANALOG is the analog GPIO pin connected to the DHT22 analog output
DHT22 dht22(DHT_PIN_ANALOG);
 
float t = dht22.getTemperature();
float h = dht22.getHumidity();
 
if (dht22.getLastError() != dht22.OK) {
    Serial.println("Last error: " + dht22.getLastError());
    return;
}
 
if(isnan(t)) {
    Serial.println(t);
}
 
if(isnan(h)) {
    Serial.println(t);
}

Index