Plant-It : Self Watering + Monitorable Indoor Greenhouse

by MerijnDefoort in Circuits > Raspberry Pi

614 Views, 3 Favorites, 0 Comments

Plant-It : Self Watering + Monitorable Indoor Greenhouse

IMG_4050.JPG

I love to grow plants but like some people I forget to water them and because of this they die or don't grow as well. Luckelly I'm a MCT student at Howest and I was tasked to make a project and I chose to make this self watering and monitorable indoor greenhouse so you don't have to worry about your plants having to little water and light. I hope people that love plants find this project useful.

Supplies

Main components

- 1x MCP3008 module

- 2x breadboard
- 1x 74HC595 Shift register module

- 1x Raspberry pi 4 + power cable

- 1x T-cobbler + T-cobbler cable

- male to male arduino/raspi cables

- male to female arduino/raspi cables

- 1x LDR sensor

- 1x 10k ohm potentiometer

- 1x 2x16 LCD screen

- 3x buttons

- 3x 470ohm transistors

- 1x 10k ohm transistor

- 1x 1k ohm transistor

- 1x 4.7k ohm transistor

- 1x 3.3v-5v power module

- 1x soil humidity sensor

- 1x one wire temperature sensor

Growing Lights

- 3x growing lights

- 3x E27 light sockets

- blue VOB cable 1.5mm²

- brown VOB cable 1.5mm²

- 1x plug with cable

water pump

- 1x 5V water pump

- 1x 5V power cable

- 1 long tube that fits on the nuzzle of your pump

- some clamps to tighten the connections


Tools

- 1x wire stripper

- 1x plyers

- 1x soldering iron

- 1x soldering tin (size and length is not important)

- 1x electrical tape

(Heat shrink tubing is useful but is optional)

You don't have a component or have nothing of the above ? No problem You can find a link to an BOM(Bill of Materials) file down here. You'll find some links to sites who sell the components, the estimate price and how much you probably need of them.

Gathering the Parts

IMG_3965.JPG
IMG_3966.JPG
IMG_3971.JPG
IMG_3984.JPG
IMG_3988.JPG
IMG_3990.JPG
20210615_080619.jpg
20210615_080639.jpg
20210615_080705.jpg
20210615_080726.jpg
20210615_080754.jpg
20210615_080820.jpg
20210615_080836.jpg
20210615_094748.jpg

To be able to start with this instructable you will need the components and tools (and materials for the case if you want to make it like the one I made.) that are in the supply list at the beginning. In the next photos you will see how the most important components you need look like.

photo list:

1. 5V water pump
2. Soil moisture sensor
3. Water proof temperature sensor
4. Power module 3.3V-5V
5. 2x16 LCD display
6. Growing Light format E27
7. LDR sensor
8. Shift register
9. button
10. MCP3008 module
11. t-cobbler cable(Be carful that the cable is plugged in the right way see step2)
12. 2-way 5V relay
13. raspberry pi 4
14. t-cobbler + breadboard


Creating the Circuit

Elektrisch fritzing shema_MerijnDefoort.png
BreadBoard Schema_Project_MerijnDefoort.png

In these pictures you can see two schematic of every part and how it connects with the Pi and each other the first is just an overall look at how it al is connected the second one is how it could look on your breadboards. for more detail you can look in the fritzing and breadboard file.

The Relay

IMG_3998.JPG
IMG_3999.JPG
IMG_4002.JPG

Because I used a 5V 2-way relay you will need to solder your water pump like in the picture so it connects the negative pole to the negative pole of your power cable. the lamp doesn't need soldering because you can use wire splice connectors to connect the cables to each other. For the lamps you will need to connect each lamps negative pole and each positive pole to each other and that common + pole goes into the NO of your relay and the - pole attaches to the - pole of the power cable of which its positive pole attaches to the COM port of your relay this order also goes for the water pump.

Prepping You Raspberry Pi

Capture.PNG

To be able to control al the components and run the code you need to configure your raspberry pi and in this step I'll guide you thru it.

  1. download the raspberry pi image (click me) choose the one without desktop because you don't need it for this project
  2. Use an imager like Win32 Imager or Balena Etcher to write te image on your SD card.
  3. go to the boot folder/partition on your SD and look for the cmdline.txt file and open it with Notepad++
  4. go to the end of the line and add "ip=196.254.10.1" then save
  5. Add an file named ssh without and extension or content into your boot partition
  6. now take out your SD out of your PC and put it into your PI. Connect your Pi with your PC using an ethernet cable.
  7. Open putty(click here for download)
  8. Enter the IP address you added to your cmdline file in the Hostname, make sure the port is 22 and connection type is SSH. Now press open
  9. Once it is connected log in with following login:
    1. username = pi
    2. password = raspberry
  10. now you have to configure wireless LAN connection (click here for guide)
  11. make sure that you change the dhcpcd.conf file using:"sudo nano /etc/dhcpcd.conf" and scroll down until you find the part about fallback addresses. edit it to make it look like in the picture. You can use this to connect ot your pi via ssh by changing your ip for your ethernet connection to static and to "192.168.168.100".
  12. once you are back into the terminal enter "sudo apt update && apt upgrade -y" to update your pi
  13. now enter "sudo apt install mariadb-server apache2" this is needed to run your webserver and database
  14. next enter "sudo pip3 install Flask Flask-Cors Flask-SocketIO gevent gevent-websocket greenlet spi SPI-Pyspidev" these are packages that you will use in the backend if this project
  15. finally enter "sudo apt install python3-mysql.connector -y" to connect to the database

Now you will have to create an user for your DB:

  1. enter "sudo mysql -u root" to connect to your MySQL server
  2. create an user with the name student and a password of your choice(don't forget this login)
  3. into your MySQL server terminal enter: "GRANT ALL PRIVILEGES ON *.* TO "student"@"%" IDENTIFIED BY "yourPasswordHere" WITH GRANT OPTION"
  4. now you will be able to visit the webserver of your pi using the LAN IP got from your configured WIFI Connection.

The Code That Makes It All Work

Click here to find the code I made for this project.

Use VSCode to make a SSH connection to your pi so you can use that to run the code(click here for the guide)

Make a folder to put your code in when you are connected to your PI.

Watch out for the config.py file in there you will need to change the name of your db, and your password into the ones you chose.

To be able to run the script automatically on reboot you will need to make 2 files:

  1. myproject.service
  2. mypicode.service

In those files you will have to enter the following:

[Unit]

Description=Plant-It

After=network.target

[Service]

ExecStart=/usr/bin/python3 -u [here location file (app.py(myproject.service) or PI_Code.py(mypicode.service)]

WorkingDirectory=[here location file (app.py or PI_Code.py)]

StandardOutput=inherit

StandardError=inherit

Restart=always

User=student

[Install]

WantedBy=multi-user.target

Now you will need to copy the 2 files to /etc/systemd/system using the following command:

"sudo cp myproject.service /etc/systemd/system/myproject.service"

&

"sudo cp mypicode.service /etc/systemd/system/mypicode.service"

now you can test this using: "sudo systemctl start myproject.service"

to stop this enter: "sudo systemctl stop myproject.service"

if this works you can enable the auto restart using:

`sudo systemctl enable myproject.service`

&

`sudo systemctl enable mypicode.service`

Database

Capture.PNG
Capture.PNG
Capture.PNG

For this part we will be using MySQL Workbench. first you will need to create a new connection like in the screenshot(Don't forget to change your username and password to the once you chose). Create a database like the one in the second screenshot. blue squares are data that can't be null and the red are foreign keys. In the plant table add the data of the 2 plants so you can test it out and you can add more plants if you want to.

The Case

IMG_4016.JPG
20210614_105937.jpg
20210614_105951.jpg
20210614_221835.jpg
20210614_221917.jpg
20210614_221929.jpg

I made a case out of 3 different materials:

  1. Multiplex 10mm
  2. Plexiglass 2mm
  3. Plexiglass 3mm

The main box where the plants go and where the lamps go on top of has a measurement of 40cm high 40 cm in width and 40 cm deep

The second box (box where al your components go is 30 cm high 40 cm deep and 25cm in width.

I made a couple of holes for the water tube, moisture and temperature sensor. power cables go thru 2 holes on the side of the smaller box and on the front panel of the "brain" of this project are 3 holes for buttons and one rectangular hole for the LCD screen.

Final Product

IMG_4050.JPG

After you finished doing everything and it works you can use the html to set a timer or add water with the press of a button the water doses are limited to the plant you chose. on the overview.html you can find the live feed of your sensors.

I hope you enjoy this project and have fun with your self watering greenhouse