Internet of Greens

Mini Automated Greenhouse

Spring 2018, Embedded Systems Design Project

A computer sitting on a table

Description generated with very high confidence

Jackson Sheu, Toya Amechi

05/01/2018

GATECH ECE 4180

 

Introduction:

The mini automated greenhouse is designed to make home plant care easier through flexibility and automation. It provides for both manual and scheduled functionalities, such as irrigation and lighting. The greenhouse system also collects, stores and visualizes environmental data. In addition, a web GUI combines all above data and functionalities.

 

Key Features:

1.     Automated and Manual Irrigation: irrigation is done on a schedule unless triggered by dry soil moisture level or manual remote control.

2.     Soil moisture measurement: keep track of moisture level of the soil to trigger or stop irrigation.

3.     Temperature and Humidity measurement: keep track of the greenhouse temperature and humidity level.

4.     Light intensity measurement: measure light intensity received by the plant and trigger the lights to turn on when natural light is insufficient.

 5.     Plant Growth measurement: track the height of the plant.

 

Demo:

https://www.youtube.com/watch?v=RvQbsjxnbIE

Parts List:

·       A Raspberry Pi 3 - https://www.adafruit.com/product/3055

·       Mbed LPC1768 - https://os.mbed.com/platforms/mbed-lpc1768/

·       NeoPixel Stick - https://www.adafruit.com/product/1426

·       Temperature and Humidity sensor (TH02) – https://www.mouser.com/ProductDetail/Seeed-Studio/101020074?qs=sGAEpiMZZMt6ebhnBMWiDGx7DEbjJyM5n589gVHaC6BOMmfoBr%2frXA%3d%3d

·       Water sensor - https://www.mouser.com/ProductDetail/Seeed-Studio/101020018?qs=%2fha2pyFadui6qdzJb%2fTJaS%252brio5eBXMQREY1WG4uDbIsyBQZT1MPeg%3d%3d

·       Light sensor - https://www.mouser.com/ProductDetail/Seeed-Studio/101020030?qs=%2fha2pyFadui6qdzJb%2fTJafx0xzjqbb%2f3eABWjalUs8oliEzoYcD%2fMQ%3d%3d

·       Sonar sensor - https://www.sparkfun.com/products/13959

·       Servo - https://www.adafruit.com/product/155

·       A fish Tanks or a clear case.

·       A Plant

 

Links to Source Code:

Project development code can be found in the following links:

Python source code:  https://github.gatech.edu/tamechi3/4180_Project

Mbed source code:  https://os.mbed.com/users/tamechi3/code/Final_project/

 

Setup Overview:

This guide assumes you are familiar with Raspberry Pi and the Linux environment. Install Raspbian OS on your Raspberry Pi, update, upgrade, and set up as desired.

How the greenhouse works: read-serial.py on the Raspberry Pi sends commands over the serial port to the Mbed to read sensor data. Mbed sends data back over the serial port, which read-serial.py receives and pushes to a MySQL database. App.py (also on the Pi) runs a Flask web server that queries the MySQL database and displays data on the Web GUI. App.py can also send commands to the Mbed to activate the lights or servo for irrigation.

 

Setting up the Web GUI

Our web GUI was created using the Flask framework. First, make sure Flask and other dependencies are installed:

sudo apt-get update

Pip install flask

Pip install serial

sudo apt-get install rpi.gpio

 

Copy app.py into any directory of your choice. Make sure you create subdirectories called /templates to hold the home.html file and /static to hold the Chart.min.js file.

To get the website up and running, navigate to the same directory where app.py is and run:

Python app.py

If successful, you should be able to open the web page in a browser at http://127.0.0.1:5000/

 

Setting up & Configuring the MySQL Database

We use a MySQL database to hold all the sensor data. First, make sure the correct dependencies are installed:

sudo apt-get install mysql-server

pip install mysqlclient

 

Then create your database:

mysql -u root -p

<ENTER YOUR PASSWORD>

CREATE DATABASE sensordata

use sensordata

exit

 

Then create the Data table by running the provided createdatabase.sql script:

mysql -u root -p < createdatabase.sql

 

In the app.py and read-serial.py files, we need to add the credentials for your database. In both files, at the top you will see the following line.

db=MySQLdb.connect(user="root",passwd="<YOURPASSWORD>" ,db="sensordata")

Replace <YOUR PASSWORD> with the password you set for your mySQL database.

Now your database should be set up!

 

Importing the Mbed Code

Import the program from the following link and load the program onto your mbed: https://os.mbed.com/users/tamechi3/code/Final_project/

 

Mbed I/O Wiring: 

NeoPixel

Mbed

NeoPixel

VU

VCC

GND

GND

P5

DIN

Water Sensor

Mbed

Sensor

VOUT

VCC

GND

GND

P15

SIG

Temperature and Humidity Sensor

Mbed

Sensor

VOUT

VCC

GND

GND

SDA

P9

SCL

P10

Light Sensor

Mbed

Sensor

VOUT

VCC

GND

GND

SDA

P28

SCL

P27

Sonar Sensor

Mbed

Sensor

VU

VCC

GND

GND

P6

TRIG

P7

ECHO

Servo

Mbed

Servo

VU

VCC(red)

GND

GND(black)

P24

SIG(white, yellow or orange)

 

Testing the Device

Connect the Pi to the Mbed via a USB cable. Make sure both the Pi and Mbed have their own power supplies. After all wiring and software configuration is set up from the previous sections, run the python programs:

Python app.py

Python read-serial.py

If working correctly, the greenhouse should react to environmental triggers. An easy way to test this is to cover the luminosity sensor and see if the LEDs turn on.

Try navigating to http://127.0.0.1:5000/. You should see the control panel and be able to control the greenhouse with the buttons on the right side (light and irrigation). Note: the GUI will only show up after at least 10 rounds of sensor data measurements have been taken because. This can be altered in app.py.

 

Conclusion

Problems Encountered:

·        The data visualization does not update in real time, even after a page refresh. App.py must be restarted in order for new data to be received.

·        When lights are turned on manually, they turn off almost immediately because they are designed to turn off if the environmental brightness is over  a certain threshold

·        Serial communication between Pi and Mbed was difficult because data would not come in the expected format. Some ugly code on the Pi side was used to parse the incoming data. It’s not very flexible.

Further Work:

·        Use JQuery to enable the data visualization to receive new data

·        Implement a manual operation mode that can override the greenhouse’s automatic system

·        Upgrade the irrigation system with water pump

·        Explore possibility of using Wifi attachment to Mbed to bypass sending data over serial to Pi