Automatic Plant Watering System using Raspberry Pi Pico

Let's hunt the Second task from the Bounty Maker Hunting List. 

 

“2. Hi Boundy Makers, I need an automatic watering system for my favorite plants when I went out traveling, do you think you can help me with that? Make sure your creation is neat and beautiful.”

 

Here, We are going to make an Automatic Watering System using Raspberry Pi Pico, which waters the plant every 8 hours or depending on the soil moisture level. Let's see how I made it. 

projectImage
projectImage
projectImage
projectImage
STEP 1
Setting up Raspberry Pi Pico

1. Download the micropython firmware from https://micropython.org/download/rp2-pico/

 

2. On the Raspberry Pi Pico, Press the BOOTSEL button and hold it while you connect the other end of the micro USB cable to your computer. This puts your Raspberry Pi Pico into USB mass storage device mode.

 

3. Drag and drop the downloaded .uf2 firmware

projectImage
projectImage

Now the Raspberry Pi Pico is ready to be programmed. Open Thonny IDE, select the interpreter as MicroPython(Raspberry PI Pico).

STEP 2
Connections

You can find the Pinout of the Raspberry Pi Pico below. 

projectImage

Make the connections as shown below.

 

We have an internal RTC to get the time. Here we connect Water Pump, Soil Moisture Sensor, RGB LED to the Raspberry Pi Pico. 

 

5V Water Pump ->GPIO26

Soil Moisture Sensor ->GPIO27

LED_Pin1 -> GPIO14

LED_Pin2 -> GPIO13

LED_Pin3 -> GPIO12

STEP 3
Functionality

First, we will interface with the internal RTC to get the current time. We will trigger the water pump every 8 hours. The Moisture level is also continuously monitored. If the soil moisture drops, then the water pump is activated for 5 to 10 seconds. In this way, the plant is supplied with sufficient water at regular intervals. 

projectImage

Reading the Soil moisture sensor as a digital input. We toggle the LEDs and the water pump depending on the sensor value. 

projectImage
STEP 4
Code

You can find the code on my GitHub repository. 

Link to the Project repo: https://github.com/Rahul24-06/Automatic-Plant-Watering-System-using-Raspberry-Pi-Pico-

CODE
from machine import Pin
import time
import utime

red_led = Pin(14, Pin.OUT) #RED LED
green_led = Pin(13, Pin.OUT) #GREEN LED
sensor = Pin(27, Pin.IN, Pin.PULL_DOWN)
pump = Pin(26, Pin.OUT) #pump

print()
print(" YYYY MM DD HH MM SS")
dateTime = (input ("Enter current date & time: "))+' 0 0'
synchronisedTime = utime.mktime(list(map(int, tuple(dateTime.split(' ')))))
timeDelta = synchronisedTime - int(utime.time())

def timeNow():
    return utime.localtime(utime.time() + timeDelta)

def pump_on():
    red_led.value(1)
    green_led.value(0)
    pump.value(0)
    time.sleep(10)
    print("Pump On - Watering the Plant")
    
def pump_off():
    red_led.value(0)
    green_led.value(1)
    pump.value(1)
    print("Plant is healthy.")
    
while True:
    dateTime = timeNow()
    #print("{:02d}-{:02d}-{:04d} {:02d}:{:02d}:{:02d}".format(dateTime[2],dateTime[1],dateTime[0],dateTime[3],dateTime[4],dateTime[5]))
    utime.sleep(1)
    if (dateTime[3] == 8 and dateTime[3] == 16 and dateTime[3] == 0):
        if (dateTime[4] == 0 and dateTime[5] == 0):
            pump_on()
        else:
            pump_off()
            
    elif sensor.value():
        pump_on()
        
    else:
        pump_off()
STEP 5
Working

This setup is placed on a pot and is powered using a power bank. One of the water tubes is connected between the water pump and a water bottle, and the other tube from the water pump is connected to the soil.

projectImage
projectImage

We finally did this project successfully. This makes me a Bounty maker🌟

 

If you faced any issues in building this project, feel free to ask me. Please do suggest new projects that you want me to do next. 

Give a thumbs up if it really helped you and do follow my channel for interesting projects. :) 

Share this video if you like. 

Blog - https://rahulthelonelyprogrammer.blogspot.com/ 

Github - https://github.com/Rahul24-06/

Happy to have you subscribed: https://www.youtube.com/c/rahulkhanna24june?sub_confirmation=1 
 

Thanks for reading!

License
All Rights
Reserved
licensBg
1