Interfacing DHT11 Using Arduino by Sujay
by alaspuresujay in Circuits > Arduino
423 Views, 0 Favorites, 0 Comments
Interfacing DHT11 Using Arduino by Sujay
In this Instructables you will learn how to set up the DHT11 Humidity and Temperature sensor on your Arduino UNO. And learn about how the Humidity sensor works, and how to check output readings from the Serial monitor
Description:
The DHT11 detects water vapor by measuring the electrical resistance between two electrodes. The humidity sensing component is a moisture holding substrate with electrodes applied to the surface. When water vapor is absorbed by the substrate, ions are released by the substrate which increases the conductivity between the electrodes. The change in resistance between the two electrodes is proportional to the relative humidity. Higher relative humidity decreases the resistance between the electrodes, while lower relative humidity increases the resistance between the electrodes.
Components Required
- Here is the list of components required to get started with the Instructable,
Hardware Components:
- Arduino UNO Buy From Flipkart
- DHT11 Humidity and Temperature sensor Buy From Flipkart
- Breadboard (Optional)
- Jumper Wires
- USB Programmable Cable
Software Components:
- Arduino IDE
Wiring the Circuit
Wiring the DHT11 to the Arduino UNO is really easy.
The wiring connections are made as follows :
VCC pin of the DHT11 goes into +3v of the Arduino.
DATA pin of the DHT11 goes into Analog Pin A0 of the UNO.
GND Pin of the DHT11 goes into Ground Pin (GND) of the UNO.
Programming the Arduino
Download the Zip file here
Extract the DHT Library and code.
#include "dht.h"
#define dht_apin D1 // Analog Pin sensor is connected to dht DHT;
The Above lines are initialization for dht library
Defining data pin of dht and creating instatnce as DHT
void setup(){
Serial.begin(9600); delay(500);//Delay to let system boot Serial.println("DHT11 Humidity & temperature Sensor\n\n"); delay(1000);//Wait before accessing Sensor }
Above lines are the setup code
Starts serial communication at 9600 baud rate print the name of project with delay of 1 sec
void loop(){ DHT.read11(dht_apin);
Serial.print("Current humidity = "); Serial.print(DHT.humidity); Serial.print("% "); Serial.print("temperature = "); Serial.print(DHT.temperature); Serial.println("C "); delay(5000);//Wait 5 seconds before accessing sensor again. }
It reads data from DHT11 repeatedly every 5 Sec
Output
Open Serial Monitor
set the baud rate to 9600 See the result on Serial Monitor....
First of all, I would like to thank you for reading this guide ! I hope it helps you. If You have any queries I am always happy to help you..... Drop a Comment. Your feedback is valuable for me.
Error
- Not showing output:
Check your connection and polarity of power supply
Check the baud rate. It should be 9600
- Not showing the correct values
Kindly check error while uploading. Try to upload the code again.
or try the code with another DHT.
If You have any other issue kindly let me know. I will definitely try my best to solve it.