Automated Garden Watering System
You will setup an automated system to water the plants in your garden using a computer. Based on a python program you can control how much water needs to be dispensed, and for how long.
Here is a what you will make.
What you will learn
- Making a basic electronics circuit.
- Practical understanding on current and voltage.
- Elementary plumbing
- A little programming, and
- A whole lot of fun!
- Elemetary knowledge of python programming. If you can print “hello, world” and understand how to write a “for loop”, you’re fine.
- An adult to supervise some of the connections. If you’re an adult, then you’re fine.
- A micro-controller like the Raspberry Pi or Pi Zero with wifi and GPIO headers.
- A case for the pizero (optional).
- A relay that will be used to turn a solenoid valve on and off periodically.
- Three power supplies - One 12V and two 5V power adapters will work fine.
- A solenoid valve to attach to the water supply, like a tap.
- A tap, preferably with two outlets.
- Teflon tape to to attach the solenoid valve to the pipe.
- Water pump plier to bolt on the solenoid to the tap.
- An irrigation system like Cinagro
You will be using the following equipment from your QuriousCorner lab:
- Precision screw driver kit for tightening the small screws on the relay.
- Electrical tape
- Soldering iron and solder.
- A Multimeter
- A bench power supply (optional, but highly recommended for troubleshooting).
Above links are mentioned to display the images of the products - if you already have something similar - use them, or can get them cheaper elsewhere - buy them there.
Step 1: Power up the Pi Zero
- Follow the instructions here to install the OS in the SDCard, enable SSH and connect to WIFI.
- Use the Balena Etcher Program to copy the OS to the SDCARD.
- The Pi Zero cannot connect to the 5GHz band, so make sure you choose the 2.4GHz band only.
- Assign a static IP address to the pizero. You have to login to the wifi router to do this. Configure hostname, DNS, install additional software like vim etc, and reboot.
- Run a simple python program like the one below and verify that it works:
Take out the soldering iron and solder the GPIO headers to the pizero. For a proper touch the heated iron to one side of the pin, and the solder to the other side of the pin. The heat from the iron, to the pin to the solder…should melt the solder.
Make sure the solder flows on to the “circles” on the board. In the following picture, it does not, for one of the pins.
- Make sure your pins are correctly soldered. Take out your multimeter and first test the 3.3V and 5V pins by using the multimeter. To do so, connect the positive (red) to the 3.3 or 5V pin, and the negative (black) lead to the GND pin.
- Run the following program and then test if the GPIO pin voltage alternates between 3.3V and 0V. You have to connect the positive lead to GPIO 23 (or Pin 16). Connect the negative lead to GND (Pin 6).
import RPi GPIO as GPIO
DELAY_ON = 5
DELAY_OFF = 30
IN1 = 16
Place the Pi Zero in it’s own. As a bonus, this also includes a heat sink for your pi zero, so it runs cool.
You are now ready to move to step 2.
Step 2: Connect the Pi Zero to the relay
The heart of this project is the relay. Make sure you [relay-|-understand-what-a-relay-is-]].-Then-follow-[relay#^2ea006-|-this-experiment-to-connect-the-Pi-Zero-to-the-relay. Once you have completed this, you should be able to consistently hear a “clicking sound” when you run the python program. The clicking sound is the sound of the relay turning on and off.
Step 3: Connect the solenoid to the relay
The solenoid valve is what you use to control the flow of water. Read up on [solenoid | solenoids here ](/activities/solenoid | solenoids here ) which also has the steps to test, and then connect the solenoid to the relay and Pi Zero. You need to have an additional power supply for the solenoid.
Pay close attention on how to connect the solenoid - make sure it is connected through CO and NO terminals of the relay.
Run the same program again, and you should be able to hear the relay click, and “feel” the solenoid open and close.
At this point you’re using the bench power supply. It’s time to make your circuit mobile so you can carry it to the garden. Splice the wires of the power supplies for the relay, and solenoid and then connect them to the circuit.
Step 4: Attach the solenoid to the water supply
Move outdoors to the garden and find the water supply. Add in the tap with two outlets (one for automated control, and the other for manual operation - we still need manual!). Then attach the solenoid using Teflon tape, making sure to align it the correct way - valves only work in one direction.
Make sure the your connections are not leaky.
When you run the program, you should now be able to see water come out at the correct intervals. This is a big milestone!
Step 5: Install the water pipes
You need a some simple tools like T and straight connectors, a needle for making holes and another assorted things, all of which can be gotten from this vendor. Lay the pipes out around the garden and make holes at strategic levels for the water to spray out.
There are props for potted plants as well, if that’s what you need.
Finally, it’s time to put the whole thing in a box.
Now that you have a micro-controller that’s watering the garden, you can water flow control based on
- weather APIs (humidity, rain, etc)
- additional sensors like soil moisture sensor, or temperature sensor.
- presence of dogs and cats - watch them scamper when water starts spraying :)
You can also extend this to a mobile app and water on-demand from your phone. You can do all this and more - limited only by your imagination.