Skip to content

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.

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.

Furthermore, DHT11 is widely regarded as the humidity and temperature module for Raspberry Pi and Arduino. Therefore, due to its many benefits, hardware enthusiasts favor the DHT11. Also the DHT11 humidity temperature sensor also works with respect to the new DHT11 module.


  • Consumes low power and has a great long-term stability
  • You can obtain a relatively high accuracy in measurements at a low and affordable cost
  • Range of humidity falls between 5 – 95% RH, and having a ±5%. Also, the range of temperature falls within -20 – 60℃ and having a ±2%.

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?

DHT22 is also referred to as RHT03 or AM2302. The DHT22 features a temperature sensor with high precision, as well as a humidity sensor. It makes use of a digital module acquisition technology, as well as humidity and temperature sensing technology. This is just to ensure that it is highly reliable and has great long-term stability.

Furthermore, DHT22 features a sensing element, as well as a measuring element of temperature of high precision, which is connected to an 8-bit microcontroller of high performance. Therefore, it has great quality benefits, very quick response, high-cost performance, and high anti-interference ability.

Features of the DHT22

  • Its size is ultra small
  • Power consumption is extremely low, coupled with a distance of signal transmission of over 20 meters. Therefore, it can withstand applications that are most demanding.
  • Range of the humidity sensor falls between 0 – 99.9% RH, and has an accuracy of ±2%. Also, the range of temperature falls within -40 – 80℃ and has an accuracy of ±0.5℃.

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.

What are the Differences: DHT11 vs DHT22


Temperature range: With respect to the temperature range, for DHT11, it falls within -20 – 60℃, while for DHT22, it falls within -40 – 80℃.

Temperature accuracy: DHT11 has a temperature accuracy of ±2%, while that of DHT22 is ±0.5℃

Humidity Range: the humidity range for DHT11 falls between 5 – 95% RH, while that of DHT22 falls within 0 – 100%RH.

Humidity Accuracy: DHT11 has a humidity accuracy of ±5%, in contrast to DHT22, which is ±2%.

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.

How do DHT11 and DHT22 sensors Interface and Work with Arduino?

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.

Working Principle of the DHT11 and DHT22

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.

Pinout of the DHT11 and the DHT22

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

NC: This means not connected

GND: This pin has to be connected to Arduino’s ground.

Connecting the DHT11 and DHT22 to the Arduino UNO

By now, you should have a good understanding of the way DHT sensors function. Now, we can start connecting it to the Arduino.

Fortunately, it is not important to connect both sensors – DHT11 and DHT22 – to Arduino. Their pitch pins of 0.1 inches are fairly long; therefore plugging them into breadboards will come in. Using the 5V, power up the sensor and then connect them ground to ground. Lastly, connect the digital pin #2 to the data pin.

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.

Printing of Values on the Serial Monitor

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.

Explanation of the Code

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:

  • //Uncomment whatever type you’re using!
  • int readData = DHT.read22(dataPin); // DHT22/AM2302
  • //int readData = DHT.read11(dataPin); // DHT11

As soon as you have the values for the temperature and humidity calculated, you can easily access them this way:

  • float t = DHT.temperature; // Gets the values of the temperature
  • float h = DHT.humidity; // Gets the values of the humidity

Now, the DHT object returns the value of the temperature in degrees Celsius. You can convert it to degrees Fahrenheit using this:

  • //print the temperature in Fahrenheit
  • Serial.print((t * 9.0) / 5.0 + 32.0);


Concerning precision, that of DHT11 is lesser than that of DHT22. It functions in a much smaller range of humidity and temperature. Asides from this, it is a bit slower, price point is lower, and its form factor is smaller too. If you desire some accuracy for your project, and you are okay with its higher price, then you should choose the DHT22. However, if this is not the case the DHT11 works fine. You can decide to work with any of the two.




                Get Fast Quote Now