from machine import Pin
from machine import ADC
import time
import dht
ledR=Pin(0,Pin.OUT)
ledY=Pin(1,Pin.OUT)
ledG=Pin(2,Pin.OUT)
relay=Pin(3,Pin.OUT)
relayLight=Pin(5,Pin.OUT)
relayAir=Pin(6,Pin.OUT)
sensor= dht.DHT22(Pin(4))
lightSensor=ADC(28)
tempAir=ADC(27)
while True:
sensor.measure()
temperature=sensor.temperature()
humidity=sensor.humidity()
light=lightSensor.read_u16()*(100/65536)
tempEx=tempAir.read_u16()
if(0<humidity<=30):
ledR.on
ledG.off
ledY.off
relay.off
elif(30<humidity<=70) :
ledY.on
ledR.off
ledG.off
relay.on
else :
ledG.on
ledR.off
ledY.off
relay.off
if(light>70):
relayLight.on
else :
relayLight.off
if (tempEx>32535):
relayAir.on
else:
relayAir.off