from machine import Pin
from time import sleep
import dht
sensor = dht.DHT22(Pin(25))
#sensor = dht.DHT22(Pin(25))
while True:
try:
sleep(2)
sensor.measure()
temp = sensor.temperature()
temp_f = temp * (9/5) + 32.0
print('Temprature: %3.1f C' %temp)
print('Temprature: %3.1f F' %temp_f)
except OSError as e:
print('Failed to read sensor.')
Loading
ssd1306
ssd1306