How to Interface DHT11 and DHT22 Sensors With Arduino Uno
by Rachana Jain in Circuits > Arduino
32 Views, 0 Favorites, 0 Comments
How to Interface DHT11 and DHT22 Sensors With Arduino Uno
Want to create a smart home climate control system or measure real-time temperature and humidity data in a weather station? DHT11 and DHT22 Temperature and Humidity Sensors are excellent choices. Their ease of use, affordability, and relatively accurate readings make them ideal for DIY electronics projects requiring climate data.
This tutorial will walk you through interfacing these sensors with an Arduino Uno to measure humidity and temperature. With a simple setup and Arduino code, you can quickly begin capturing real-time environmental data.
Supplies
- Arduino Uno
- DHT11
- DHT22 sensor
- Breadboard
- Jumper wires
- 10kΩ pull-up resistor
Overview of DHT11 and DHT22 Sensors
The DHT11 and DHT22 sensors are part of the DHTxx series and are widely used for temperature and humidity measurement. They are similar in appearance and pin configuration but differ in terms of specifications, accuracy, and applications.
DHT11 Sensor
The DHT11 is cost-effective and suitable for basic applications. It has the following features:
- Temperature Range: 0 to 50°C with an accuracy of ±2°C
- Humidity Range: 20-90% RH with an accuracy of ±5%
- Operating Voltage: 3.3 to 5.5V DC
- Sampling Rate: 2 seconds
- Resolution: 1% RH for humidity, 1°C for temperature
DHT22 Sensor
The DHT22 offers higher precision and a broader range of measurements:
- Temperature Range: -40 to 80°C with an accuracy of <±0.5°C
- Humidity Range: 0-100% RH with an accuracy of ±2 to ±5%
- Operating Voltage: 3.3 to 6V DC
- Sampling Rate: Greater than 2 seconds
- Resolution: 0.1% RH for humidity, 0.1°C for temperature
Both sensors are interchangeable, requiring minimal modifications to the code for swapping.
Working Principle of DHT11 and DHT22
The sensors measure temperature and humidity using:
- Humidity Sensing Component: A substrate holds moisture between two electrodes. The conductivity changes with humidity levels, altering the resistance sensed by the sensor's internal MCU. The processed data is sent as relative humidity.
- NTC Thermistor: Measures temperature by changing resistance based on ambient temperature. A negative temperature coefficient (NTC) means resistance decreases as temperature increases.
- Integrated Circuit (IC): Processes the signals from the sensing components, converting analog readings into digital data for the Arduino.
How DHT Sensors Communicate with Arduino
DHT sensors use the Aosong One-Wire Protocol to communicate with the Arduino. This protocol requires a single data pin for communication, simplifying wiring while maintaining efficient data transfer.
DHT11 and DHT22 Pinout
- Pin 1: VCC (Power Supply, 3.3-5.5V for DHT11, 3.3-6V for DHT22)
- Pin 2: This pin is used for communication between the sensor and the microcontroller.
- Pin 3: NC (Not connected)
- Pin 4: GND (Ground)
Wiring Diagram for Interfacing DHT11 and DHT22 Sensor to an Arduino
- Connect VCC of the sensor to the Arduino's 5V pin.
- Connect GND of the sensor to the Arduino's GND pin.
- Connect Data pin to a digital pin D2 on the Arduino with a 10kΩ pull-up resistor between the data pin and VCC.
Arduino Example Code
In the below code, we will be interfacing a DHT11/DHT22 temperature and humidity sensor with Arduino UNO.
Conclusion
By following this guide, you can seamlessly interface DHT11 or DHT22 sensors with an Arduino Uno to measure temperature and humidity. The DHT11 offers affordability for basic projects, while the DHT22 provides higher precision for more critical applications. Choose the sensor that best fits your project requirements and start building amazing projects!
To learn more checkout this guide: Interfacing DHT11 and DHT22 Sensors with Arduino Uno