import dht
from machine import Pin
import time
sensor = dht.DHT11(Pin(15))
warn_led = Pin(16, Pin.OUT)
TEMP_LIMIT = 30 # degrees Celsius
while True:
try:
sensor.measure()
temp = sensor.temperature()
hum = sensor.humidity()
print(f"Temp: {temp}°C, Humidity: {hum}%")
warn_led.value(1 if temp > TEMP_LIMIT else 0)
except Exception as e:
print("Sensor read error:", e)
time.sleep(2)