The Design and Realization of Intelligent Greenhouse Control System Based on Cloud Integration

In order to solve the problems of high cost and large input resources of traditional greenhouse management system, this paper designs an intelligent greenhouse management and control system. The core control part of the system uses a cloud integration design architecture chip, based on China’s Alibaba dominated YoC platform to realize the cloud integration design. The end side design with a master control board which using a 485 bus communication, and polling mode was adopted to realize the sensor data acquisition and actuator control; The cloud side creates Topic list on the cloud platform of Internet of things, communicates with the end side through the subscription and publication mechanism of MQTT protocol, and realizes data upload and cloud instruction acquisition. Finally, the function test is carried out in the environment of greenhouse simulation mode.


Introduction
With the improvement of living standards, people have higher and higher requirements on the quality of fruits and vegetables. Greenhouse planting can realize the fine cultivation of plants, which can meet people's requirements. However, greenhouse planting has a high requirement on the indoor environment. It not only requires growers to have certain planting expertise and relevant planting experience, but also requires all-weather monitoring and management of greenhouse [1], which results in excessive greenhouse resource investment, high planting cost and low income for farmers. Therefore, the application of advanced Internet of things technology, intelligent control technology and sensor network technology to greenhouse greenhouse control system has certain practical significance for realizing intelligent greenhouse management [2].
The intelligent greenhouse management and control system collects real-time environmental data information in the greenhouse through various sensors distributed in the greenhouse. Users can set rules such as sensor threshold control, plan execution operation and exception handling on the front-end equipment. The system can realize offline automatic control of the system according to the set rules.

Introduction to Cloud Integration
The collaborative development of end-to-end and cloud is a new trend of IoT technology. In the selection of IoT system chips, we should not only consider the end side, but also consider the application and development on the cloud [3]. Using the cloud integration design, the data can flow efficiently between the cloud side and the end side.
The system uses the YoC (Yun on Chip) platform led by Alibaba, which is a software and hardware platform for the deep integration of cloud based software and chip hardware in the field of IoT, so that cloud technology can support the expansion of chip capability. Through the YoC platform, the whole process of efficient design from chip end to cloud can be realized, and TEE security mechanism combining software and hardware is used to ensure the security and reliability of the system.

Overall Scheme Design of the System
The system is divided into two parts: endside and cloud side, and the two parts are deeply integrated through the YoC platform. As shown in Figure 1, the cloud side includes front-end devices, back-end servers and Internet of things cloud platform. The end side includes core control module, wireless communication module, sensor acquisition control module and actuator control module. The core control module adopts CH2201 Internet of things MCU by T-Head Semiconductor Co. Ltd.
In the cloud side part, through the interaction and control interface on the front-end device, the environmental data in the greenhouse and the rule information such as setting sensor threshold control, plan execution operation and exception handling are displayed on the front-end device. The IoT cloud platform processes and forwards the data, authenticates the end-to-side chips, subscribes to the status data of sensors and actuators from the chip, classifies and analyzes the data, and then transmits it to the back-end server.
On the end side, the core control module is connected with wireless communication module, sensor acquisition control module and actuator control module. The module controls the wireless communication module and the security transmission channel established by the Internet of things cloud platform through the end cloud integrated chip control wireless communication module, and controls the sensor acquisition control module and actuator control module according to the rule information set in the cloud side.

End Side Hardware Circuit Design
In order to reduce the system coupling, increase the system reliability, and facilitate the system to increase or decrease the configuration of sensors and actuators, the sensor acquisition control module and actuator control module adopt the form of master control board and slave board to complete environmental data acquisition and actuator control, as shown in Figure 2.The core control module is connected with acquisition main control board and executive control board through RS232 serial port communication interface. RS485 serial communication mode is adopted between master control board and slave board.

Hardware Circuit Design of Core Control Module
The core control module is mainly composed of main control chip, GPIO circuit related to indicator light and key, YoC interface circuit connecting wireless communication module, JTAG program download and debugging circuit, serial port circuit and power supply for connecting sensor acquisition control module and actuator control module, and other related peripheral circuits. The hardware circuit design of core control module is shown in Figure 3.
The distance between the core control module, the sensor acquisition control module and the actuator control module is relatively close, there is no long-distance transmission, and the signal interference is small. Therefore, the core control module carries out high-speed asynchronous

Hardware Circuit Design of Sensor Acquisition and Control Module
In order to shield the difference of different types of sensor hardware interfaces and reduce the coupling and complexity of the system, this module adopts the form of master control board and slave board, and the core control module issues the acquisition control scheme to the acquisition master control board. The main control board polls controls each sensor to collect data from the simultaneous interpreting board, and collects the slave board to control data acquisition by IIC, SPI, UART and ADC according to different types of hardware interface types, and then collects data to the main control panel. The hardware circuit design of sensor acquisition control module is shown in Figure 4.

Hardware Circuit Design of Actuator Control Module
The hardware circuit design of the actuator control module is shown in Figure 5. The communication mode between the executive master control board and the executive slave board of the module is similar to the above sensor acquisition control module. However, each actuator, such as sunshade roller shutter motor, irrigation control motor, lighting, ventilation fan, ventilation window control motor, etc., belong to strong current equipment and need to be controlled by means of relay, motor drive board, etc., so the executive slave board needs to be controlled by PWM, GPIO, etc.

Data Frame Structure Definition
The communication between the core control module and the acquisition main control board and the executive main control board, the acquisition main control board and each acquisition slave board, the executive main control board and each executive slave board, adopts the user-defined data frame structure. On the basis of reference [5][6], this paper simplifies the frame protocol structure according to the actual situation of the system, as shown in Figure 6. End of frame Figure 6. Schematic diagram of data frame structure 1) Frame head: length is 2Bit, fixed value is 0xaa55; 2) Destination device ID: length 1Bit, When the ID number is 0-254, it represents the query frame sent by the motherboard to the slave board, and the ID number is the slave board number; When the ID number is 255, it represents the return frame sent from the slave board receiving the query frame to the motherboard; 3) Data frame length: the length is 1Bit, indicating the number of bytes of the data frame; 4) Data field: the length is 1-255Bit, and the content is the data to be transmitted; 5) End of frame: the length is 2Bit, and the content is the check sum.

Software Design of Core Control Module
The software design of the core control module mainly includes system initialization, data reporting event processing, cloud command issuing event processing, serial data sending and serial data receiving. The core control module receives the data frame from the acquisition main control board through UART interrupt, analyzes and reports the received data frame to the cloud. After receiving the command information sent by the cloud, the module processes it and sends it to the executive main control board through serial port.
Data reporting events and cloud command issuing events are based on the publish and subscribe mechanism of MQTT protocol [7]. Through the Topic list created by the Internet of things cloud platform, the data message transmission between the end side and the cloud side is realized. The cloud command issuing event is obtained through the YoC SDK subscription. Data reporting events release sensor acquisition and system status to the corresponding Topic of cloud platform through YoC SDK.

System Testing
The system is running and functional tested in the greenhouse simulation model environment. The hardware circuit of the system is shown in Figure 7.