Introduction: Automatic Plant Watering

Are plants not satisfied with your care?

Do they always die without explaining their problems to you?

Well then keep reading on how to build your own automatic plant watering sytem, that gives you all the information you'll ever need to make your plant live a happy life. I made sure to not only include the moisture, but also the temperature and light for extra reference. You'll be able to see the growth of your own plant.

And on top of that, it keeps your plant moisturised.

Supplies

Electrical components:

    • Raspberry Pi (4)
    • LCD Display 16x2 (for displaying IP-adress)
    • Light Dependent Resistor
    • TMP36
    • (Sparkfun) Moisture sensor
    • MCP3008
    • Potentiometer
    • Relay module
    • Small submersible pump (Preferable 5-9V)
    • Breadbord
    • Electrical wires

    Tools and materials:

      • Some wood
      • Basic tools
      • Woodglue
      • Jar or glass bowl to store water

      Software: (i used, feel free to use any alternatives)

      • win32diskimager
      • Putty
      • MySQL Workbench
      • Visual Studio Code

      Step 1: Setting Up the Pi

      First we'll setup our Raspberry Pi. Grab the Raspbian image from https://www.raspberrypi.org/downloads/raspberry-pi-os/ and write it to an SD card.

      Now connect to your internet and run the following commands to install necessary programs and libraries.

      Apache, PHP

      sudo apt install apache2 -y
      sudo apt install php libapache2-mod-php -y

      MariaDB

      sudo apt install mariadb-server mariadb-client -y
      sudo apt install php-mysql -y
      sudo systemctl restart apache2.service 

      PHPMyAdmin

      sudo apt install phpmyadmin -y 

      Python

      pip3 install mysql-connector-python 
      pip3 install flask-socketio 
      pip3 install flask-cors 
      pip3 install gevent
      pip3 install gevent-websocket 
      pip3 install spidev
      
      pip3 install CharLCD

      Step 2: Building the Circuit

      First we'll make sure all the components are ready. Carefully connect all the wires as shown.

      All 3 sensors are connected with the MCP3008. The MCP3008, together with the LCD and Relay IN1, are all directly connected with the Pi.

      Do not connect the pump with the Pi, as this could cause damage!

      Step 3: The Code and Database

      All the code and the databse can be found and used from my Github:

      https://github.com/SnauwaertSander/RaspiPlant

      Place the Frontend (html) inside '/var/www/'
      Place the Backend (project1) in /home/pi/

      Connect to your MySQL server (with MySQL workbench or any client through SSH) and execute the dump found in github.

      To make the code run automatically, place the Raspiplant.service inside /etc/systemd/system/ and run the following command:

      sudo systemctl enable Raspiplant.service

      After everything is in it's place, the code should run automatically on startup, to confirm everything is working correctly reboot your pi and go to the IP shown on the lcd. If you can't acces the site or the site doesn't show any values after 30s, disconnect your Pi and check your wiring.

      Now every hour the program wil run a check on your plant. It will record the values in the chart and activate the pump if needed. In this version, the only way to add new plants is in the database.

      Step 4: Casing

      I build my case with some old wood and basic tools. I'm sure you could do a much better job then i did, so go ahead and try something.

      If not here's a basic explanation on how I did it: I made a small wooden box using wood glue. To acces the electronics, I used a hinge on the top part. Then I made some holes for the sensors, power and the LCD. After all that I finished it with a layer of grey paint.