Learn the interfacing of DHT11 Temperature and Humidity Sensor in Raspberry Pi. The DHT11 sensor is capable of measuring Temperature as well as humidity. So, let’s start.
First, let’s start with the basics of the DHT11 Temperature and Humidity Sensor.
Humidity: 20-95%, ±5% accuracy
Temperature: 0 to 50°C, ±2°C accuracy
Step 1: Required Components
DHT11 Sensor x 1
Breadboard x 1
Raspberry Pi x 1
Step 2: Circuit Time
Make the circuit as per given diagram. DHT11 has basically 3 pins, VCC, GND, and Data. VCC pin is used to provide power supply to the module and Data pin send data to Raspberry Pi. Connect VCC pin of DHT11 to +5v of Raspberry Pi. Then, Connect Data pin of DHT11 to GPIO 7 of Raspberry Pi. Now, Connect GND pin to GND of Raspberry Pi.
Step 3: Code Time
This is the code for Pushbutton with LED in Raspberry PI. First imported sys and Adafruit_DHT library (For using DHT11 Temperature and Humidity Sensor in Raspberry Pi, install Adafruit DHT11 Python library) In while loop, read the data from Sensor and stored it into variables. After that, the values of variables are printed on the screen.
Step 4: Run code to Raspberry Pi
Set the components as per the Circuit Diagram and run the above-given code in Raspberry Pi. Data pin of DHT11 provides reading to Raspberry Pi and Raspberry Pi will display the readings. Below is screenshot of readings provided by DHT11.
For running python code in Raspberry PI, visit: raspberrypi.org/documentation/usage/python/
For basic hardware information about Raspberry PI 3, Click here.