Introduction: IGreenhouse - Intelligent Greenhouse

About: student NMCT at Howest (Kortrijk Belgium)

Home-grown fruits and vegetables are often better than those you buy, but sometimes you can lose sight of your greenhouse. In this project we will make an intelligent greenhouse. This greenhouse will automatically open and close his windows and door when it's too hot or too cold. When the plants are to dry, the smart greenhouse will automatically water your plants (in this project we will visualise the watering based on a led). The time your plants are being watered and when the door and windows are opened or closed is shown on a homemade website.

Step 1: Tools and Components

Tools:

  • A rivet pliers
  • A multifunctional saw
  • A drill diameter 1 mm
  • A step drill 8mm
  • tape measure
  • A file
  • Sandpaper
  • snap-off knife
  • A soldering iron

Components (see PDF):

  • Servo motors
  • Push buttons
  • Raspberry Pi 3 Model B
  • Temperature sensor
  • Moisture sensor
  • Breadboard
  • Transistor
  • Universal Power supply
  • Resistors
  • MCP3008
  • Pi T-Cobbler (Optional)
  • Led
  • Wires
  • Ethernet cable
  • 5,2V adapter
  • 8GB micro SD card
  • Hinges
  • Alluminium blind rivets
  • Bright polystyrene plate
  • Angle section
  • Soldering Tin
  • Double-sided tape
  • Pins
  • Electrical heat shrink sleeve
  • Cable ties
  • Box

Maximum cost: € 167,82

Attachments

Step 2: Setting Up the RPi

We will start installing the operating system on our Raspberry Pi.

  1. Download the image "Raspbian Jessie with pixel" from the Raspberry Pi website.
    You will see that this is a ZIP-file.
  2. Extract this ZIP-file to a desired location.
  3. Download the tool Win32 Disk Imager, this can be downloaded on Sourceforge.
    • Click on the folder icon to select the image
    • Then select at "Device" your microSD
    • Then click on "Write"

After the image is written on your microSD, you can open the microSD in Windows Explorer.

  • Open the file "cmdline.txt"
  • Add the following line before the word "rootwait": 169.254.10.0
  • Then save the file.
  1. Insert the microSD in the RPi
  2. Apply a voltage to your RPi with 5,2V DC Adapter
  3. Connect the network cable to the RPi and plug it into the network port of your computer.

Your Raspberry is ready to use now.

Step 3: Connect to the RPi

To connect to our RPi we will use Putty.

  1. Download Putty
  2. Create a SSH connection (see image)
  3. Sign in
    • Username: pi
    • Password: raspberry

SETTING WIFI UP

sudo nano /etc/wpa_supplicant/wpa_supplicant.conf

Go to the bottom of the file and add the following:

network={<br>	ssid="name of the wireless netwerok"<br>	psk="password of the wireless network"
<p>}</p>

To see your IP address type:

ifconfig wlan0

Now you can wirelessly connect to your Raspberry Pi

Hostname in Putty = IP address

Step 4: The Greenhouse

In this step we are about to make the greenhouse itself.

You'll need:

  • A multifunctional saw
  • A file
  • The rest of the materials mentioned in the bill of materials

Steps:

  1. Saw the polystyreen panel like illustrated on the draft above.
  2. Saw the angle section like illustrated on the picture above:
    • 3 x 50 cm
    • 2 x 50 cm (angle 140°)
    • 4 x 20,5 cm with one lit shortened by 1,5 cm
      • mitre cut these profiles with the 2 x 50 cm (angle 140°)
    • 4 x 17,5 cm (mitre cut two by two to make the gable)
  3. After sawing, polish the burr.

Step 5: The Angle Sections

  1. Place all parts together on the base of the angle sections.
  2. Drill holes in your corner profile and polystyrene pannel, as shown on the picture. The diameter is indicated on the packaging of your blind rivets.
  3. Place the blind rivets in the holes and fix them using a rivet pliers.

!! Please note that the blind rivets are diametrically opposed, so we don't have problems further on. !!

5. Now you slide the front and the back into the greenhouse.

Step 6: Windows & Door

Now we will place the door and the windows.

  1. Mark the door and the windows like shown on the pictures above.
  2. Saw the marked parts using a multifunctional saw.

    After sawing you'll see that there is burr on the side of the windows and door.
  3. Polish the sides and also the sides of the pieces that you have sawn out until you don't see any burr anymore.
  4. Pin the windows and the door with hinges as illustrated on the pictures.

The greenhouse is ready now!

Step 7: Wiring

  • R2 = 220Ω resistor
  • R3 = 1kΩ resistor
  • R4 = 10kΩ resistor
  • R5 = 1kΩ resistor
  • R6 = 10kΩ resistor
  • R7 = 1kΩ resistor
  • R8 = 10kΩ resistor
  • R10 = 470Ω resistor
  • R11 = 220Ω resistor
  • R12 = 220Ω resistor

Step 8: Adding Servos

Paste the servo motors to the polystyreen panel, using double sided tape.

Make sure that their pivot point is in a straight line with the hinge point of the door and the windows. (see picture)

  • To ensure that the door and the windows are pulled open by the servo motor, we will need to drill a small hole (diameter 1 mm). Between the wick of servo and the hole we will place a pin.
  • To get our wiring inside, we will drill a hole with a step drill. While you drill, ensure that you push your drill to a certain side. In this way we get a kind of rectangle.

Tuck the spelt so when the servo opens, the door goes with it.

Extend the wires (linking other wires) so you can reach your breadboard at the end of the greenhouse.

Step 9: Push Buttons

In this step we will start to drill 4 holes with a diameter of 1 mm to plug our buttons in (to open and close the door).

  1. Keep your button where you want to attach him (next to the door) and draw a dot on the place of the legs of your button. ( 2 times, 2 buttons)
  2. Drill in the dot you've drawn.

Attach the buttons

  1. Insert the legs of the buttons through the holes. (one inside, one outside)
  2. Solder a wire to each leg of the button.
  3. Place heat shrink over the leg and the brazed piece, so that the wires don't make a short circuit.
  4. Solder on the end of one wire a 220 ohm resistor. Place heat shrink over it.

Drill a hole with the step drill as seen in the previous step, so we can bring the wires of the inner button inside.

Attach the wires of the two buttons together with a clamping strap.

Extend the wires (linking other wires) so you can reach your breadboard at the end of the greenhouse.

Step 10: Soldering Led & Temperature Sensor

Solder the led as you did by the push button.

  1. Solder a wire to each leg of the led.
  2. Place heat shrink over the leg and the brazed piece, so that the wires don't make a short circuit.
  3. Solder on the end of one wire a 220 ohm resistor. Place heat shrink over it

Solder to each thread of the temperature sensor a male-female thread. So it will be easier to connect our temperature sensor to the breadboard.

!! Don't forget to place electrical heat shrink sleeve over the soldered parts. !!

Step 11: Hide Away Wiring

In this step we will make sure that the cables don't run through our plants.

  1. Insert a clamping strap through the holes that were formed when you have placed your blind rivets right in front of each other.
  2. Insert all cables in the clamping strap and pull.

And finally:

Past your breadboard and Raspberry Pi in the little box with double sided tape and drill a hole in the backpanel so you can bring your power supply out.

Step 12: Coding

Before we can run the code, we must first install some things on our Raspberry Pi.

  • Enable the one-wire interface
    • sudo raspi-config
    • Interfacing options
    • 1-wire : enable
    • sudo nano /boot/config.txt
    • add the following --> dtoverlay=w1-gpio
    • restart the Raspberry Pi with 'sudo reboot'
  • Installing MySQL on the Raspberry Pi
    • sudo apt-get update && sudo apt-get upgrade
    • sudo apt-get install mysql-server
    • sudo apt-get install mysql-client
    • mysql -uroot -p
      • password = root
  • Installing MySQL connector
    • sudo apt-get install python3-mysql.connector
  1. Download the Flask project from Github.
  2. Open the project in Pycharm

Step 13: MySQL Database

MySQL user toevoegen

mysql -uroot -p
CREATE USER 'name'@'localhost' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON *.* TO 'name'@'localhost' WITH GRANT OPTION;
CREATE USER 'name'@'%' IDENTIFIED BY 'password';
<span style="background-color: initial;">GRANT ALL PRIVILEGES ON *.* TO 'name'@'%' WITH GRANT OPTION</span>

Password and name are self-chosen.

Create a new database

CREATE DATABASE ENMDatabase;

Exit MySQL connection

quit

Step 14: Create Table in Pycharm

Add as Data Source a MySQL database.

  1. CTRL + SHIFT + A --> Database
  2. + Data Source --> MySQL

Use next information:

General

Host: localhost Port: 3306

Database: ENMDatabase

User: ** name you chose in previous step

Password: ** password you chose in previous step

SSH/SSL

Proxy host: ** your IP address Port: 22

Proxy user: pi

Proxy password: raspberry

Inserting tables

  1. Right click on the ENMDatabase --> Open console
  2. Execute the sql files (Database.zip) in the 'console'
  3. Result: see image above

Step 15: Upload the Project

In Flask:

  • Click on Tools --> Deployment --> Configuration
  • Configure as in the picture above
  • Click on Tools --> Deployment --> Upload to Default server

Step 16: Automatically Run

This is the very last step before we can use our greenhouse!

Go to your Raspberry Pi in Putty

sudo nano /etc/profile 

Add the following line below:

python /home/pi/ProjectFlask/ProjectFlask.py &

Step 17: Using IGreenhouse

In this step we are going to put our greenhouse ready for use.

  1. Connect the power supplyy from the Rasberry Pi in the socket.
  2. Wait until the Raspberry Pi is fully booted.
  3. Connect the universal power supply to the socket.

Always wait to connect the universal power supply until the Raspberry Pi is fully booted up, otherwise the servo motors will not work correctly!

To see your website: search for your IP address followed by :5000


Now your iGreenhouse is ready to use. You can grown your own fruit and vegetables.

So I'd say: enjoy your meal!