This project teaches students how to measure temperature and humidity using the DHT11 sensor and an ESP32 microcontroller. Students will learn how to read sensor data and display it in the serial monitor, OLED, or web dashboard, introducing basic data collection and real-world IoT applications.
ESP32 3.3V —> VCC (DHT11)
ESP32 GPIO4 —> DATA (DHT11)
ESP32 GND —> GND (DHT11)
10kΩ resistor between VCC and DATA
from machine import Pin
import dht
from time import sleep
sensor = dht.DHT11(Pin(4)) # GPIO4
while True:
try:
sensor.measure()
temp = sensor.temperature()
hum = sensor.humidity()
print("Temperature:", temp, "°C")
print("Humidity:", hum, "%")
except OSError as e:
print("Sensor error:", e)
sleep(2)
You can explore a wide range of microcontroller and electronics projects, including Arduino, ESP32, IoT, and more. Each project comes with downloadable code, detailed guides, and the necessary hardware list.
You can explore a wide range of microcontroller and electronics projects, including Arduino, ESP32, IoT, and more. Each project comes with downloadable code, detailed guides, and the necessary hardware list.
You can explore a wide range of microcontroller and electronics projects, including Arduino, ESP32, IoT, and more. Each project comes with downloadable code, detailed guides, and the necessary hardware list.
You can explore a wide range of microcontroller and electronics projects, including Arduino, ESP32, IoT, and more. Each project comes with downloadable code, detailed guides, and the necessary hardware list.