Introduction: MAG (Miniature Automatic Greenhouse)

My mother is most of the time pretty busy. So i wanted to help her by automating her greenhouses. This way she can save a bit of time as she won't need to water the plants.

I will be able achieve this with MAG (Miniature Automatic Garden). As in the name, MAG is a miniature project that can be expanded for bigger greenhouses. MAG is an automated gardening monitoring system that reads and sends data of different sensors to a webserver running on Raspberry Pi. The user will be able to monitor their plants on a website. This concept is being developed as a final project within the first year of multimedia and communication technology, at Howest Kortrijk, Belgium.

Step 1: The Materials

In order to build this project, you will need the following items:

Electronics:

1. Raspberry pi 4 - kit
2. Raspberry pi T-cobbler
3. Breadboard
4. Male-to-male connectors
5. Male-to-female connectors
6. LM35 (temperature sensor)
7. 4x Moisture sensors
8. DHT11
9. MCP3008
10. Potentiometer (for controlling, not necessary)
11. SunFounder LCD-display
12. 4x Brushless water pomp 12V
13. Waterpipes
14. Adapter 12V
15. 4x Relay 5V

Casing:

1. Aquarium
2. Wooden planks
3. Solid round bar of iron
4. Nails
5. Screws
6. Aquaplan Roofprimer

Tools:

1. Hammer
2. Saw
3. Screwdriver
4. Drill
5. Woodfile
6. Glue gun
7. Paint brush
8. Welding machine
9. Solding device

In the Pdf file below, you can see the complete price list with links to the parts.

Step 2: Making the Greenhouse

In the provided images you will find the needed measurement for the boards. First you will find the images with the measurement, on it you will find a number (below this there will be extra information with the corresponding number). There are also some provided images of how it will look.

Numbers 1 to 4 are for the case and when you have cut them out you can attach together by hamering nails in the holes.

The extra board, numbers 5 + 6, is a lid that you can place above the compartment for the pi.

Notes:

The center of the holes on all the boards are 0.8cm away from the edges (Grey lines, see picture with number one is reference). The holes were drilled with a 2mm bolt for wood.

1.: This is the bottom plate. On the left side you have 64 cm between 2 holes. This counts for the distances between the holes and the edges on both the left and right side. The top board has a 2cm x 2cm square with the purpose of letting the power cables through. The bottom plank has a 8cm x 2.5cm cut out to position the lcd display.

2.: These are the longest sides and you will need 2 of these planks. On the top you have 2 cut out piece of 3mm x 10mm. This will be used later to route the moisture sensor cables.

3.: These are the shortest sides and you will need 4 of these planks.

4.: These are the intersection for the plant container, you will need 2 of these planks. You will need to remove the white piece as shown so you can slide these 2 in eachother

Step 3: Finishing the Greenhouse Case

Now that everything is mounted together, we will make sure that the compartments for the plants are waterproof. We do this to make sure no water can leak, just in case. With a paintbrush paint the compartments, if you want you can add a second layer when its dry.

Next up is welding the metal bars together in the middle so we end up with a cross. We will put this metal frame on the case after drilling 4 holes, 1 on each end like on the image. Make sure when you put it in that all 4 sides are even.

As last we will make a notch in each side of the compartment. Make it so the water pipes can rest in. Add a little piece of wood on top to keep it in place. Make sure when applying this piece of wood that you can still remove the water pipe easily and put it back in if needed.

Step 4: Software on the Raspberry Pi

For my code to work (which I will link below) you'll need to install some packages and libraries. First thing that is needed is for you to update your Pi.

First, update your system's package list by entering the following command: sudo apt-get update.

Upgrade all your installed packages to their latest versions with the following command: sudo apt-get dist-upgrade.

If the system doesn't ask for a reboot, do a 'sudo reboot'. This is to make sure that everything has been setup correct.

After you have installed the packages you'll need to install some libraries:

  • sudo pip3 install --upgrade setuptools
  • sudo apt-get install python3-flask
  • sudo pip install -U flask-cors
  • sudo pip install flask-socketio
  • sudo apt-get install rpi.gpio
  • sudo pip3 install Adafruit_DHT

When you are done, do a 'sudo reboot'.

Step 5: Making the Circuit

In step 2 we are going to make the circuit for this project. This is the absolute minimum you need if you want it to work. Use the fritzing table and the diagram to make a copy of the circuit. This is where you need all the electric materials from step 1.

Information about the circuit:

We have 5 sensors connected to the MCP3008 which are the lm35 for the inside temperature and 4 soil moisture sensors. A DHT11 for the outside temperature and humidity and lastly a water float switch to check if there is enough water in the reservoir.

The soil moisture sensor has a analog output and uses a GPIO-pin on the Raspberry Pi.

Extra:

I also implemented a LCD-display which will make it easier later on to connect to the Raspberry Pi without the need of having to connect to your laptop. This is not necessary but it is highly suggested.

Before soldering it all together I used my breadboard to link everything together and test my sensors to make sure everything works.

Step 6: Create a Database

It is very important to store your data from the sensors in an organized but also secure way. This is why i decided to store my data in a database. This way only I can acces this database (with a personal account) and keep it organized. In the picture above you can find my ERD diagram.

You can see my ERD diagram above, I will also link a dump file so you can import the database for yourself.
With this database you will be able to show multiple things like:

  • The temperature near and above the plants
  • The humidity near the plants
  • The ground humidity of each plant
  • See if the pump is enable for the plant
  • Etc..

Attached to this step you can find my Mysql dump. So you can easy import it. Get the Mysql dump.

Step 7: Website

I wanted to be able to monitor the plants so I made a website to show me this data. Via the website you will be able to check on the plants, as well as enabling/disabling the pumps seperately.

While the Pi is booting up, it will start running my python script. This will be taking care of getting the data to show on the website. Following the script, the pi will read data from the sensors every exact hour and put them in the database. The site is also responsive so it could be opened on mobile.

My code can be found on github right here.

Step 8: Writing the Backend

Now its time to make sure all components do there job. So I wrote some code in python and deployed it on raspberry pi. You can find my code on Github.

For programming the code I used Visual Studio Code. The code is written in html, CSS, javascript and python (Flask)

Step 9: Place Everything in the Case

Once you have finished all the steps successfully,

you can start putting everything in the case. In order to do so I highly recommend you to solder your components together so they can’t be disconnected by accident.

I glued the relays on a piece of wood so they dont hang lose when in the case. I also glued the pumps on to reservoir so they dont sit lose. I also advice to glue the DHT11 sensor on top of the frame.