Looking for low-cost temperature and humidity sensors?
DHT11 and DHT22 are the most common temperature and humidity modules for Arduino and Raspberry Pi. DHT sensors will be perfect for you. Despite being slower than other temperature sensors, they have advantages including low power consumption and excellent long-term stability. 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.
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
We will start off with a short 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 vapor in the air vs the saturation point of water vapor in the air.
- DHT11 is the most common temperature and humidity module for Arduino and Raspberry Pi. It is widely favored by hardware enthusiasts for its many advantages.
- E.g. Low power consumption and excellent long-term stability. Relatively high measurement accuracy can be obtained at a very low cost.
- For our DHT11 temperature humidity sensor, it is based on the new DHT11 module.
- It features a single-bus digital signal output through the built-in ADC, which saves the I/O resources of the control board.
- It features a 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 is the comparison 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 includes a capacitive humidity sensor and a high precision temperature sensor. DHT22 is also known as AM2302 or RHT03.
- It uses dedicated digital module acquisition technology and temperature and humidity sensing technology to ensure high reliability and excellent long-term stability.
- The sensor consists of a capacitive sensing element and a high precision temperature measuring element connected to a high-performance 8-bit microcontroller.
- Therefore, the product has the advantages of excellent quality, ultra-fast response, strong anti-interference ability, and high-cost performance
- The DHT22 sensor is ultra-small size, extremely low power consumption, and with a signal transmission distance of more than 20 meters makes it the best choice for any application with even the most demanding applications.
- For this sensor, 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.
- The DHT22 features a range of humidity sensor of 0 to 99.9 %RH with ±2% accuracy while the temperature sensor ranges from -40 to 80℃ with ±0.5℃ accuracy.
What are their differences?
- 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%
As you can tell, 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.
So 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.
Need help getting started with your DHT11 and DHT22? We got you! Here are tutorials on how to get started together with the Arduino together with our DHT modules!
Getting started with DHT11 / DHT22 and Arduino
What do you 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 by step tutorial
- 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 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
DHT 11 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.
Wonder how other temperature sensors like the DS18B20 or BME280 and many more compares to the DHT temperature sensor? Check out our other guide here!