from machine import Pin
from machine import ADC #analog to digital converter
import time
import dht
ledR=Pin(0,Pin.OUT)
ledY=Pin(1,Pin.OUT)
ledG=Pin(2,Pin.OUT)
relay=Pin(3,Pin.OUT)
sensor=dht.DHT22(Pin(4))
lightSensor=ADC(28)
relayLight=Pin(5,Pin.OUT)
tempAir=ADC(27)
relayAir=Pin(6,Pin.OUT)
while True:
   # ledR.on()
    #ledY.on()
    #ledG.on()
    #relay.on()
    #time.sleep(1)
    #ledR.off()
    #ledY.off()
    #ledG.off()
    #relay.off()
    #time.sleep(1)
    sensor.measure()
    temperature=sensor.temperature()
    humidity=sensor.humidity()
    lumiere=lightSensor.read_u16()*(100/65536)
    tempEXT=tempAir.read_u16()
    print(tempEXT)
    #print(lumiere)
    #print(temperature)
    #print(humidity)
    if(0<humidity<=30):
        ledR.on()
        ledY.off()
        ledG.off()
        relay.off()
    elif(30<humidity<=70):
        ledY.on()
        ledG.off()
        ledR.off()
        relay.on()
    else:
        ledG.on()
        ledY.off()
        ledR.off()
        relay.off()
    if(lumiere>70):
        relayLight.on()
    else:
        relayLight.off()
    if (tempEXT<32391):
        relayAir.on()
    else:
        relayAir.off()
BOOTSELLED1239USBRaspberryPiPico©2020RP2-8020/21P64M15.00TTT
NOCOMNCVCCGNDINLED1PWRRelay Module
NOCOMNCVCCGNDINLED1PWRRelay Module
NOCOMNCVCCGNDINLED1PWRRelay Module