Temperature and humidity monitoring with a Raspberry Pi Zero W — this was my first "real" IoT project and it taught me so much about Linux, Python, and hardware interfacing.

Hardware Required

  • Raspberry Pi Zero W
  • DHT11 Temperature & Humidity Sensor
  • 10kΩ pull-up resistor
  • Breadboard & wires

Python Code

import Adafruit_DHT
import time

sensor = Adafruit_DHT.DHT11
pin = 4

while True:
    humidity, temperature = Adafruit_DHT.read_retry(sensor, pin)
    if humidity is not None and temperature is not None:
        print(f"Temp: {temperature}°C  Humidity: {humidity}%")
    time.sleep(2)

The moment the temperature reading showed up in my terminal, I felt like a real engineer. (Even though I am definitely not one.)