Introduction: Raspberry Pi Tutorial: How to Use the DHT-22
The DHT-22 (also named as AM2302) is a digital-output relative humidity and temperature sensor. It uses a capacitive humidity sensor and a thermistor to measure the surrounding air, and spits out a digital signal on the data pin. In this tutorial you will learn how to use the DHT-22 sensor with Raspberry Pi.
Tutorial updates and more Raspberry Pi tutorials can be found here:
Let's get started!
Step 1: About the DHT-22 Sensor
The DHT22 is a basic, low-cost digital temperature and humidity sensor. It uses a capacitive humidity sensor and a thermistor to measure the surrounding air, and spits out a digital signal on the data pin (no analog input pins needed). Connections are simple, the first pin on the left to 3.3V power, the second pin to your data input pin and the right most pin to ground.
- Power: 3-5V
- Max Current: 2.5mA
- Humidity: 0-100%, 2-5% accuracy
- Temperature: -40 to 80°C, ±0.5°C accuracy
Step 2: What You Will Need - Hardware
Step 3: The Circuit
The connections are pretty easy, see the image above with breadboard circuit schematic.
Step 4: Install Adafruit DHT Library
Before python code you need to download and install the DHT library in your Raspberry Pi. Open the terminal window and type:
Now you will have to reboot your Pi system to get the Adafruit driver.
Step 5: Python Code
Download the code from here and open it with Thonny Python IDE or run it from terminal.
Step 6: Well Done
You have successfully completed one more Raspberry Pi "How to" tutorial and you learned how to use the DHT-22 sensor.
I hope you liked this, let me know in the comments.
Video in Greek language
1 Person Made This Project!
- cvodu made it!