from machine import Pin
import time, random
import dht
dhts=dht.DHT22(Pin((16)));
red_led = Pin( 22, Pin.OUT)
blue_led = Pin(18, Pin.OUT)
# Main program
while True:
dhts.measure();
temp = dhts.temperature() + random.randint( -3 , 3 )
humi = dhts.humidity() + random.randint( -5, 5 )
time.sleep(0.1)
print(f'temp:{temp}, humi:{humi}')
if temp > 25:
red_led.value(1)
print('RED HOT')
else:
red_led.value(0)
if humi >40:
blue_led.value(1)
print('BLUE WET')
else:
blue_led.value(0)
print('-'*30)
time.sleep(3)