from machine import Pin
from time import sleep
import dht
dht_sensor = dht.DHT22(Pin(16))
Red, Green = Pin(18, Pin.OUT), Pin(20, Pin.OUT)
while True:
dht_sensor.measure()
temp = dht_sensor.temperature()
hum = dht_sensor.humidity()
Red.value(temp > 30)
Green.value(temp <= 30)
print(f"Temp: {temp}ºC, Humidity: {hum}%")
sleep(1)