Smart Greenhouse

Intro: Smart Greenhouse

Did
you ever had the problem that it was too hot in your greenhouse, so all your plants died, because you forgot to open the air vents?

Look no further, smart greenhouse is the solution to this problem.

Following step walks you through how to build your Smart Greenhouse or modify your greenhouse to a Smart Greenhouse.

Step 1: Components

Components:

1 x Servo motor

2 x Temperatuursensor

1 x fan

2 x soil moisture sensor

2 x light sensor

8 x white led

multiple resistors

1 x 4 by 7-segment display

1 x MCP3008

1 x 74HC595

1 x Relais

1 x raspberry pi 3 model b

Breadboard

jumpercables

a small greenhouse

Step 2: Write Rasbian on the Micro SD Card

    1. Download the latest version "rasbian stretch with desktop" from there site: https://www.raspberrypi.org/downloads/raspbian/
    2. Unzip the raspbian file.
    3. Download also the latest version etcher from there site: https://etcher.io/
    4. Reformat the 32GB micro SD card.
    5. Open echter, select the rasbian img and you micro SD card.
    6. Click on Flash.

    Step 3: Add Ip and Enable SSH

    1. Add a "ssh" file to the micro SD card.
    2. Find the "cmdline.txt" file and open it.
    3. Add "ip=169.254.10.1" at the end.
    4. Insert the micro SD card in je Raspberry Pi and give it power.
    5. Connect the Raspberry Pi with an ethernet cable to your pc.

    Step 4: Get Started With Putty

    1. Download the latest version "rasbian stretch with desktop" from there site: https://www.putty.org/
    2. Open putty and fill in the following details:
      1. HostName (or IP address): 169.254.10.1
      2. Connection type: SSH
      3. Saved Sessions: Smart_Greenhouse
    3. Click on "Save"
    4. Click on "Open"
    5. If you get a security alert from putty, click "Yes".

    Step 5: Raspberry Pi Basics

    1. Defealt cedentials are:
      1. username: pi
      2. password: raspberry
    2. Change default password by typing command "passwd" and enter
    3. Type first current password raspberry and after that twice your new password of your choice.

    Step 6: Connect to Wi-Fi and Update Raspberry Pi

    1. Type: sudo -i
    2. Type: echo “password” | wpa_passphrase “SSID” >> /etc/wpa_supplicant/wpa_supplicant.conf
    3. Change password to the password of your wifi and SSID to the name of your wifi.
    4. To check type: nano /etc/wpa_supplicant/wpa_supplicant.conf
    5. There should be something in this file that looks like the image above. Use "Ctrl" + "X" to exit the file.

    6. Type: systemctl restart networking

    7. Type: systemctl status networking

    8. Type: reboot

    9. Wait 30 seconds, restart putty, click "Smart_Greenhouse" and click "Open"

    10. Log in again

    11. Type: ping 8.8.8.8

    12. After these commands, there should be something that looks like the image above.

    13. Type: sudo apt-get update && sudo apt-get upgrade -y this can take a while to update.

    Step 7: Enable SPI and 1-wire

    1. Type: sudo raspi-config
    2. Select "Interface Options"
    3. Select "SPI", say "Yes" and say "Ok"
    4. Select "Interface Options"
    5. Select "1-wire", say "Yes" and say "Ok"
    6. Select "Finish"
    7. Type: sudo reboot
    8. Wait 30 seconds, restart putty, click "Smart_Greenhouse" and click "Open"

    Step 8: Create Smart Greenhouse Folder and Download All Necessary Packages

    1. Type: sudo apt update
    2. Type: sudo apt install -y python3-venv python3-pip python3-mysqldb mariadb-server uwsgi nginx uwsgi-plugin-python3
    3. Type: mkdir Smart_Greenhouse && cd Smart_Greenhouse
    4. Type: mkdir Smart_Greenhouse_frontend && cd Smart_Greenhouse_frontend
    5. Type: python3 -m venv --system-site-packages env
    6. Type: source env/bin/activate
    7. Type: python -m pip install mysql-connector-python argon2-cffi Flask Flask-HTTPAuth Flask-MySQL mysql-connector-python passlib
    8. Type: sudo reboot

    9. Wait 30 seconds, restart putty, click "Smart_Greenhouse" and click "Open"

    10. Type: cd Smart_Greenhouse

    11. Type: mkdir Smart_Greenhouse_backend && cd Smart_Greenhouse_backend
    12. Type: python3 -m venv --system-site-packages env
    13. Type: source env/bin/activate
    14. Type: python -m pip install mysql-connector-python argon2-cffi Flask Flask-HTTPAuth Flask-MySQL mysql-connector-python passlib
    15. Type: sudo reboot
    16. Wait 30 seconds, restart putty, click "Smart_Greenhouse" and click "Open"

    Step 9: Uploade Code on Raspberry Pi

    1. Download the latest filezilla client from there site: https://filezilla-project.org/
    2. Download the code from github: https://github.com/NMCT-S2-Project-I/project-i-Jo...
    3. Start fillezilla and fill in following details:
      1. Host: 169.254.10.1
      2. Username: pi
      3. Password: "password you chose on the Raspberry Pi"
      4. Port: 22
      5. Click connect
    4. In the left side "local site" navigate to the files you downloaded from github
    5. In the right side "extrene site" navigate to the Smart_Greenhouse folder
    6. Drag the "conf" and "sql" folders to the Smart_Greenhouse folder

    7. Open the Smart_Greenhouse_backend in both sides and drag "model" and "main.py" from the left to the right side

    8. Go back to the previous folder on both sides

    9. Open the Smart_Greenhouse_frontend in both sides and drag "static", "templates" and "app.py" from the left to the right side

    10. It should look like the picture above.

    Step 10: Create Database

    1. Start putty and log in
    2. Type: cd Smart_Greenhouse/
    3. Type: sudo mariadb
    4. Type: CREATE USER 'project1-admin'@'localhost' IDENTIFIED BY 'admin'; CREATE USER 'project1-web'@'localhost' IDENTIFIED BY 'web'; CREATE USER 'project1-sensor'@'localhost' IDENTIFIED BY 'sensor';
    5. Type: CREATE DATABASE smartgreenhousedb;

    6. Type: GRANT ALL PRIVILEGES ON smartgreenhousedb.* to 'project1-admin'@'localhost' WITH GRANT OPTION; GRANT SELECT, INSERT, UPDATE, DELETE ON smartgreenhousedb.* TO 'project1-web'@'localhost'; GRANT SELECT, INSERT, UPDATE, DELETE ON smartgreenhousedb.* TO 'project1-sensor'@'localhost'; FLUSH PRIVILEGES;

    7. Type: show databases;

    8. It should look like the picture above.

    9. Type: exit;

    10. Type: sudo mariadb < sql/smartgreenhousedb.sql

    11. Type: sudo mariadb

    12. Type: use smartgreenhousedb;

    13. Type: show tables;

    14. Type: exit;

    Step 11: Automatic Start of Scripts

    1. Type: sudo cp conf/project1-*.service /etc/systemd/system/
    2. Type: sudo systemctl daemon-reload
    3. Type: sudo systemctl start project1-*
    4. Type: sudo systemctl status project1-*
    5. Type: sudo cp conf/nginx /etc/nginx/sites-available/project1
    6. Type: sudo rm /etc/nginx/sites-enabled/default
    7. Type: sudo ln -s /etc/nginx/sites-available/project1 /etc/nginx/sites-enabled/project1
    8. Type: sudo systemctl restart nginx.service

    9. Type: sudo systemctl status nginx.service

    10. Type: sudo systemctl enable project1-flask

    11. Type: sudo systemctl enable project1-sensor

    12. It should look like the picture above.

    Step 12: Builds Greenhouse

    1. Build the greenhouse.
    2. Add all the components to the greenhouse according to the electrical diagram.
    3. Add power and enjoy.

    Share

      Recommendations

      • Metalworking Contest

        Metalworking Contest
      • Audio Contest 2018

        Audio Contest 2018
      • Fix It! Contest

        Fix It! Contest

      Discussions

      0
      None
      tomatoskins

      3 months ago

      Thanks for sharing and welcome to the community!