from machine import Pin
import time
import dht
sensor=dht.DHT22(Pin(14))
while True:
try:
time.sleep(1)
sensor.measure()
temp=sensor.temperature()
hum=sensor.humidity()
print('temperature= ', temp)
print('humidity= ', hum)
except OSError as e:
print('failed')