Arduino + DHT11 sensor (humidity and temperature)

Today we are reviewing the connection to the Arduino board humidity sensor and temperature DHT11 (Figure 1). (see also Arduino and DS18B20 temperature sensor)

Figure 1 – DHT11 sensor

Relative humidity

Resolution: 16Bit
Repeatability: ± 1% RH
Accuracy: At 25 ? ± 5% relative humidity
Interchangeability: fully interchangeable
Response Time: 1/e (63%) of 25 ? 6s 1 m/s air 6s
Hysteresis: < ± 0,3% RH Long-term stability: <± 0,5% RH/year Temperature Resolution: 16Bit Repeatability: ± 0,2 ? Range: На 25 ? ± 2 ? Response time: 1/е (63%) 10S Electrical characteristics Power: DC 3,5 ~ 5,5 V Supply Current: 0.3mA Standby measuring 60? Sampling period: more than 2 seconds

Connecting sensor to the Arduino board
DHT11 digital temperature and humidity sensor is a composite sensor which contains a calibrated digital output from the readings of temperature and humidity. The sensor includes a resistive humidity sensor NTC structures and components for temperature measurement.


To connect to the Arduino is necessary to use a resistor of 10 ohms between pins 1 and 2 of the sensor DHT11.


I used the sensor module DHT11 with already integrated SMD resistor.


For the operation of the sensor is needed DHT11 libraryDHT

#include "DHT.h"

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

// Uncomment whatever type you're using!
#define DHTTYPE DHT11 // DHT 11
//#define DHTTYPE DHT22 // DHT 22 (AM2302)
//#define DHTTYPE DHT21 // DHT 21 (AM2301)

// Connect pin 1 (on the left) of the sensor to +5V
// Connect pin 2 of the sensor to whatever your DHTPIN is
// Connect pin 4 (on the right) of the sensor to GROUND
// Connect a 10K resistor from pin 2 (data) to pin 1 (power) of the sensor


void setup() {
Serial.println("DHTxx test!");


void loop() {
// Reading temperature or humidity takes about 250 milliseconds!
// Sensor readings may also be up to 2 seconds 'old' (its a very slow sensor)
float h = dht.readHumidity();
float t = dht.readTemperature();

// check if returns are valid, if they are NaN (not a number) then something went wrong!
if (isnan(t) || isnan(h)) {
Serial.println("Failed to read from DHT");
} else {
Serial.print("Humidity: ");
Serial.print(" %\t");
Serial.print("Temperature: ");
Serial.println(" *C");


Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.