from machine import Pin
import time
import machine
import dht
d = dht.DHT22(machine.Pin(23))
led1 = Pin(2, Pin.OUT)
led2 = Pin(4, Pin.OUT)
led3 = Pin(16, Pin.OUT)
while True:
d.measure()
temp = d.temperature()
humid = d.humidity()
print('Temperature:',temp,'*C')
print('Humidity:',humid,'%')
time.sleep(0.5)
if temp <= 10 and humid <= 35:
led1.on()
led2.off()
led3.off()
elif temp <= 35 and humid <= 65:
led1.off()
led2.on()
led3.off()
elif temp > 35 and humid > 65:
led1.off()
led2.off()
led3.on()
else:
led1.off()
led2.off()
led3.off()