How to set up the DHT11 Temperature and Humidity Sensor with Arduino.

How to set up the DHT11 Temperature and Humidity Sensor with Arduino.

DHT11 sensor description.

The DHT11 sensor is quite cheap but still provides great performance  with temperature range from 0 to 50 degrees Celsius with +-2 degrees accuracy and  humidity range from 20 to 80% with 5% accuracy.
There are two different versions of the DHT11 sensor you might come across. One type has four pins, and the other type has three pins and is mounted to a small PCB. The PCB mounted version is nice because it includes a surface mounted 10K Ohm pull up resistor for the signal line. Here are the pin outs for both versions:
The DHT11 sensor consist of a humidity sensing component, a NTC temperature sensor (or thermistor) and an IC on the back side of the sensor. A thermistor is actually a variable resistor that changes its resistance with change of the temperature.
dht11 arduino sensor

DHT11 sensor with Arduino and LCD.

The setup below shows a DHT11 sensor connected with Arduino. The sensor used in this case is a three pin sensor.
dht11 arduino schematic

Connecting DHT11 sensor with for pins

dht11_4pin arduino schematic

The DHT11 sensor with four pins has VCC, GND, data pin and a not connected pin which has no usage. A pull-up resistor from 5K to 10K Ohms is required to keep the data line high and in order to enable the communication between the sensor and the Arduino Board. 

Code

Before you can use the DHT11 on the Arduino, you’ll need to install the DHTLib library. It has all the functions needed to get the humidity and temperature readings from the sensor. This Library can be downloaded from here. We also use the LiquidCrystal.h library to control the working of the LCD screen.
#include <dht.h>
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

dht DHT;
#define DHT11_PIN 8

void setup(){
  lcd.begin(16, 2);
}

void loop()
{
  int chk = DHT.read11(DHT11_PIN);
  lcd.setCursor(0,0); 
  lcd.print("Temp: ");
  lcd.print(DHT.temperature);
  lcd.print((char)223);
  lcd.print("C");
  lcd.setCursor(0,1);
  lcd.print("Humidity: ");
  lcd.print(DHT.humidity);
  lcd.print("%");
  delay(2000); // Delays 2 secods, as the DHT11 sampling rate is 0.5Hz
}

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top