from machine import Pin
from time import sleep
from dht import DHT22
dht = DHT22(Pin(15))
dht2 = DHT22(Pin(14))
led1 = Pin(16, Pin.OUT)
led2 = Pin(17, Pin.OUT)
led3 = Pin(18, Pin.OUT)
while True:
dht.measure()
dht2.measure()
temp = dht.temperature()
hum = dht.humidity()
temp2 = dht2.temperature()
hum2 = dht2.humidity()
avgt = (temp + temp2) / 2
avgh = (hum + hum2) / 2
print(f"average temp {avgt}degree C and average humidity: {avgh}% ")
if avgt > 30:
led1.toggle()
sleep(0.5)
elif avgt < 30 and avgt>=10:
led2.toggle()
sleep(0.5)
elif avgt < 10 :
led3.toggle()
sleep(0.5)
sleep(2)