from machine import Pin
import time
import dht
ledV = Pin(2, Pin.OUT)
ledO = Pin(3, Pin.OUT)
ledR = Pin(4, Pin.OUT)
d = dht.DHT22(machine.Pin(28))
while True:
d.measure()
temperature = round(d.temperature())
humidity = round(d.humidity())
print(temperature,"°C")
print(humidity, "% of humidity")
if humidity < 20:
ledV.off()
ledO.off()
ledR.on()
if 20 <= humidity < 60 :
ledV.off()
ledO.on()
ledR.off()
if 60 <= humidity <= 100:
ledV.on()
ledO.off()
ledR.off()
time.sleep(1)