Skip to content

Integrate smart irrigation system to water the tree automatically #4

Description

@myHerbDev
import RPi.GPIO as GPIO
import time

# Set up the GPIO pins for the irrigation valve and the pump
GPIO.setmode(GPIO.BCM)
GPIO.setup(18, GPIO.OUT)
GPIO.setup(23, GPIO.OUT)

# Define a function to water the tree
def waterTree():
    # Open the irrigation valve
    GPIO.output(18, GPIO.HIGH)

    # Turn on the pump
    GPIO.output(23, GPIO.HIGH)

    # Wait for 5 minutes
    time.sleep(300)

    # Close the irrigation valve
    GPIO.output(18, GPIO.LOW)

    # Turn off the pump
    GPIO.output(23, GPIO.LOW)

# Water the tree every day at 10am
while True:
    # Get the current time
    now = time.localtime()

    # Check if the current time is 10am
    if now.tm_hour == 10 and now.tm_min == 0:
        # Water the tree
        waterTree()

    # Wait for 1 second
    time.sleep(1)

Metadata

Metadata

Assignees

Labels

documentationImprovements or additions to documentation

Projects

Status
✅ Ready to Share

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions