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)
relayair=Pin(6 , Pin.OUT)
sensor=dht.DHT22(Pin(4))
LightSensor = ADC(28)
relaylight =Pin(5 , Pin.OUT)
tempair = ADC(27)
while True:
sensor.measure()
temperature = sensor.temperature()
humidity = sensor.humidity()
thalma= LightSensor.read_u16() * (100/65536)
tempex = tempair.read_u16()
print(tempex)
if (0 <humidity <=30):
ledR.on()
ledG.off()
ledY.off()
relay.off()
elif (30<humidity<=70):
ledY.on()
ledG.off()
ledR.off()
relay.on()
else:
ledG.on()
ledR.off()
ledY.off()
relay.off()
if (thalma >70):
relaylight.on()
else:
relaylight.off()
if (tempex <32535):
relayair.on()
else:
relayair.off()