Pi in the Sky: A Sustainable, Web-based, Automated Greenhouse

Maisie Cottrill

Age 14 | Tara, Ontario

Canada-Wide Science Fair 2019 Excellence Award: Junior Silver Medal 

Western University $2000 Entrance Scholarship


Introduction

Greenhouses provide increased productivity, reduced pesticide usage, and protection from exterior dangers (Vox et al., 2010). Greenhouse automation technologies have the capability to produce an abundance of top quality plants and the potential to use carbon dioxide, water, fertilizer, and other inputs with increased efficiency (Ehret, 2001). Basic automated systems revolve around timing control, where actuators are operated on a timed schedule (Pawlowski et al., 2009). In contrast, event-based control systems strive to maintain environmental variables in a desired range, between minimum and maximum set points, and control actuators from the feedback of sensors (Pawlowski et al., 2009). Artificial neural networks and genetic algorithms are more complex control systems that have also been implemented into many greenhouse environments (Soto-Zarazúa et al., 2011). These systems often lack user compatibility and cost-efficiency and require an experienced grower to manage the system (Soto-Zarazúa et al., 2011). This project investigates the possibility of using a web-based greenhouse utilizing an event-based control system. It required the user to have little prior knowledge of agriculture to operate it effectively.

PREVIOUS WORK

An automated greenhouse was created last year using a Raspberry Pi to monitor and control temperature and moisture levels. This automated greenhouse was tested against a manual greenhouse and an uncovered manual tray to ascertain which environment produced the highest yield and the best quality crop. A total of four 14 day trials were conducted with eight bean seeds planted in each of the environments. The temperature, humidity, and soil moisture of each

environment was logged through sensors. This experiment concluded that the automated and manual greenhouses yielded approximately the same amount of produce. However, the automated greenhouse had several limitations. It was connected to a wall outlet for power with no backup power source. The greenhouse could not be remotely monitored or controlled, and the web app could only be viewed on the localhost server. 

PURPOSE

The purpose of this project was to develop a self-contained, solar-powered, automated greenhouse system that could be monitored and controlled remotely.

MATERIALS

A homemade 60 by 45 centimetre (cm) greenhouse was constructed using 2 millimetre (mm) acrylic and 16 mm plywood. An Arduino Uno Rev3 and a Raspberry Pi 3 Model B were used to automate the greenhouse. The sensors that were used included an AM2302 Temperature and Humidity sensor, a DF Robot Soil Moisture sensor, an eTape 30 cm water level sensor, and a Tinkerkit LDR sensor module. The sensors were connected to a Tinkerkit Sensor Shield V2 using jumper wires. Two breadboards were used to connect a 5-volt (V) fan, a car door lock actuator, and a windshield washer fluid pump to a 4 Channel DC 5V Relay Module. The energy source for this prototype was created using two 6V lantern batteries, two 25-watt solar panels, a solar charge controller, and a deep cycle battery, a 12V socket with battery clips, and a micro USB car charger. A Raspberry Pi camera module V2 was also used. 

PROCEDURES

Setting Up the Energy Source: An important design criterion for this prototype was to be entirely self-sufficient with minimal environmental impacts. This was accomplished with solar panels wired in a parallel circuit. Any additional power that was collected was stored in a battery using a solar charge controller. The 12V socket and the micro USB car charger were used to connect the battery to the Raspberry Pi and converted the 12V from the battery to 5V that was needed to run the Raspberry Pi. Two 6 V lantern batteries were wired in series and were used as an external power source for the relay that assisted in operating the actuators.

Setting up the Database: All of the data collected by the sensors and configuration settings for the application were stored in four tables in a SQLite database on the Raspberry Pi.

Programming: The greenhouse was controlled from a Python script and an Arduino sketch. Code modified from (“Serial Input Basics -updated”, 2016) and (DiCola, 2014) was used in the Arduino sketch, in addition to the DHT library (https://github.com/adafruit/DHT-sensor-library) and the Tinkerkit library (https://github.com/TinkerKit/TinkerKit). The Python script contain code modified from many sources to provide various features. The code for serial communication with the Arduino was inspired by “Pyduino, Interfacing Arduino with Python through Serial Communication” (n.d.). The Flask library (http://flask.pocoo.org/) was used to create the web app. Sections of the web app were restricted to authenticated users only with the help of the FlaskLogin library (https://flask-login.readthedocs.io/en/latest/). The SMTP library (https://docs.python.org/3/library/smtplib.html) and code from (de Langen, 2018) was used to create email alerts that were sent periodically when errors occurred within the greenhouse. The live video feed was established using code from Grinberg (2014, 2017). The HTML template included the Bootstrap (https://getbootstrap.com/), and plotly.js (https://plot.ly/javascript/) libraries, as well as code modified from “HTML Forms” (n.d.).

RESULTS

The prototype was fully automated and operational. The Raspberry Pi and the Arduino communicated through the serial. The Arduino received the sensor readings every 10 minutes for temperature, humidity, light, water level, and soil moisture. These readings were then sent through the serial to the Python script where the values were written to the “sensor_data” table in the  SQLite database. The readings were evaluated to determine whether the greenhouse needed to be cooled or heated, or the plants needed to be watered. If action was needed, the Python script sent an appropriate message to the Arduino, and the Arduino executed the task. The interface for the greenhouse was an HTML home page that displayed interactive graphs showing the sensor data, a web camera to remotely view the occurrences in the greenhouse, and the current settings and status of the fan, pump, and vent. The data for the graphs was supplied by a secondary URL that returned the sensor readings in Javascript Object Notation (JSON) format after the page loaded. The Raspberry Pi monitored greenhouse conditions and alerted the user through an email notification if an important event occurred, such as the water reservoir being empty, the absence of sensor readings, or a set period of time elapsing without watering. The web page also featured a login element which gave the authenticated user the ability to remotely control the settings, activate or deactivate any of the actuators, and view the greenhouse through the live video feed. In order to provide the live video feed, the Flask server streamed a series of individual JPEG images. The video feed could then be viewed through a separate route of the web app. The prototype was powered exclusively using solar panels and operated independently for more than a month.

CONCLUSION

A solar-powered, automated greenhouse that could be monitored and controlled remotely over the web was successfully designed and created. This innovation has the potential to be used for commercial applications, as well as for the average person to grow their own fresh produce at home. It opens new doors in the future for minimizing the environmental impacts of agriculture, by reducing greenhouse gas emissions from the production, transportation of produce, and processing of growing materials. The negative environmental effects could be reduced further through the use of a rain water collection and filtration system, a biodegradable covering material.

APPLICATIONS

This web-based, environmentally sustainable prototype is intended for use by the general public to produce their own food and has potential to be expanded on an industrial scale. This is important because it is predicted that 1.8 - 2.4% of agricultural land is going to be lost to urbanization by 2030, and additional land will be lost as result of improper land management (Charles, 2010). The world population is expected to increase to 9.7 billion people by 2050 so it is very likely that the world will need 70 to 100% more food to provide everyone with enough to eat (Charles, 2010). This means that the impending global demand for food requires an increase of produce that will need to come from the same amount, or potentially less land than today (Charles, 2010). This innovation could have applications in producing nutritious food from land that is not dedicated to agriculture or in remote or under-developed areas since it operates off the grid. 

ACKNOWLEDGEMENTS

Thanks to Anji, Adam, and Sophia Cottrill, and Brad and Patti-Jo Lacey for their assistance and support throughout the creation of this project.

REFERENCES

Articles

Charles, H., Godfray, J., Beddington, J. R., Crute, I. R., Haddad, L., Lawrence, D., . . . Toulmin, C. (2010, February). Food Security: The Challenge of Feeding 9 Billion People. Science, 327, 812-818. Retrieved from https://science.sciencemag.org/

Ehret, D., Lau, A., Bittman, S., Lin, W., & Shelford, T. (2001). Automated monitoring of greenhouse crops. Agronomie, EDP Sciences, 21(4), 403-414. Retrieved from https://hal.archives-ouvertes.fr/

Khor, M. (2009). The Food Crisis, Climate Change, and The Importance of Sustainable Agriculture. Retrieved from http://citeseerx.ist.psu.edu/index

Myers, S.S., Smith, M. R., Guth, S., Golden, C. D., Vaitla, B., Dangour, A. D., & Huybers, P. (2017). Climate Change and Global Food Systems: Potential Impacts on Food Security and Undernutrition. Annual review of public health, 38, 259-277. Retrieved from: https://www.annualreviews.org/

Pawlowski, A., Guzman, J. L., Rodriguez, F., Berenguel, M., Sáchez, J., & Dormido, S. (2009, January). Simulation of Greenhouse Climate Monitoring and Control with Wireless Sensor Network and Event-Based Control. Sensors, 9(1), 232–252. Retrieved from https://www.mdpi.com/

Shamshiri, R., & Ismail, W. (2013, September). A Review of Greenhouse Climate Control and Automation Systems in Tropical Regions. Journal of Agricultural Science and Applications, 2(3), 176-183. Retrieved from https://www.researchgate.net/ 

Soto-Zarazúa, G. M., Archuleta-Romero B. A., Mercado-Luna, A., Toledano-Ayala, M., Rico-Garcia, E., Peniche-Vera, R. R., & Herrera-Ruiz, G. (2011). Trends in Automated Systems Development for Greenhouse Horticulture. International Journal of Agricultural Research, 6(1), 1-9. Retrieved from https://www.researchgate.net

Vox, G., Teitel, M., Pardossi, A., Minuto, A., Tinivella, F., & Schettini, E. (2012). Sustainable Greenhouse Systems. Sustainable Agriculture: Technology, Planning and Management, 1-80. Retrieved from https://www.researchgate.net

Webpages

DiCola, T. (2014, April). Smart Measuring Cup. Retrieved from https://learn.adafruit.com/smart-measuring-cup/hardware#assembly

de Langen, J. (2018, December). Sending Emails with Python. Retrieved from https://realpython.com/python-send-email/

Grinberg, M. (2014, October). Video Streaming with Flask. Retrieved fromhttps://blog.miguelgrinberg.com/post/flask-video-streaming-revisited

Grinberg, M. (2017, August). Flask Video Streaming Revisited. Retrieved from https://blog.miguelgrinberg.com/post/video-streaming-with-flask

HTML forms. (n.d.). Retrieved from https://www.w3schools.com/html/html forms.asp

Pyduino, Interfacing Arduino with Python through Serial Communication. (n.d.). Retrieved from https://www.instructables.com/id/Pyduino-Interfacing-Arduino-with-Python-through-se/

Serial Input Basics -updated. (2016, April). Retrieved from https://forum.arduino.cc/index.php?topic=396450.0


BIBLIOGRAPHY

Articles

Vourdoubas, J. (2015, June). Possibilities of Using Renewable Energy Sources for Covering all the Energy Needs of Agricultural Greenhouses. Journal of Agriculture and Life Sciences, 2, 111-118. Retrieved from http://jalsnet.com

Webpages

Controlling a Pc fan with Arduino. (n.d.). Retrieved from http://forum.arduino.cc/index.php?topic=17944.0

Controlling an Arduino With Python Based Web API. (n.d.) Retrieved from https://www.instructables.com/id/Controlling-Arduino-with-python-based-web-API-No/p

Components of the Greenhouse System for the Environmental Control. (n.d.). Retrieved from https://www1.agric.gov.ab.ca/$department/deptdocs.nsf/all/opp2891 D3.js based Time Series in Plotly.js. (n.d.). Retrieved from https://plot.ly/javascript/time-series/

Getting Started with picamera. (n.d.). Retrieved from https://projects.raspberrypi.org/en/projects/getting-started-with-picamera

Liang, O. (2013). Connect Raspberry Pi and Arduino with Serial USB Cable. OscarLiang.com. Retrieved from https://oscarliang.com/connect-raspberry-pi-and-arduino-usb-cable/

Management of the Greenhouse Environment. (n.d.). Retrieved from https://www1.agric.gov.ab.ca/$department/deptdocs.nsf/all/opp2902

Pullen, T. (2018, June). How to Store Solar Power. Retrieved from https://www.homebuilding.co.uk/how-to-store-solar-power/

Torres, A. (2013). Introduction to SQLite in Python. Retrieved from https://www.pythoncentral.io/introduction-to-sqlite-in-python/

Books

Dale, K. (2016). Data visualization with Python and JavaScript: Scrape, clean, explore & transform your data. Sebastopol, CA: O’Reilly & Associates.


MAISIE COTTRILL

article-photo.jpg

My name is Maisie Cottrill. I am a grade nine student at Owen Sound District Secondary School. Since I was young, science has been my passion. As a child, I was curious about how things worked. As I got older, my curiosity became the inspiration for my science fair projects. To date, I have completed four science fair projects, competed at the Canada Wide Science Fair twice and earned two silver medals. Recently I attended the MILSET Expo-Sciences International in Abu Dhabi, UAE. In the future, I intend to pursue my interest in science throughout my postsecondary education and career.