from machine import Pin
from time import sleep
from dht import DHT22
button = Pin(13, Pin.IN, Pin.PULL_UP)
led = Pin(3, Pin.OUT)
sensor = DHT22(Pin(28))
while True:
try:
sleep(1)
sensor.measure()
if button.value() == 0:
tempe = sensor.temperature()
humidity = sensor.humidity()
print(tempe)
print(humidity)
led.on()
sleep(1)
else:
led.off()
except:
print('DHT Falhou')