Temperature and Humidity Sensor DHT11 Vs DHT22 Which One Is Better
Temperature and Humidity Sensor DHT11 Vs DHT22 Which One Is Better
Have you been searching for low-cost humidity and temperature sensors? Great
timing! Here, we will discuss the DHT11 and DHT22. These are the two well-known
humidity and temperature modules for Raspberry Pi and Arduino.
Though DHT11 and DHT22 are slower compared to some temperature sensors, both
boast of benefits that include great long-term stability and low consumption of power.
In addition, you can get relatively high accuracy in measurement at an affordable rate.
Both DHT sensors are great for any home project such as weather stations, inspection
and testing of equipment, garden or farm monitoring systems, environmental control
systems, and more.
DHT sensors are composed of two major parts. These include a thermistor having a
basic chip and a humidity sensor. Both are responsible for converting
from analog to digital.
Table of Contents
What is DHT11?
DHT11 vs DHT22
DHT11 can be referred to as a basic, low-cost humidity and temperature sensor. It has
the capability to detect relative humidity and temperature. The relative humidity here
refers to the quantity of air’s water vapor compared to the water vapor’s saturation
point in air.
Features
Comparing the old and new DHT11, we can see some differences. The old DHT11 is
called ADSONG, while the new is ASAIR.
The old DHT11 has a resistive sensor, while the new DHT11 has a capacitive
sensor
Old DHT11 has a humidity range falling between 20 and 95%, while the new
DHT11 has a humidity range that falls between 5 and 95%
The old DHT11 has a temperature range falling between 0 and 50℃, while the
new DHT11 has a temperature range that falls between 20 and 60℃.
The old DHT11 has a temperature resolution of 1℃, while the new DHT11
has a temperature resolution of 0.1℃.
From this comparison, you can clearly see that the new DHT11 has a wider range for
both humidity and temperature. Furthermore, its temperature resolution is also lower.
What is DHT22?
Note that the sensor module can be sold individually. Also, connection with 3 leads is
easy. If you wish to connect the sensor using a longer wire, all you need to do is
include a pull-up resistor.
Temperature range: With respect to the temperature range, for DHT11, it falls
within -20 – 60℃, while for DHT22, it falls within -40 – 80℃.
Humidity Range: the humidity range for DHT11 falls between 5 – 95% RH, while
that of DHT22 falls within 0 – 100%RH.
Cost: The cost of DHT11 is $5.90 compared to that of DHT22, which is $9.90.
In conclusion, in all aspects, the DHT22 beats the DHT11. This includes humidity
accuracy, humidity range temperature accuracy, and temperature range. DHT22 has
just one downside, which is its higher price compared to that of DHT11. However,
this is necessary, since you have to pay more to get the better deal.
Therefore, if you are searching for a sensor having a wider accuracy and range, then
you should choose the DHT22. However, if you decide to choose the DHT11, no
problem; it will also work well for your different projects.
Generally, both DHT sensors are regarded as slow and basic humidity and
temperature sensors, which are great for hobbyists and beginners seeking to do some
data logging. Both utilize one digital pin and function very slowly. You cannot query
both sensors more than once for each second.
Before we go into details on how DHT11 and DHT22 sensors interface and work with
Arduino, let’s first consider how the two sensors work.
Here, we will be considering how the DHT11 and DHT22 sensors work. They are
made up of a thermistor or temperature sensor, a component for humidity sensing, and
an integrated circuit on the sensor’s back side.
For the measurement of humidity both sensors make use of a sensing component
having two electrodes with a substrate for holding moisture between them. As
changes in humidity happen, the substrate’s conductivity changes, or changes happen
in the resistance found in between the electrodes. The IC measures and processes the
resistance change. By doing so, it prepares it for reading by the microcontroller.
Measuring the temperature, on the other hand, both sensors utilize a thermistor or a
NTC temperature sensor. A thermistor can b e referred to as a resistor that changes the
resistance value with temperature change. The manufacturing of these sensors came to
be by sintering semi-conductive materials like polymers and ceramics, so as to
offer larger resistance changes with just little temperature changes.
NTC refers to the “Negative Temperature Coefficient.” This means that there is a
decrease in resistance with every temperature increase.
Circuit Schematics
Sensors DHT11 and DHT22 feature four pins – data pin, VCC, an unconnected pin,
and GND, with all four having no usage. There’s a need for a pull up resistor from
5-10 ohms to ensure the data line is kept high to ensure that there is a communication
between the Arduino board and the sensor. Some of these sensor’s versions
feature breakout boards having an in-built pull-up resistor having only 3 pins.
Both sensors feature their personal single wire protocol. These are used in data
transfer. This protocol also requires accurate timing. Also, you will find the diagrams
required for getting this data from both sensors on their datasheets. However, there’s
no need to be concerned about the timing diagrams. This is because the DHT
library will be useful here as it handles everything.
It is fairly easy to connect both sensors – DHT11 and DHT22. As mentioned earlier,
they feature four pins.
VCC pin: This pin provides the sensor’s power. Although the voltage supply falls
between 3.3V – 5.5V, it is recommended to work with the 5V supply.
As regards the power supply of 5V, the sensor can be kept for about 20 meters. In
contrast, for the supply voltage of 3V, the length of the cable cannot be more than a
meter. If this happens, the line voltage will drop, thereby causing measurement errors.
Data Pin: The data pin is the medium through which the microcontroller and the
sensor communicates
By now, you should have a good understanding of the way DHT sensors function.
Now, we can start connecting it to the Arduino.
Also, you need to place a resistor (pull-up) of 10KΩ between the data line and the
VCC to ensure it is kept HIGH. This makes proper communication between the MCU
and the sensor. However, if you possess the sensor’s breakout board, then there’s no
need to include an external pull-up. Also, it features a pull-up in-built resistor.
After achieving this, you can now go ahead with uploading some code and get it to
work.
Both sensors, DHT11 and DHT22 feature their personal single wire protocol, which
are utilized for data transfer. There’s a need for precise timing for this protocol.
Fortunately, you don’t have to be bothered about this. This is because everything will
be taken care of by the DHT library.
First download the library here, and then install it. To do the installation, open your
Arduino IDE – Sketch – Include Library – Add .ZIP Library, then lastly, select the
file that you have just downloaded. However, if you need more information on how to
install the library, you can use this tutorial.
After installing the library, copy the sketch into your Arduino IDE. This test sketch
helps in printing the values of the relative humidity and temperature on your serial
monitor. Let’s explain this sketch in detail.
After uploading the sketch, you will see a window that reveals the output delivered by
Arduino.
The sketch begins by the inclusion of the DHT library. Then, we have to define the
pin number of the Arduino to which the data pin of our sensor is connected; we then
use it in creating a DHT object. By doing so, we will be able to access any special
function that relates to the library. This is shown below:
#include <dht.h>
#define dataPin 8 // Defines pin number to which the sensor is connected
dht DHT; // Creats a DHT object
For the ‘setup’ function, there’s a need to initiate serial communication, because this
serial monitor will be useful in printing the results. This is shown below:
void setup() {
Serial.begin(9600);
For the ‘loop’, we will be utilizing the function read22(). This reads the DHT22 data.
It takes the data pin number of the sensor as one parameter. You can make use of the
read11() function if you’re tinkering using DHT11. This can be achieved by
uncommenting the second line like this:
As soon as you have the values for the temperature and humidity calculated, you can
easily access them this way:
Now, the DHT object returns the value of the temperature in degrees Celsius. You can
convert it to degrees Fahrenheit using this:
Conclusion
Related Posts:
https://www.raypcb.com/dht11-vs-dht22/