How to connect DHT22 to Raspberry Pi

DHT22 is a Temperature and Humidity Sensor. In this project we connect a DHT22 Sensor to a Raspberry Pi with Raspbian OS to measure the Temperature and Humidity. We use Python language and tkinter  Library to create Graphics and use Adafruit_DHT Library to read data from DHT22.

for downloading Adafruit_Python_DHT in terminal window issue the commands:

git clone https://github.com/adafruit/Adafruit_Python_DHT.git

cd Adafruit_Python_DHT

sudo python setup.py install

Code walk through:

Now that  Adafruit_DHT library is installed we can import it in our code:

import Adafruit_DHT as dht

  1. On Raspberry Pi Create a directory
  2. download DHT22_Bar and unzip them in that folder
  3. On Raspberry Pi under Menu Programming select Thonny Python IDE
  4. from menu file open file DHT22_Bar.py
  5. Connect DHT22 Device to Raspberry Pi
  6. run the Python file

Tags: DHT22_Bar DHT22 Sensor Raspberry Pi 3 barlib Adafruit_DHT  G1.PNG

Leave a Reply

Your email address will not be published. Required fields are marked *