from machine import Pin
from time import sleep
import dht
sensor=dht.DHT22(Pin(5))
while True:
try:
sleep(2)
sensor.measure()
temp=sensor.temperature()
hum=sensor.humidity()
temp_f=temp*(9/5)+32.0
print('Temperatura: %3.1f C'%temp)
print('Temperatura: %3.1f F'%temp_f)
print('Unidade: %3.1f %%'%hum)
except OSError as e:
print('Falha ao ler o sensor!!!')