Exp 2 (I)
Exp 2 (I)
Aim: To interface DHT11 sensor with Arduino and write a program to print
temperature and humidity readings.
Component Required:
Sl No Components Quantity
1 ARDUINO UNO BOARD 1
2 DHT11 Temperature sensor 1
3 USB cable for ARDUINO Board 1
4 Connecting wires --
Circuit Connection:
Theory:
The DHT11 sensor is a low-cost digital temperature and humidity
sensor. It operates at a voltage of 3.3V to 5V and can measure
temperatures ranging from 0°C to 50°C with an accuracy of ±2°C.
Additionally, it can measure relative humidity ranging from 20%
to 90% with an accuracy of ±5% .
The humidity sensing capacitor has two electrodes with a moisture holding substrate as a
dielectric between them. Change in the capacitance value occurs with the change in humidity
levels. The IC measure, process this changed resistance values and change them into digital
form.For measuring temperature this sensor uses a Negative Temperature coefficient
thermistor, which causes a decrease in its resistance value with increase in temperature.
DHT11 Specifications
Operating Voltage: 3.5V to 5.5V
Operating current: 0.3mA (measuring) 60uA (standby)
Output: Serial data
Temperature Range: 0°C to 50°C
Humidity Range: 20% to 90%
Resolution: Temperature and Humidity both are 16-bit
Accuracy: ±1°C and ±1%
Libraries are a collection of code that makes it easy for you to connect to a sensor, display,
module, etc. For example, the LiquidCrystal library makes it easy to talk to character LCD
displays.
There are thousands of libraries available for download directly through the Arduino IDE,
and you can find all of them listed at the Arduino Library Reference.
Steps to Add DHT11 Sensor Library
1) Open your Arduino IDE and go to Sketch > Include Library > Manage Libraries.
The Library Manager should open.
2) Search DHT then find the DHT Sensor library by Adafruit
3) Click install button to install library
4) If ask click on install all button to install library dependencies
Arduino Code to interface DHT 11 sensor to read Temperature &
Humidity:
#include <DHT.h>
#define DHTPIN 2 //DHT11 out pin is connected to pin2 of arduino
#define DHTTYPE DHT11
DHT dht(DHTPIN, DHTTYPE);
float humidity;
float temp;
void setup() {
Serial.begin(9600);
dht.begin();
}
void loop() {
humidity= dht.readHumidity();
Serial.print("Humidity = ");
Serial.print(humidity, 2);
Serial.println (" %");
temp=dht.readTemperature();
Serial.print("Temperature = ");
Serial.println(temp,2);
delay(500);
}
Output:
Result: Temperature and Humidity values are read and displayed on to serial monitor by
interfacing DHT11 sensor with Arduino.