import time
from machine import Pin
import dht
dhtpin = Pin(15, pull=Pin.PULL_UP)
sensor = dht.DHT22(dhtpin)
ledR = Pin(25, Pin.OUT)
ledG = Pin(26, Pin.OUT)
ledB = Pin(27, Pin.OUT)
while True:
ledR.off()
ledG.off()
ledB.off()
print("Measuring... ", end="")
sensor.measure()
temp = sensor.temperature()
humidity = sensor.humidity()
print("Temp: {}, Humid: {}".format(temp, humidity))
if temp > 50:
ledR.on()
elif 10 < temp <= 50:
ledG.on()
else:
ledB.on()
time.sleep(1)