#DHT11 Digital Temperature and Humidity Sensor
from machine import Pin
from time import sleep_ms
import dht
d = dht.DHT11(Pin(23))
led = 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)
if temp > 20 and humid > 50:
led.on()
print('warm....')
else:
led.off()
print('normal....')
except OSError as e:
print('Failed to read sensor!')