Looking for low-cost temperature and humidity sensors? Perfect timing! In this blog, we will be talking about DHT11and DHT22, the two most common temperature and humidity modules for Arduino and Raspberry Pi.
Despite being slower than other temperature sensors, they have advantages including low power consumption and excellent long-term stability. Furthermore, relatively high measurement accuracy can be obtained at a very low cost. The single-bus digital signal is output through the built-in ADC, which saves the I/O resources of the control board as well.
These DHT sensors are perfect for home projects like weather stations, environmental automatic control systems, testing/inspection of equipment, farm/garden monitoring systems, and many more!
DHT sensors are made up of two parts, a capacitive humidity sensor, and a thermistor with a basic chip that is responsible for analog to digital conversions.
DHT11 vs DHT22
Before we jump right into their differences, let’s look at an introduction about each temperature sensor first:
The DHT11 is a basic, ultra low-cost digital temperature and humidity sensor. It is able to detect temperature and also relative humidity which is the amount of water vapour in the air vs the saturation point of water vapour in the air.
DHT11 is the most common temperature and humidity module for Arduino and Raspberry Pi. Thus, widely favoured by hardware enthusiasts for its many advantages. Our DHT11 temperature humidity sensor is based on the new DHT11 module as well!
- Low power consumption and excellent long-term stability.
- Relatively high measurement accuracy can be obtained at a very low cost.
- Single-bus digital signal output through the built-in ADC, which saves the I/O resources of the control board.
- Humidity range of 5 to 95% RH with a ±5% and also a temperature range of -20 to 60℃ with a ±2%.
For comparison, here’s the difference between the new module and the old module:
As you can tell, the new module has a wider humidity range, temperature range and also a lower temperature resolution.
The DHT22 is also known as AM2302 or RHT03, it includes a capacitive humidity sensor and a high precision temperature sensor. It uses dedicated digital module acquisition technology and temperature and humidity sensing technology to ensure high reliability and excellent long-term stability.
The DHT22 also has a capacitive sensing element and a high precision temperature measuring element connected to a high-performance 8-bit microcontroller. Thus, it has the advantages of excellent quality, ultra-fast response, strong anti-interference ability, and high-cost performance
- Ultra-small size
- Extremely low power consumption, and with a signal transmission distance of more than 20 meters thus it’s able to withstand the most demanding applications.
- Humidity sensor of 0 to 99.9 %RH with ±2% accuracy while the temperature sensor ranges from -40 to 80℃ with ±0.5℃ accuracy.
Do note that we also sell the sensor module individually, it is also easy to connect with 3 leads (single bus interface). If you want to connect your sensor with a longer wire, you can easily just add a pull-up resistor.
How are they different?
- Temperature Range
- DHT11: -20 to 60℃
- DHT22: -40 to 80℃
- Temperature Accuracy
- DHT11: ±2%
- DHT22: ±0.5%
- Humidity Range
- DHT11: 5 to 95% RH
- DHT22: 0 to 100%RH
- Humidity Accuracy
- DHT11: ±5%
- DHT22: ±2%
- The DHT22 outshines the DHT11 in every aspect from temperature range, temperature accuracy, humidity range to humidity accuracy.
- The only downside of the DHT22 is, of course, the slightly higher price but you are paying for the better specs.
Therefore, if you want a sensor with a wider range and accuracy, go for the DHT22. If not, the DHT11 should work fine for your projects as well.
Overall, these DHT sensors are basic and slow temperature and humidity sensors that are suitable for beginners and hobbyists looking to do basic data logging. They both use a single digital pin and are a little slow where you can’t query them more than once every second.
Getting started with DHT11 / DHT22 and Arduino
Need help getting started with your DHT11 and DHT22? We’ve got you! Here’s a tutorial on how to get started together with the Arduino together with our DHT modules!
What you’ll need:
- Arduino UNO / Seeeduino V4.2
- Grove Base Shield (Optional, for easy connection)
- Grove – Temperature & Humidity Sensor (DHT11) / Grove – DHT22 Temperature & Humidity Sensor Pro (AM2302)
- Step 1: Connect the hardware
- Firstly, connect Grove – Temperature&Humidity Sensor to port D2 of Grove-Base Shield.
- Plug Grove – Base Shield into Seeeduino
- Connect Seeeduino to PC via a USB cable
- Your setup should look something like this:
If you do not have a Grove Base Shield, you can also directly connect Grove – Temperature and Humidity Sensor to your Arduino / Seeeduino as shown below:
|Seeeduino / Arduino||DHT11 Sensor|
- Step 2: Setup software
- Download the Seeed DHT library from Github.
- Refer to How to install library for Arduino.
- Restart the Arduino IDE. Open “ DHTtester” example via the path: File → Examples → Grove_Humidity_Temperature_Sensor-master → DHTtester. Through this demo, we can read the temperature and relative humidity information of the environment.
Both DHT11 and DHT22 sensors are sharing this library. No matter which product you are using, make sure that you have made the definition line of the sensor of your board into effect and commented out the definition lines of other specs. The default setting of the library is
DHT 22, so you need to change it into manually if you are using DHT11.
For example, if you are using the DHT 11, the definition part of the sensor spec should be:
#define DHTTYPE DHT11 // DHT 11 //#define DHTTYPE DHT22 // DHT 22 (AM2302) //#define DHTTYPE DHT21 // DHT 21 (AM2301)
- Step 3: Upload the Demo
- For the next step, you will upload the demo. If you are unsure on how to upload the code, you can refer to our how to upload code guide.
- Step 4: Review Results
- Open the Serial Monitor of Arduino IDE by click Tool-> Serial Monitor. Or tap the Ctrl+Shift+M key at the same time. if there is nothing wrong, you should get a temperature reading like this:
That is all on the comparison between DHT11 and DHT22 together with a short tutorial on how to get started with these DHT sensors and the Arduino. Both the DHT11 and DHT22 are great low-cost temperature and humidity sensors and you will not be disappointed with both! However, the great minds behind both sensors have recently released a new sensor! Find out more below!
Wonder how other temperature sensors like the DS18B20 or BME280 and many more compare to the DHT temperature sensor? Check out our other guides here!
Introducing the DHT20, a Successor of DHT11
Aosong Electronics has introduced us to a new temperature and humidity sensor module, the DHT20!
The DHT20 comes with a brand-new ASIC chip and several other new internals bringing along all-rounded performance upgrades! Here at Seeed, we will also be upgrading our sensors that use DHT11 to the new DHT20! You can find out more information about the DHT 20 at “Introducing DHT20 Temperature and Humidity Sensor and Comparing it with DHT11!”!