#DHT11 Digital Temperature and Humidity Sensor
from machine import Pin
from time import sleep_ms
import dht
d = dht.DHT11(Pin(23))
led1 = Pin(4, Pin.OUT)
while True:
try:
d.measure()
temp = d.temperature() #( ํC)
humid = d.humidity() #(% RH)
print('Temp:', temp, ' Humid:', humid)
sleep_ms(1000)
#Auto system
if temp > 20 and humid > 50:
led1.on()
print('Warm.....')
else:
led1.off()
print('Normal....')
#Manual system
except OSError as e:
print('Failed to read sensor!')