Research Article Intelligent Spraying Water Based on the Internet of Orchard Things and Fuzzy PID Algorithms

During the fruit ripening period, the orchard temperature di ﬀ erence between day and night has a substantial impact on the fruit quality, and it is not easy to be controlled like that of in greenhouse, this paper designed the smart orchard Internet of Things (IoT), through the fuzzy PID (Proportion-Integration-Di ﬀ erentiation) algorithm to control the water spraying to adjust the temperature di ﬀ erence Δ T between day and night in the orchard, intelligently in ﬂ uenced the orchard energy conversion process, and promoted the fruit sugar accumulation. Experiments show that the maximum Δ T can reach 20 ° C, the intelligent energy regulation based on the IoT has a good e ﬀ ect, and a scheme to intervene the microclimate in farmland (quite di ﬀ erent from the greenhouse environment) is provided.


Introduction
As we all know, the growth of crops is a process of energy transfer and transformation. Through photosynthesis, solar energy is converted into chemical energy and stored in crops and fruits. With the development of smart agriculture, artificial management of energy conversion conditions in the growth process of crops to promote crop better growth has always been a research focus. For example, promoting the improvement of fruit quality in orchards is worth exploring. The Internet of Things (IoT) is the fourth information revolution after computers, the Internet, and mobile communication technologies. Since 1999, the Massachusetts Institute of Technology introduced the concept to major countries in the world such as the United States. Smart Planet, the European Union made the Internet of Things Action Plan in 2009, China proposed the sensing China and made the Internet of Things one of the strategic emerging industries [1][2][3][4].
At present, the Internet of Things has been applied to various fields such as transportation, medical treatment, industry, and military. In agriculture, various sensing terminals such as radio frequency identification (RFID), sensors, and visual devices have been used to comprehensively sense collection facilities, environmental information of production processes such as field planting, breeding, etc. to gradually achieve the optimal control, and intelligent management of agricultural production processes [5].
Among them, the Orchard Internet of Things mainly is used, detects and communicates related data such as soil, temperature, light, weather, and insect pests in the orchard environment, and can carry out independent irrigation, integrated water and fertilizer management, and insect forecasting, which improves the orchard information level, management efficiency, and fruit yield [6][7][8][9][10].
Nowadays, fuzzy PID control technology has been widely used in orchards because of its fast response speed, no overshoot, almost no shock, and high control precision [11,12]. First, aiming at pest control in orchards, it is used for chemical pesticide spray operation. Combined with precision target technology and variable air spray technology, it improves the precision of fruit trees' air spray and achieves the effect of precision application p [13][14][15][16]. Second, together with the orchard Internet of things to achieve intelligent irrigation, water saving effect [17,18]. Third, it is used to control the intelligent lighting in orchard and improve the appearance quality of fruit [19,20].
However, China as the biggest fruit production of the world, Chinese fruits also have problems such as low sugar content [21]. As for the sugar content of fruits, according to the literature [22][23][24][25], during fruit growth, carbohydrates are produced during the day of photosynthesis. Under the same conditions as water and fertilizer, high temperatures can enhance photosynthesis to produce more carbohydrates; these carbohydrates are converted into sugars at night. Temperature is the main factor affecting sugar conversion, which is the temperature difference between day and night. The greater the temperature difference between day and night, the more favourable the sugar conversion is, and the sweetness of the fruit is higher.
In the northern plains of China, popular fruits such as apples, strawberries, peaches, and pears generally start to accumulate sugar during the summer fruit ripening period, but the temperature difference in the northern plains is not as large as in Xinjiang and other regions.
Based on the key factors that affect the sugar content of fruit during the fruit growth process, this article proposed an IoT system with the function of regulating in the peach orchard during the ripening period, using fuzzy PID to control the mist sprayer to spray 16°C water to reduce the night temperature of the orchard, increase the temperature difference, and weaken the respiration of the fruit tree, which is beneficial to promote sugar conversion and fruit expansion and improve fruit quality. The expected contributions are as the following: (1) The ambient temperature of the orchard at night can be effectively reduced, and the maximum temperature reduction range can reach 10°C so that the day-night temperature difference of the orchard on that day can reach 20°C. According to the literature [21], it can be known that the orchard's breathing effect can be better suppressed, which is beneficial to the orchard organic matter accumulation and sugar conversion, increasing the sugar content and dry matter content (2) The misting operation increases the environmental humidity during the orchard fruit ripening period.
According to the literature [26][27][28][29][30], it is helpful to promote fruit expansion and increase orchard yield (3) The system can meet the actual needs of orchard data collection and control in terms of signal transmission quality, network stability, data collection timeliness, and system power consumption. Comparing with the literature [7], the development cost is reduced, and the orchard can be realized. Remote real-time monitoring (4) Fuzzy PID algorithm effectively controls the intensity of mist and achieves water conservation. This system is of positive significance for promoting the informatization and development of orchards in temperate plains and improving fruit quality and yield

Materials and Methods
The materials and methods section should contain sufficient detail so that all procedures can be repeated. It may be divided into headed subsections if several methods are described.

Principle and Process of Temperature Difference
Regulation in Orchard. Photosynthesis and respiration occur simultaneously in cells of green plants such as fruit trees. During the day, photosynthesis is the main process because the light intensity and the temperature are high. During the photosynthesis process, the chloroplast in the cell synthesizes solar energy, CO 2 , H 2 O, and other organic matter, stores energy, and releases O 2 . At night, the light intensity is small, and the respiration is stronger than photosynthesis. Cell mitochondria decompose organic matter produced by photosynthesis and release energy and oxygen. Respiratory effects include aerobic and anaerobic respiration.
Studies have shown that [21] photosynthetic intensity (also called photosynthetic rate) is affected by light intensity, temperature, CO 2 concentration, etc.; under light conditions, photosynthesis starts under enzyme catalysis, and temperature directly affects enzyme activity. General plants normally perform photosynthesis at 10°C to 35°C. The range of 10°C to 35°C gradually increases with increasing temperature. Photosynthetic enzyme activity decreases above 35°C, and photosynthesis begins to decline. Photosynthesis at 40°C to 50°C, effect is almost completely stopped; the main influencing factor of respiration is temperature. The higher the temperature, the stronger the respiration. Respiration is the strongest at the optimal temperature (25°C~35°C); above the optimal temperature, the enzyme activity decreases, even degeneration and inactivation, and the breathing is suppressed; below the optimal temperature, the enzyme activity decreases and the breathing is suppressed.
In China, summer is the main period of fruit growth, high temperature during the day, strong photosynthesis, and produced more organic matter; the low temperature at night, weak respiration, and less organic matter decomposed. Therefore, more organic matter accumulated in the photosynthesis of plants than organic matter consumed by respiration, accumulated in the body, increase in organic matter results in particularly sweet fruits, so "where the temperature difference between day and night is particularly sweet and delicious," the scientific explanation is that photosynthesis will increase when the temperature is appropriately high, and the respiration will weaken and decompose when the temperature is low. Fewer organics are good for organics accumulation. It can be seen that increasing the temperature difference between day and night can increase the sugar content of fruits.
In the summer of temperate plains, temperatures are high during the day and fruits accumulate nutrients. At night, the ambient temperature drops, however, in general, declines less, and the decline rate is slower. Therefore, the mist cooling method can be used to accelerate the reduction of the ambient temperature. In summer, the sun enters the sunset point relatively late. To make full use of the photosynthesis of fruit trees after sunset, under nonrainfall conditions, it is generally chosen to spray the water misting in the orchard at 8 : 00 pm every day. According to the wind direction collected by the wind direction sensor, the data centre transmits the command to the sprayer node through LoRa, adjusts the direction of the sprayer nozzle, and sprays the water mist. The spray distance varies from 5 to 100 m, and the height is 2 meters above the fruit tree. Multiple mist dispensers form a mist of water covering the entire orchard. Misty time lasted until 4 : 00 in the morning. The water in the well is less affected by the ground temperature and is maintained at about 16°C throughout the year. The local summer temperature averages 30°C, so water mist can quickly reduce the ambient temperature of the orchard to below 20°C, which can reduce the night-time temperature of the orchard by 10°C in a short time.

Orchard IoT for Temperature Difference Regulation.
The proposed orchard IoT scheme is shown in Figure 1. The basic functions include collection of orchard environmental information, soil temperature, soil pH, soil humidity, carbon dioxide, CO 2 concentration, air temperature and humidity, light intensity, wind speed and direction, rainfall, etc.; monitoring fruit tree pests by hyperspectral sensors; and remote monitoring achieved on computer or smartphone device [6][7][8].
According to the three-layer basic architecture of the Internet of Things: the sensing layer, the transmission layer, and the application layer; the sensing layer contains 4 types of sensor nodes and 2 types of actuator nodes. The sensor node mainly implements the orchard information collection. Actuator node 1 completes automatic orchard irrigation. Actuator 2 reduces the ambient temperature of the orchard at night by spraying the mist and increases the temperature difference between day and night in the summer. Water mist is conducive to fruit expansion after the fruit enters the expansion stage [21].
The basic composition of a sensor node is a sensor, an ARM microcontroller, and LoRa module; the basic composition of an actuator node is a relay, ARM microcontroller, and LoRa module.
The ARM microcontroller is a low power, highperformance embedded system as the node control core. It is an MCU based on the STM32 F401 series ARM® Cortex™-M4. It has a 12-bit ADC and a 16-bit/32-bit timer. To reduce costs, each node is provided with several related sensors. To control the day and night temperature difference of the orchard, sensor node 2 collects four orchard meteorological parameters such as air temperature, humidity, CO 2 , and light intensity, and actuator node 1 executes the relevant commands sent by the data centre. Sensors/ transducers utilized in the internet of orchard things are shown in Figures 2(a)-2(g).
Sensor node 2 can measure four parameters: air temperature, relative humidity, CO 2 concentration, and illumination.

Journal of Sensors
The measurement range and accuracy of the four parameters are air temperature −30~70 ± 0:2°C; relative humidity, 0~100%RH ± 3%RH; carbon dioxide concentration 01 0000 ppm ðoptional 2000, 5000 ppmÞ ± 20 ppm; and light intensity 0~200 k lx ðoptional 2 k, 20 k lx and other rangesÞ ± 3%. In the North China Plain area, under normal conditions, the illuminance under strong sunlight in summer is 100,000 lx (3 to 300,000 lx). It is 10,000 lx, and the intensity of sunrise and sunset lights is 300-400 lx. Sensor node 4 is used to collect wind speed/direction and rainfall and provides a decision basis for temperature difference control.
The wind sensor for collecting 16 directions including east, west, south, north, southeast, southwest, northeast, and northwest. The voltage signal output is 0~2 V, and the comprehensive voltage accuracy is ±2%. Three bulk sensor measurement. Measuring range: 0~30 m/s, 0~60 m/s, response time is less than 1S, start-up wind is 0.4~0.8 m/s, and power supply voltage is 12~24 VDC.
A dump bucket rain sensor is used for detecting the rainfall, its range of rain intensity is 0.01 mm~4 mm/min (the maximum rain intensity allowed is 8 mm/min), and the measurement accuracy is ≤ ±3%.
The transmission layer is mainly composed of wireless transmission modules and gateways, and each sensor and actuator node contains a wireless transmission module LoRa (long range). Wireless transmission can avoid the difficulty of wired communication in the orchard and prevent the line from affecting the operation of the orchard. There are many wireless transmission methods. Commonly used ZigBee, Bluetooth, Wi-Fi, etc. and their transmission distances are relatively short. Orchard data centres are generally located in urban areas with good environmental conditions. For complex orchards in the field, WSN (wireless sensor network) has high cost and complicated networks.
In comprehensive consideration, the LoRa [16][17][18] was used because of its excellent performance of long-distance,   Journal of Sensors large capacity, low power consumption, and other characteristics., which is one of the low power wide area networks LPWAN (low power wide area network) technology. Here, the LoRa module is SX1278 with 433 MHz and spread spectrum technology. Its communication interface is RS232/485, 9600 Baud (1200~115200 Baud), and 5W12V (10~28 V). Gateway LoRa and each node LoRa form a star topology, structure of the transmission network, and the transmission distance is up to 20 km, which meets the 12 km distance between the orchard and the data centre, reducing the data transmission costs. The application layer is the data centre of the Internet of Orchard Things. The central database is configured with MySQL, which can store data, analyse, visualize, and make decisions. The data collected by the sensors is transmitted to the gateway through the LoRa wireless transmission module and sent to the data centre. The control command of the centre is passed to the LoRa module through the gateway and realizes automatic irrigation and fogging operations.
Various device nodes, such as sensor nodes, irrigation nodes, and spraying actuator nodes, all use LoRa's free networking technology, which can also easily implement single control and centralized management of each node of the system. At the same time, the convenience and practicability of LoRa free networking greatly save the development cycle and reduce the system development cost and difficulty.

System Software
Based on the function analysis of the orchard IoT, the system consists of 7 parts: parameter collection, irrigation, spraying, mist, insect analysis, data server, and mobile clients. The application layer uses Baidu Cloud Server as the cloud server with the open-source GNU/Linux operating system Ubuntu and the E-Chart visualization tools. The display can ensure the normal operation of the orchard's data access, data storage, and visual display programs; 3.1. The Flow Chart of the Sensor Collection. There are many types of sensors in this system. Here, only the basic process of temperature sensor collecting temperature is given, and the temperature data is mainly used to judge whether to carry out water spray. The flow chart of the sensor collection is shown in Figure 3.

Mist Spraying Operation
Procedure. Spray subroutine is mainly used to control spraying water mist to realize orchard cooling. When the ambient temperature of the orchard is higher than 20 degrees, the spray will be started, and the direction of the nozzle can be adjusted according to the wind direction to achieve the optimal spray effect. Mist spraying operation procedure flow is shown in Figure 4.

Fuzzy PID Algorithm.
To adjust the temperature difference according to the night temperature with high efficiency and save water, the algorithm of fuzzy PID for spraying is shown in Figure 5.
The fuzzy PID controller is mainly composed of a fuzzy controller and an adjustable PID controller. The input of the fuzzy controller is the deviation between the measured temperature value t1 of the sensor and the set target temperature value t0 and the deviation change rate. The output is the three input correction parameters of the PID controller where uðtÞ is output of the system at time t; K p is the proportional coefficient; K i is the integral coefficient; K d is the differential coefficient. The fuzzy PID control effect is better when set the K p , K i , K d initial value as fK p0 , K i0 , K d0 g = f16, 0:4, 0:07g, and K p ∈ ½10, 18, K i ∈ ½0, 1, K d ∈ ½0, 0:15.

Results and Discussion
The experiment site and conditions: WH Agricultural Fruit Planting Cooperative Peach Orchard, with an area of 1hm2, and an Internet of orchard Things. There is a selfuse well in the orchard with a depth of 30 meters. The test time is summer 2018-07-20, and the weather conditions are sunny, temperature 37°C~28°C, south wind 3-4 level. The water temperature of the well is 16°C. Mist spraying machine parameters: electric high-pressure remote sprayer, rated flow: 30-40 L/min; adjustable working pressure: 10-40 MPa; horizontal range: up to 100 M. The spray apparatus and effect are shown in Figures 6(a)-6(c).
The pumping device draws water out of the well at a temperature of 16 degrees and then feeds it into a tank, which is pressurized and then sprayed from nozzles at different locations in the orchard, and the water mist could cover the whole orchard and cool it down. 20   Journal of Sensors There are five sprayers, one at each corner of the orchard and the centre. The plot according to the temperature data is shown in Figure 7.
It can be seen from Figure 7 that during the misting operation of the orchard, the ambient temperature in the orchard is reduced by a maximum of 10°C compared with the temperature outside the orchard, and the cooling effect is obvious. Compared with the maximum temperature of 37°C during the day, the temperature difference between day and night reaches 20°C. According to the literature, the respiration of the fruit, tree, leaves, and fruit in the orchard will be significantly weakened compared with that without misting operation, which is beneficial to the sugar conversion and organic matter accumulation of the fruit. There are differences in the data measured by the three sets of sensors, mainly due to the different installation locations. The south wind is not good for cooling the southern part of the orchard. The north side of the orchard is affected by the wind, the concentration of water mist is greater, and the temperature drop is slightly larger than the south. After finishing the misting operation at 4 : 30 in the morning, the temperature of the orchard began to rise.
NLE-AI800 development board and 5-million-pixel camera were used as image acquisition equipment to construct fruit size measuring instrument. The system supports Linux/Ubuntu-Server, and Ros system supports ROS-core. CPU: dual-core A73+ dual-core A53+ single-core A53; storage: 4 GB RAM, 32 GB storage space; AI computing unit: dual core NNIE@840 MHz, 4.0TFLOPTS computing power. HMI display device touch screen, camera: Python3.6.7 environment and PyCharm2020.1.1 VERSION of IDE, as well as plug-ins.
In order to verify the fruit sweetness and expansion effect, one peach from each of the 5 peach trees in the experimental orchard was selected, with the numbers P1~P5, respectively; at the same time, select 5 peach trees of the same variety in the nearby orchard, and numbered C1~C5. Measure once every three days at 3 : 00 p.m. and for five consecutive times. The measured fruit size and sweetness data are shown in Tables 1 and 2, and Table 3 is for data comparison results.
It can be seen from Table 3 that there is little difference between the initial average sweetness and the size of the fruit. But after the experiment, there is a significant difference between the size and sweetness of the fruit, which verifies the effectiveness of the designed method.

Conclusions
The Internet of orchard Things was designed and implemented by comprehensively utilizing multiple types of  7 Journal of Sensors sensors and LoRa, and a temperature difference control experiment was carried out in the peach orchard. The fuzzy PID was used to perform spraying water of constant 16°C in a peach orchard in the ripening period. The main results are as follows: (1) The ambient temperature of the orchard at night can be effectively reduced, and the maximum temperature reduction range can reach 10°C so that the day-night temperature difference of the orchard on that day can reach 20°C, which is beneficial to the orchard organic matter accumulation and sugar conversion, increasing the sugar content and dry matter content (2) The misting operation is helpful to promote fruit expansion and increase orchard yield (3) The system development cost is reduced, and the orchard can be realized. Remote real-time monitoring (4) Fuzzy PID algorithm effectively controls the intensity of mist precisely for achieving water conservation, furthermore, useful for improving fruit quality and yield

Data Availability
The primary data of this article is in Figure 5.

Conflicts of Interest
The authors declare that there is no conflict of interest regarding the publication of this paper.