Plant with auto watering

  • Raspberry Pi 3 Model B+
  • Soil Moisture Sensor
  • Flexible Water Line
  • 12V Relay
  • 12V Micro Submersible Pump
  • TOLI 120pcs Multicolored Dupont Wire
  • 5v Power Supply (Any USB Cable+ USB Wall Charger
  • 12v batteri pack for pump supply

Hardware setup

Water Sensor – plug the positive lead from the water sensor to pin 2, and the negative lead to pin 6. Plug the signal wire (yellow) to pin 8.

Relay – Plug the positive lead from pin 7 to IN1 on the Relay Board. Also connect Pin 2 to VCC, and Pin 5 to GND on the Relay board.

Pump – Connect your pump to a power source, run the black ground wire between slots B and C of relay module 1 (when the RPi sends a LOW signal of 0v to pin 1, this will close the circuit turning on the pump).

This diagram capture the correct GPIO as long as you are using Raspberry Pi 3 B+ and not shown is another power source to the RPi.

Image result for rasp gpio

Lamp using 5v from USB and its scheduled with crontab schedule.

Software setup

Flaskwebserver – ( )

The next aspect of this project is to setup and install the web server. This python script runs a web server enabling various actions from the script described above. It will control the plant in the way you want.

You will need to install flask, and psutil as follows:

$> python3.4 -m pip install flask $> python3.4 -m pip install psutil

$> sudo python3.4 Now if you navigate to the ip address of your RPi, you should see a web dashboard something like this:

Make sure to place the file in the same directory as the script above. You will also need to create a sub-directory called templates, and place main.html in the templates directory. Now run the following command command to start your web server:

Get the code:

Run it on boot:


$> sudo crontab -e

@reboot cd <your path to web_plants>; sudo python3.4

Leave a Reply