from time import sleep
from machine import Pin
from dht import DHT22
botão = Pin(20,Pin.IN,Pin.PULL_UP)
sensor = DHT22(Pin(28))
vermelho = Pin(1,Pin.OUT)
verde = Pin(7,Pin.OUT)
azul = Pin(12,Pin.OUT)
def medir(args):
azul.off()
sleep(0.1)
try:
sleep(0.3)
sensor.measure()
tempe = sensor.temperature()
print(tempe)
verde.on()
humidity = sensor.humidity()
print(humidity)
vermelho.on()
except:
print("falha")
botão.irq(handler = medir, trigger = Pin.IRQ_RISING)
while True:
azul.on()