University of Regina Faculty of Engineering Electronic System Engineering – ESE Final Year Project Report Project Name: SMART GREENHOUSE Designed by: Amir Baker Mohammad Gasim Supervised by: Dr. Irfan Al-Anbagi Mabior John TABLE OF C ONTENTS Co er page ................................................................................................................................................ Acknowledgement ........................................................................................................................................ Abstract ......................................................................................................................................................... Introduction ................................................................................................................................................... Motivation ................................................................................................................................................. design process ............................................................................................................................................... Methods and Material ............................................................................................................................... Designing the Structure......................................................................................................................... Control Sub-System ...................................................................................................................................... Heating System: ........................................................................................................................................ Components selection: .......................................................................................................................... Logical operation: ................................................................................................................................. Irrigation System:...................................................................................................................................... Components selection: .......................................................................................................................... Logical operation: ................................................................................................................................. Light Subsystem........................................................................................................................................ Component .......................................................................................................................................... Ventilation and Humidity Subsystem...................................................................................................... Component .......................................................................................................................................... Monitoring System...................................................................................................................................... Power ...................................................................................................................................................... Visual feed: ............................................................................................................................................. Data Monitoring:..................................................................................................................................... Data types: .......................................................................................................................................... Communication system:.............................................................................................................................. Commopnent: ...................................................................................................................................... Network configuration: ....................................................................................................................... Web User Interface: SmartGreenhouse.ca .................................................................................................. Set the system time ................................................................................................................................. Customize Environment.......................................................................................................................... View Data Remotely ............................................................................................................................... Change operation mode .......................................................................................................................... Take Images ............................................................................................................................................ User Notification..................................................................................................................................... 1 Results ......................................................................................................................................................... Discussio s .................................................................................................................................................. Co clusio ................................................................................................................................................... Further i pro e e t a d future ork: ..................................................................................................... Appe dix: .................................................................................................................................................... Refere ces................................................................................................................................................... 2 ACKNOWLEDGEMENT Throughout in our project we are very thankful for the support we received from all the members of department of electronic system engineering at University of Regina with your help we make through. We would like to thank and acknowledge: Our supervisor, Dr. Irfan Al-Anbagi we owe you a deepest gratitude for your involvement and concern throughout in our project without your continuous optimism, enthusiasm, encouragement and support this project would hardly have been completed may you continue with the same spirit. The course instructor, Doug Wegner for his continual support throughout the year during our project without your advice it would have been tough for us may you continue to do the job you love the most. Our lab instructor, Dave Duguid we are very grateful for all your advices, knowledge and generosity throughout the years without your lab instructions we would have not finish this project thank you. Finally, we are very thankful to our beloved sister Dr. Samar Baker for her support by offering us all the resources we need to build our prototype (all tools including garage that we used to build the structure in it). 3 ABSTRACT The Smart Greenhouse is prototype implementation of a remotely controlled and monitored greenhouse. Using an Internet of things (IoT) - based communication and control technology the smart greenhouse enables an automatic control of the plants growing environment and enables remote control and monitoring of the plants and the environment. This project utilizes Eleven sensors to read in the environment parameters and monitor the power consumption of the system. For the environment parameters, light condition, inside and outside temperature and humidity, soil moisture and pH level. The sensors are used to control Six actuators. Growing LED lights, heater, water pump, two solenoids, and a ventilation Fan. In the automatic mode the microcontroller will control the status of each actuator based on the sensors. In addition to the monitoring system, a camera is installed inside the greenhouse to provide visual feed. Current sensors were used to calculated the power consumption of each actuator. The greenhouse is connected to a remoted cloud using a wireless communication system. This system is used to stream data for the user to store and view using a web application. In summary, the requirements were to create suitable greenhouse environment, control and monitor the environment, communication system to store data for the user to view. The requirements were successfully achieved, and a remote controller of the greenhouse was implemented that include a web user interface. 4 INTRODUCTION MOTIVATION Building a remotely monitored and controlled Greenhouse which enable users to grow crop while keeping the user inform. Allowing the users to take control of the Greenhouse remotely, manually the users are always face with problem of when is the best time to grow crop and what is the best condition for certain crops. The goal is to implement a system that will allows the users to remotely control all condition necessary for crop grow. The aim was built a working prototype to monitor and control this problem. We call it a Smart Greenhouse because it will operate automatic while control all this condition. This system can be accessed remotely using a web server on any internet connected device. DESIGN PROCESS METHODS AND MATERIAL Several stages were defined to meet the requirements. Designing the Structure to host the environment, designing four control sub-system, integrating a monitoring system, establishing communication via IoT, and developing a web-user interface. DESIGNING THE STRUCTURE In order to contain the environment, a design of a Fully insulated 4-season Greenhouse was selected for this prototype purpose, rescaled to 51”x 48” x 26” inches. (figure 1,2) The structure specification: As one of the requirements, the structure should be built to meet the indoor and outdoor conditions. The structure environment specifications were set to be as following: Temperature range is = -15 to + 20 degrees Celsius The humidity should be above 75 at all times. 5 The design structure indoors (Solid Edge and Keyshot model) The design structure outdoors (Solid Edge and Keyshot model) 6 The structural thermodynamics: In order to maintain a lower power consumption and eventually reduce the cost of growing plants in cold weather the heat loss had to be calculated. The surface area of the upper compartment (the plant place) is = 75 sq. fts The thickness of the wall is uniform and it composed of three layers Assuming the out temperature is -15. Wood insulation wood The layers of the wall. (insulation) The calculation of heat loss was: q= 90.361 Watt [1] This concludes that the heating system is required to generate heat in a higher rate to be able to control the system at the worst case. 7 CONTROL SUB-SYSTEM Subsystems consist of the following: HEATING SYSTEM: COMPONENTS SELECTION: • • Based on the thermal calculation provided [1] the heater rating was selected to be 150W, 12V DC. Sensors: 2x 5V, DHT22, digital humidity and temperature sensor, to measure in/out temperature. LOGICAL OPERATION: The heating system will operate in two different modes, daytime and night time. Each mode corresponds to a specific target temperature. Target Temperature Default Day-time Default Night-time 8:00am ~8:00pm 8:00pm ~8:00am 25-degree Celsius 18-degree Celsius System reset Set up time, day and night temp Day Mode temperature YES Is Daytime? Humidity and temp. Sensor NO Night Mode temperature Save Mode temperature BELOW Below threshold Heater ON sleep If the system is in the Default or Automatic mode: The system will maintain the day time temperature of 25 degrees Celsius and 18 degrees Celsius at night time. The daytime and nighttime are determined by the internal clock of the microcontroller. The system is designed to operate a heater to maintain desired temperatures at daytime and nighttime. 8 IRRIGATION SYSTEM: COMPONENTS SELECTION: • • • • 5W, 12V water pump, 2x 12V Solenoid valves, each one corresponds an area (Area 1, Area 2) 2x Analog Soil Moisture sensor, each one corresponds with an area (Area 1, Area 2) Digital Water tank level switch, detect water level in the water tank. System reset Set up time and soil moisture levels (each area) Read soil moisture (Area A) YES Solenoid A ON Pump ON NO Is Soil Dry? sleep LOGICAL OPERATION: The irrigation system operating in the default modes will respond to the reading of the soil moisture level sensor, if the output voltage of the analog sensor is below 30% of the 3.3 volt then the soil is considered dry. If the output voltage of the sensor is more 70% of the 3.3 volt, the soil is considered wet. When one of the areas is sensed dry, the relays of both water pump and corresponding solenoid will turn ON. They will only turn OFF when the soil is wet. LIGHT SUBSYSTEM The lighting sub-system will determine the need of turning ON and OFF the growing LED lights based on the time and availability of light. when the system is in the daytime, time is between 8.00am ~ 8.00pm the system will be active. When the system is active it will actively check the availability of light using the digital light sensor. when the sensor reads light value to be below 1500 lux at the daytime, which indicates low light condition, then the growing LED lights turns ON. When the sensor reads above 1700 9 lux the grow LED lights turns OFF. the system will be in a sleep mode for the if rest of the day. The system can also be control manual if the user when to let the LED light run longer or turn it off. Availability of light Default Day-time Default Night-time 8:00am ~8:00pm 8:00pm ~8:00am ON/OFF based on lux value Sleep mode System reset Set up time NO Is Daytime? sleep YES Is there enough light? NO YES Grow Light OFF COMPONENT • • 10 Light sensor - GA1A12S202 - Light, Ambient Sensor LED light 12V, Provide between 600 - 800 lux, Red Blue spectrum. Grow Light ON VENTILATION AND HUMIDITY SUBSYSTEM The system is designed to recycle air in the greenhouse and maintain humidity level below 70%. Humidity sensor will read the humidity of the air and if the humidity is greater than 70% the Fan will be turn ON and if less than 70% system sleep. The system will only maintain low humidity. System reset Set up time humidity limit Read humidity level NO sleep YES High Humidity? COMPONENT: • • 11 2x 5V, DHT22, digital humidity and temperature sensor, to measure in/out Humidity. 5V Ventilation Fan, consume 0.5W Fan ON MONITORING SYSTEM The monitoring system monitors the following: 1. Power consumption 2. Visual feed 3. Data monitoring POWER This monitors the power of the system, power consumed by the major component used in the system. These components are: • • • • Heater LED Light Fan Pump The current through each component is measured using current sensor and the current calculated as • P = VI The 4 current sensors will take the current readings and display then on the website for users to read and use it for calculation. The following table display how measure current from sensors was used to calculations power consume by the components. I (measured) P(W) (A) P=VI 12 2.46 29.52 Heater 12 11 132 Fan 5 0.1 0.5 Pump 12 0.32 5.0 Actuator Name Voltage Light Total Power: VISUAL FEED: The system is also equipped with a camera to provide the user with a visual feed THE SPECIFICATION OF THE CAMERA: Resolution: 160x120 Power: 5V, 100mA Communication protocol: 5V Serial TTL, baud rate :9600 [3] 12 167.02 Images size: 50kbyte TTL serial camera The camera is controlled by pre-programmed commands sent by microcontroller. The system is programed to take an image every day. The captured frame is stored in the camera The microcontroller will then send a command to read the frame. And the frame will be sent form the camera to the micro in the serial link (USART), this will take 50 seconds to transmit the full image. DATA MONITORING: The data monitoring system aim to report all the sensors reading to the user with a timestamp. DATA TYPES: • Numerical data: ✓ Temperature in/out. ✓ Humidity in/out. • ✓ Soil pH level. Condition (ON/OFF): ✓ Heater ✓ Light ✓ Fan • 13 ✓ Pump Condition (High/Low): ✓ Water level sensor (Tank) COMMUNICATION SYSTEM: The communication system consists of a radio module that is connected wirelessly to a gateway that is connected to a cloud server. The main purpose of the communication system is to transmit all the data captured by the monitoring system to an accessible server or cloud that the user can access. COMMOPNENT: • • 2x 3.3V Xbee radios module (each is connected to a microcontroller USART port) data rate 250kbps, operating frequency is 2.4GHz [1]. Ethernet/Wi-Fi Digi Gateway, includes an account and cloud storage in devicecloud.com NETWORK CONFIGURATION: • • • • 14 Module mode: AT, transparent mode Pan IP: 1616 Scan Channel: Wi-Fi channels 1, 6,11. Communication protocol: 5V Serial TTL, baud rate :9600 [3] Xbee module Configuration Pre-communication: microcontrollers will be storing all the reading of the sensors in one string (array of characters) this array values will be uprated before every transmission attempt (default: every 1 minute) The communication system operation (two-way communication): Once the network is configured, the data string from both microcontrollers is going to be streamed in the serial terminal USART corresponding to the Xbee radio. Once the Xbee module receives the data string the string will be forwarded to the gateway. The gateway is connected to a modem to via ethernet or Wi-Fi. Once the gateways receive the data it will be stored in the cloud server. The data will be stored in a string format Base64 encrypted to ensure that the data is not lost when the data is stored. Sending data from the gateway to the microcontroller also possible, but in order to establish this connection a python API code needed to be executed. The python code includes the MAC address of the targeted Xbee module and will include massage that is needed to be sent. This feature will allow the user communicate with the greenhouse and command the microcontroller to execute certain commands. However, the user needs a user interface. 15 WEB USER INTERFACE: SMARTGREENHOUSE.CA The main purpose of the web interface is to do the following functions: 1. Setup the system time 2. Customize environment 3. View data remotely 4. Change operation mode 5. Image taking 6. User Notification SET THE SYSTEM TIME Every time the system starts, the microcontroller will reset the timer to 00:00, and in order to reset the clock of the system the time is sent from the gateway to the both Xbee modules and then to microcontrollers. When the system restart, the microcontrollers send a “restart!” message to be stored in the cloud and wait for the time to be sent. In the web interface set a CRON job1 that is set in the C-panal of the website, a PHP code to be executed every fixed period of time elapsed. this PHP code will look at the last string of data, and if it sees “restart!” it will send the time. This page will initiate and execute the python transmission code that will allow the gateway to send the time both microcontrollers through the Xbee modules. CUSTOMIZE ENVIRONMENT After establishing the two-way communication, the user will be able to set their preferred: 1. daytime temperature 2. nighttime temperature 3. Lighting hours VIEW DATA REMOTELY In order to view the data in the website the web user interface is required to: 1 Cron Jobs are used for scheduling tasks to run on the server. 16 1. Fitch the data from the cloud server There are two formats for the data to be fetched, excel file, json file. In the design we have used json file since it is ease to access and manipulate. 2. Decrypt the data All the data stored in the cloud server are encrypted to safely be transmitted without loss. However, to display the data, the fetched string needs to be decrypted using PHP decryption function. 3. Dismantle data Since all the numerical data are sent in one string they need to be decomposed after the decryption. Then every value will be stored separately in a variable. 4. Stored in the database The data will then be added to the database SQL tables, if the data is an image then after decryption it will be saved in a file in the database server and the link will be added to the images SQL table. CHANGE OPERATION MODE After establishing the two-way communication, this function will allow the user to take full control over the greenhouse. The program is to switch the greenhouse operation mode from Automatic to Manual 1. Automatic mode: the actuator will be operating base on sensors reading. 2. Manual mode: the actuator will be operating base on commands sent from the user interface. Logical work flow of the system Manual mode 17 Logical work flow of the system Automatic mode TAKE IMAGES After establishing the two-way communication, the web user interface enables the user to take extra images remotely and in real time. When the user clicks on the “take picture” link, a the takeimage.php page is executed, this will send a command to the microcontroller. The microcontroller then will execute the “take image” routine. The image is then captured, read and send to the Xbee by the microcontroller. The Xbee module will forward the frame to the gateway. The data rate of the camera is slower than the Xbee module which will allow the whole frame to be transmitted without loss. USER NOTIFICATION The user will be notified by email of the following conditions: 1. System restarted 2. System is down 3. Water tank level is low Email Notifications 18 RESULTS In the system we put the real plant to test if the is work after two week the plants group by about the height of 8 cm. This indicate that the system is actual controlling the environment. Heater: The heater was able to rise the temperature from 10 degrees Celsius to 27 degrees Celsius. Base on the test carryout in the garage this heater is capable of maintain the optimal time of 27 degree Celsius. Lighting: LED Light provide 600-800 LUX which is suitable for plant. Plants grow to a considerable height after two weeks and they remain healthy for this duration which indicate that LED light is working as expected. Camera: We were able to to read the images. The were very clear to be used for monitoring. Though the camera resolution was limited and it can be improved by changing camera with the higher resolution. The images were play on the website in real time. Pump were able to irrigate base on the moisture sensor reading. Sensor read the moisture level and it will actuate a relay to turn on the solenoid valve which will turn on the pump. Power measuring: current sensors sense the current and the current readings were recorded. The sensitivity was not great because the sensors are cheap and high sensitivity sensors will be costly. The temperature sensor read the temperature inside and outside of the structure and base on the reading it will actuate the heater. It was test and confirm that it works as required. We were able to see the reading on the website. DISCUSSIONS The system was designed to control the environment inside the greenhouse. The system has to be smart to be able to control the environment inside the greenhouse. Smart means the system can control the environment automatically by sensing the conditions inside the greenhouse and depending on the readings from the sensor, the system will create the suitable environment to grow crops. this was achieved by putting the sensors to control various conditions. One of the conditions was to control the temperature. Temperature sensor used to get in/out reading of the temperature and base on the reading it will turn on or off the heater. The humidity sensor was used to read the humidity in/out if the humidity is more than 70% the Fan will be 19 ON. Moisture sensors will read the soil moisture if it is less than 30% it will turn on the pump to irrigate the soil when it is greater than 70% pump is turn off. CONCLUSION In the end all requirements for this system were achieved and all results were within the expectations. The system can control the environment inside the greenhouse, therefore the user will be provided with information about the environment inside the greenhouse and the daily power consumption of the greenhouse via email and in case of any failure in the system the user will be notified. the benefits of having a smart greenhouse: 1- in case of travelling the system will take of the plants and will keep the user informed about the growth of the plants. 2- if the user has limited experience with planting. the website will lead with more information and will give the user the choice to set the suitable environment as they prefer. 3- the user can grow organic food easily. 4- the user will have an estimate of the power consumption of the smart greenhouse especially with bigger scales. FURTHER IMPROVEMENT AND FUTURE WORK: To improve this system. There are few things can be added to make it smarter and to provide the user with more information about the growth of the plants and wider control of the greenhouse. Those things can provide the user with: 1. The ability of selecting the desired plant from a drop-down menu using the website. this would requires programing all plants environment variables. 2. Camera upgrade: by removing the infrared IR filter a NGB (near infrared, Green, Blue) images can be captured, than processed by the user interface to give an NDVI. The NDVI image can show the amount of the light consumed and reflected which will then determine the posthypnosis and the health of the plant further analysis can also determine ways to improve the plants health. 20 3. Controlling low humidity. Those features can be done by: a. Developing a new page in the website which it has all the information for different type of plants. b. Changing the camera filter to a infrared filter that will take NGB image. This image can be processed by the website to give NDVI image which will allow the user to understand the growth and the health of the plants c. to control low humidity. Humidifier is needed to increase the humidity inside the greenhouse if the humidity is below certain percentage. 21 APPENDIX: Schematics 1,2 Microcontroller 1 [2] 22 Microcontroller 2 [2] 23 CALCULATION: In and out temperature: T0= -15, T3=25; R value for: Wood is 0.19; �= 24 � � �0−�3 + � + � � REFERENCES A. Software Documentation [1] codes https://bitbucket.org/gasim20m/enel400_finalproject B. References [1] Digi Could Kit manual https://www.digi.com/support/productdetail?pid=5605 [2] STM, user manual http://www.st.com/en/microcontrollers/stm32f100rb.html [3] Project page http://www.robotshop.com/letsmakerobots 25