DHT11 Interfacing: Raspberry Pi

 1. Introduction

The DHT11 sensor is used to measure temperature and humidity. It provides digital output, making it easy to interface with Raspberry Pi. This sensor is widely used in weather monitoring and smart home applications.


2. Components

  • Raspberry Pi
  • DHT11 Sensor Module
  • 10kΩ Resistor (if required)
  • Breadboard
  • Jumper Wires

3. Circuit and connections

Raspbery Pi
Raspberry Pi Pinout Diagram

Pinout Diagram DHT11
Pinout Diagram DHT11 Sensor Module

Connections:

  • VCC → 3.3V (Pin 1)
  • GND → GND (Pin 6)
  • DATA → GPIO17 (Pin 11)

(If using bare sensor, connect 10kΩ resistor between VCC and DATA)


4. Detailed Step By Step Circuit working

  1. DHT11 senses temperature and humidity
  2. It converts analog signals into digital data
  3. Data is sent through DATA pin
  4. Raspberry Pi reads this data
  5. Values are displayed on terminal

5. Libraries to be included

import Adafruit_DHT

6. Code

import Adafruit_DHT
import time

sensor = Adafruit_DHT.DHT11
pin = 17

while True:
humidity, temperature = Adafruit_DHT.read(sensor, pin)

if humidity is not None and temperature is not None:
print("Temp = {0:0.1f}°C Humidity = {1:0.1f}%".format(temperature, humidity))
else:
print("Sensor failure. Try again.")

time.sleep(2)

7. Detailed Step By Step Code working

  1. Import Adafruit_DHT library
  2. Define sensor type as DHT11
  3. Assign DATA pin to GPIO17
  4. Use read() function to get values
  5. Store humidity and temperature
  6. Check if values are valid
  7. Print values on screen
  8. Add delay for stable reading

8. Tips

  • Use proper library installation (pip install Adafruit_DHT)
  • Avoid touching sensor while reading
  • Place sensor in open environment
  • Wait few seconds between readings

9. Uses

  • Weather monitoring systems
  • Smart home automation
  • Greenhouse monitoring
  • Temperature logging systems

10. Conclusion

The DHT11 sensor is a simple and effective way to measure temperature and humidity. It is ideal for beginners working with Raspberry Pi and IoT projects.

തുടക്കക്കാർക്കായുള്ള ഇലക്ട്രോണിക്സ് ലളിതമായി പഠിക്കാം.

Empowering students in Kerala with hands-on technical skills.