The DHT11 humidity and temperature sensing element makes it rattling easy to add humidity and temperature data to your DIY electronics projects. It's down pat for remote control weather condition stations, home environmental control systems, and farm or garden monitoring systems.
Therein teacher, I'll first go into a little background about humidity, and then I'll excuse how the DHT11 measures humidness. Afterwards that, I'll show you how to connect the DHT11 to an Arduino and give you some example encipher so you privy use the DHT11 in your own projects.
BONUS: I made a ready start guide for this tutorial that you can download and recover to later if you can't set this sprouted exact straight off. Information technology covers all of the steps, diagrams, and code you need to get started.
Here are the ranges and accuracy of the DHT11:
- Humidity Cast: 20-90% Releasing factor
- Humidity Truth: ±5% RH
- Temperature Range: 0-50 °C
- Temperature Accuracy: ±2% °C
- Operative Voltage: 3V to 5.5V
The DHT11 Datasheet:
DHT11 Datasheet
What is Relation Humidness?
The DHT11 measures relative humidity. Proportionate humidity is the amount of water vapor in air vs. the saturation distributor point of urine vapor in air. At the intensity point, water vapour starts to condense and accumulate on surfaces forming dew.
The vividness taper off changes with air temperature. Cold air can hold less piddle vapor before it becomes saturated, and wanted air can hold more water vapour before information technology becomes saturated.
The recipe to calculate relative humidity is:
Relative humidity is overt as a part. At 100% RH, condensation occurs, and at 0% RH, the air is completely dry.
How the DHT11 Measures Humidity and Temperature
The DHT11 detects water vapor by measuring the electrical resistance between cardinal electrodes. The humidity sensing component part 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 congeneric humidity. High relative humidity decreases the resistance between the electrodes, while lower relation humidity increases the resistance between the electrodes.
The DHT11 measures temperature with a surface mounted NTC temperature sensor (thermistor) built into the unit. To determine more well-nig how thermistors work and how to use them happening the Arduino, check prohibited our Arduino Thermistor Temperature Sensor Instructor.
With the impressionable housing removed, you can insure the electrodes applied to the substrate:
An IC mounted on the back of the social unit converts the resistance measurement to comparative humidity. It also stores the standardisation coefficients, and controls the information sign transmitting 'tween the DHT11 and the Arduino:
The DHT11 uses just ace signal wire to transmit information to the Arduino. Power comes from divide 5V and ground wires. A 10K Ohm chin-up resistor is needed between the signal line and 5V line to make sure the signal level stays high schoo by default (see the datasheet for more information).
At that place are two different versions of the DHT11 you power come crosswise. Unmatched type has four pins, and the past typecast has three pins and is adorned to a small PCB. The PCB adorned version is skillful because it includes a surface mounted 10K Georg Simon Ohm pull dormie resistance for the signal line. Here are the pin outs for both versions:
How to Launch the DHT11 along an Arduino
Wiring the DHT11 to the Arduino is really soft, only the connections are different conditional which type you have.
Conjunctive a Three Pin DHT11:
Conjunctive a Little Jo Pin DHT11:
- R1: 10K Ohm extract resistance
Display Humidness and Temperature on the Serial Varan
Before you can use the DHT11 connected the Arduino, you'll pauperism to install the DHTLib library. Information technology has all the functions needed to get the humidity and temperature readings from the sensing element. Information technology's easy to instal, just download the DHTLib.postal code file down the stairs and open up the Arduino IDE. Then go to Sketch>Include Program library>Add .ZIP Library and choose the DHTLib.zilch filing cabinet.
DHTLib
After it's installed, upload this example program to the Arduino and open the serial monitor:
#let in <dht.h> dht DHT; #define DHT11_PIN 7 void setup(){ Serial publication.begin(9600); } void loop(){ int chk = DHT.read11(DHT11_PIN); Serial.mark("Temperature = "); Asynchronous.println(DHT.temperature); Ordering.print("Humidness = "); Asynchronous.println(DHT.humidness); detain(1000); } You should see the humidity and temperature readings displayed at one indorse intervals.
If you don't want to use pin 7 for the data signalise, you prat interchange the fall number in line 5 where it says #define DHT11_PIN 7 .
Display Humidity and Temperature on an LCD
A nice way to display the humidity and temperature readings is on a 16X2 LCD. To do this, first follow our tutorial on How to Order an LCD Display on an Arduino, then upload this code to the Arduino:
#include <dht.h> #include <LiquidCrystal.h> LiquidCrystal liquid crystal display(12, 11, 5, 4, 3, 2); dht DHT; #delimit DHT11_PIN 7 void apparatus(){ lcd.begin(16, 2); } void curl(){ int chk = DHT.read11(DHT11_PIN); lcd.setCursor(0,0); LCD.print("Temp: "); lcd.print(DHT.temperature); LCD.photographic print((blacken)223); lcd.print("C"); lcd.setCursor(0,1); lcd.print("Humidness: "); lcd.print(DHT.humidity); lcd.print("%"); delay(1000); } Using the Information in Unusual Programs
What if you don't want to output the actual humidity and temperature readings, but need them to calculate or control condition other things? The code below is the bare negligible needed to initialize the sensor. You can add this to existing programs and use DHT.humidness and DHT.temperature as variables in any function.
#include <dht.h> dht DHT; #delimit DHT11_PIN 7 void setup(){ } void loop(){ int chk = DHT.read11(DHT11_PIN); delay(1000); } To figure an case of using the DHT11 sensing element outputs as variables in other functions, check out our clause How to Put up an Ultrasonic Orbit Finder on an Arduino, where we use of goods and services the DHT.humidness and DHT.temperature variables in a recipe that improves the accuracy of an ultrasonic range finder.
You can sentry how to set up the DHT11 and escort how it works in this video:
If you accept whatever questions about how to set off up the DHT11 humidity and temperature sensor happening your Arduino, clean leave a comment at a lower place and I testament try to answer it… And if you like our tutorials, delight subscribe! Also, feel free to portion this if you know anyone other that might find it helpful!
Humidity Sensor Wiring Old Two Wirw Fan Swithc
Source: https://www.circuitbasics.com/how-to-set-up-the-dht11-humidity-sensor-on-an-arduino/
Post a Comment