Raspberry Pi Pico W ( Niveau 1 )
About Lesson
'''void setup ----------------------------------------------------------------------------------
-------------------------------------------------------------------------------------------------'''
from machine import Pin  , ADC # importing input / output and analog to digital converter libraries 
import time  # importing time library 
import dht 
sensor = dht.DHT22(Pin(0))
ledR = Pin(1 , Pin.OUT)
ledY = Pin(2 , Pin.OUT)
ledG = Pin(3 , Pin.OUT)
pumpRelay = Pin(4 , Pin.OUT)    # relay of water pump 
relayLight = Pin(5,Pin.OUT)     # relay of lamp of lighting 
ldr = ADC(28)
Tsensor = ADC(27) 
'''void loop----------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------'''
while 1: 
    sensor.measure()   #turn on the sensor measurement 
    humidity = sensor.humidity() #measure humidity of soil 
    temperature = sensor.temperature() #measure temperature of soil 
    light = ldr.read_u16()  #get value from light sensor using adc ( 0 - 65536)
    tempEx = Tsensor.read_u16() # get vaue from tempEx sensor using adc (0 - 65536 )
    lightPercent = (100 - int(light * (100 / 65500))) # convert light value to percent 
    print(tempEx) #display external temperture value  ( air temperature ) 
    if( 0   < humidity <= 30):
        pumpRelay.off() 
        ledR.on()
        ledG.off()
        ledY.off()
    elif ( 30   < humidity <= 70):
        pumpRelay.on()
        ledY.on()
        ledR.off()
        ledG.off()
    else  :
        pumpRelay.off()
        ledG.on()
        ledY.off()
        ledR.off() 
    if(lightPercent < 70  ): #turn on lamp when the light quantity is small 
        relayLight.on()
    else:
        relayLight.off()   #turn off lamp
    time.sleep_ms(10)
Join the conversation
Malek Bounasri 7 months ago
slm 3likom cv slvp comment je peux envoyer mon projet ?
Reply
0% Complete
error: Content is protected !!

ุชู… ุฅุฑุณุงู„ ุทู„ุจูƒ ุจู†ุฌุงุญ ูˆุณู†ุชูˆุงุตู„ ู…ุนูƒ ู‚ุฑูŠุจุงู‹