Mini-Serre

As a student, I have a bad habit of forgetting things. Because of that, if I want to grow a certain type of plant, I usually forget about it and it dies because there is nobody to take care of it.

I will try to fix this problem with Mini-Serre. Mini-Serre is an automated gardening monitoring system that sends data of the different kind of sensors that are installed to a webserver running on the Raspberry Pi. This way the user can monitor their plants on a website wherever they are. 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 3 - kit
  2. Breadboard
  3. Male-to-male connectors
  4. Male-to-female connectors
  5. Dallas 18B20 (temperature sensor)
  6. Photoresistor Detection Photosensitive Light Sensor
  7. MCP3008
  8. Potentiometer
  9. LCD-display
  10. Resistors
  11. Blue LED
  12. RGB LED

Casing:

13. Central Park kweekkas (https://www.brico.be/nl/tuin-buitenleven/moestuin/...)
14. Wooden plate (bottom of the case)
15. Nails
16. Screws

Tools:

17. Hammer
18. Saw
19. Screwdriver
20. Drill

Step 2: 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 2 sensors connected to the MCP3008 which are the light sensor and soil moisture sensor. The temperature sensor has a digital 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.

Step 3: 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 scheme from my database and below a file to export the database to a database program, for example MySQL.

Database-program
It is important that our database can work on its own from our Raspberry Pi. You can do this by downloading MySQL or MariaDB for the Raspberry Pi. You first want to make the database on your computer in MySQL Workbench. Next you export this database as a self contained file. Now connect to your Raspberry Pi's database via MySQL Workbench and restore the database on here. Now you have the database running on your Raspberry Pi!

Step 4: Writing the Sensor Data to the Database

After the database is running on your Raspberry Pi we want our sensors to be able to store their data in it. We can do this by creating 3 seperate scripts (which is did in PyCharm). A nice feature included in PyCharm is that you are able to connect to your Pi and this way you can acces your database and write directly to it. The data is also directly read by the Raspberry Pi and the LED's will light up accordingly to what you need.

Blue LED lights up: The soil isn't moist enough.
RGB LED lights up green: everything is fine.
RGB LED lights up red: it is too hot, open the roof to cool it down a bit.
RGB LED lights up blue: it is too cold, close the roof if it is open.

You can download all the scripts from my github repository: https://github.com/WoutRuyters/Project_sensors

Note: I used my personal login information for the databases so you might have to change it to fit yours.

Note: The folder DB1 contains a class 'database' which is imported in the code which will connect to your database.

Step 5: Displaying Your IP on the Display

The display shows the IP-address that your Raspberry Pi is running on, this way you can easily connect without any wires to your Raspberry Pi. I also wrote a script for this which reads the IP of your pi and displays it on the display (note that your GPIO-pins match otherwise it might not work). The Raspberry Pi runs this script automatically on startup. You can do this by adding some code to the rc.local file on your Raspberry Pi. You can get there by typing 'sudo nano /etc/rc.local', before the last line of code you want to add 'Python3.5 /home/user/filelocation &'.

You can find the script here: https://github.com/WoutRuyters/Project_display

Note: the '&' at the end, this will make the script run once and immediatly stop it so other scripts can run aswell.

Step 6: Measuring the Sensors Every 10 Minutes

We don't want our database to be filled by the sensordata ever 0.001seconds, otherwise this will make it way to hard for the database to keep up with all the data coming in and it might crash. This is why I added a scrapt to 'crontab' on the Raspberry Pi. Crontab is a program that keeps track of scheduled tasks so this way you can simply run the script every 10 minutes just once.

How to set it up:

You can set this up by first typing into the Raspberry Pi command line 'crontab -e', this opens the editor for crontab. Scroll down to the bottom of the file and add 3 lines, one for each sensor.

'*/10 * * * * python3.5 /home/user/filepath/sensor1'

Note: The '*/10' is the 10 minutes we want to be between every measurement. The code I typed after it is the python version you are running and the file you want to run so you have to write one line for every sensor because they exist out of 3 different files.

Step 7: Making the Website

I made my website in a program called Atom. It is a very simple to use program and adviseable if you're pretty new to writing HTML and CSS like me.

You can find all the code and images used following this link: https://github.com/WoutRuyters/Project_website

I made the front-end of the website in Visual Studio Code so if you're not planning on making the HTML & CSS yourself you can just add the files to a new folder in Visual Studio Code instead of Atom.

Step 8: Creating the Back-end

The back-end and front-end will be the things that actually make something happen on the website we just made. In the back-end we connect to our database once again and instead of putting data in the database. We will now read all the data from the different sensors and using Socket.IO we will send it to our front-end so we can display it on the website.

You can find the code to the back-end here: https://github.com/WoutRuyters/Project_Back-end

Note: We use the database class we used earlier before so I didn't include this in this repository.

Step 9: Creating the Front-end

The front-end is where we combine our HTML & CSS code together with JavaScript and our Back-end. The JavaScript I wrote tries to make a connection with the back-end which has to be Running. Now the Back-end will send us all the data from the sensors and we can make a few functions in JavaScript which edit the HTML file so it fits our current values.

The JavaScript can be found here: https://github.com/WoutRuyters/Project_Front-end

Note: make sure you link in your HTML to the correct folder of the place of your JavaScript otherwise it may not work.

Step 10: Making the Greenhouse

I bought a premade package from Brico: https://www.brico.be/nl/tuin-buitenleven/moestuin/...

Just follow the steps that come with the package. After this is done we're not quite ready to put our Raspberry Pi in there. First we need to make a 'floor' or bottom for the Greenhouse, you can do this by taking a wooden plate and measuring out how big it has to be to make it fit. I first made wooden frame so the wooden plate has something to rest on.

Step 11: Putting Everything Together

We're almost ready! Just this one last step and you're ready to go. Take the Raspberry Pi and the greenhouse, make a few holes so you can put the LED's through it, make a hole for the display and a hole for the Raspberry Pi power supply. Put everything in the greenhouse, plug in the Pi and you're all set up! You've got your own greenhouse!

Share

    Recommendations

    • Games Contest

      Games Contest
    • Stone Concrete and Cement Contest

      Stone Concrete and Cement Contest
    • Backyard Contest

      Backyard Contest

    Discussions