Interfacing DHT11 Temperature and Humidity Sensor in Raspberry Pi

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.
Power: 3-5V
Current: 2.5mA
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
Jumper Wires

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.

Circuit of DHT11 Temperature and Humidity Sensor in 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.Screenshot of DHT11 Temperature and Humidity Sensor in Raspberry Pi

For running python code in Raspberry PI, visit: raspberrypi.org/documentation/usage/python/

For basic hardware information about Raspberry PI 3, Click here.

Leave a Reply