SMART AUTONOMOUS AGRICULTURAL SYSTEM FOR IMPROVING YIELDS IN GREENHOUSE BASED ON SENSOR AND IOT TECHNOLOGY

With a special focus on the now widespread Internet of Things (IoT) technology, it offers a convenient solution for smart agriculture. This paper will introduce a smart greenhouse monitoring and control data logger system as part of a smart farm. The system is based on: a group of built-in sensors, a microcontroller with a peripheral interface (PIC) as a core and a server system and a wireless Internet using the Global System of Mobile Telecommunications (GSM) module with General Packet Radio Service (GPRS) as a communication protocol. It is possible to implement a smart agricultural service, in which the realized smart data logger system could be implemented, which enables automatic control of the greenhouse at the farm.


INTRODUCTION
Greenhouse planting conditions differ from outdoor growing conditions, which can have its advantages and disadvantages. Some of the advantages that can be cited are the reduced or total isolation of the plantation from external influences such as weather (city, strong winds, etc.), unhealthy sunlight, insects, etc. The disadvantages of growing greenhouses in greenhouses are that the temperature inside the greenhouses must be controlled, regularly ventilated, to provide fresh air for the crops being grown, the quality of the soil declining with the consumption of minerals due to the greenhouse effect, etc. As greenhouses reduce a large percentage of external influences, it is necessary to monitor and control in some way the parameters that can adversely affect the yield and cultivation of plantations in greenhouses, a part of which is listed. The human factor is most often prone to errors and the inability to wash and control all parameters. Especially this problem is reflected in the morning when it is necessary to ventilate the greenhouse, and inside the greenhouse, the humidity is above 85% and the temperature difference is high (the temperature inside the greenhouse is much higher than the outside temperature), so when opening the greenhouse plants experience temperature shocks, which adversely affect the plant as well as the fruit itself. Earlier research [1] was based on measuring ambient/ atmospheric parameters and storage it on Security Data (SD) card that cannot be accessed during the measurement to give the end user an insight into the current results. The research [2] was based on wireless communication and storing measured atmospheric/ambient parameters in commercial Cloud or database with commercial data protection. In research [3] the smart house system based on Internet of Things was described. Both of these researches [2] and [3] were related to smart weather station/home systems that are designed to monitor and measure both atmospheric and/or ambient parameters. Unlike the research [2], the research [3] monitored the ambient parameters (temperature and LPG gas concentration) based on the changes the system reacted, including ventilation/room cooling or heating in case the temperature was lower than the set value. With the use of smart autonomous systems, it is possible to completely exclude the human factor, and perform monitoring and control with a minimal detrimental effect on the quality of cultivation of the plantation, and most importantly on the quality of yield. The system implemented is for monitoring and controlling the following microclimatic parameters: Greenhouse temperature [°C]  All measurements are accompanied by information on the time and date of measurement. The period for reading the microclimatic parameters and storage in the database can be set within the range of 1 to 60 minutes, depending on the need for monitoring and measurement of parameters. For the user to monitor the values of the measured parameters, the smartphone application has been implemented. By using the application, the user monitors the results of the measurement, and the application also offers the ability to control the microclimatic and ambiental parameters being measured. This smart agricultural system offers using control nodes which can be used to control microclimatic parameters in other greenhouses, managed by a control unit that serves the whole system. They turn on the air conditioning or ventilation if temperature, relative humidity, soil moisture, pH value or CO 2 control is performed, or adjust the brightness intensity by controlling mesh slope or position above the greenhouse or by turning on the lights in the greenhouse. Also, based on changes in atmospheric pressure it is possible to show whether weather can be expected (if there is a sudden fall in the value of atmospheric pressure), the system can react by closing the door of plastic, covered with plastic protective mesh, etc. Based on the measured parameters, the application sends a message to the control unit which parameter needs to be regulated, or to regulate the values of that parameter to be in the optimal range.

THEORETICAL BACKGROUND
Monitoring agricultural crops, controlling ambient parameters to ensure yield improvements, is one of the most current and major problems in the agriculture field. To facilitate the control of ambient parameters, various systems were developed that tracked some of the basic parameters, such as ambient temperature, soil humidity, and light intensity. However, such systems are not of much use, which makes it impossible to drastically improve yields and higher quality yields based on these parameters. In [4], [6], [7] and [8] the authors used very expensive development environments that were not easily accessible to a large number of users. Accordingly, in [4], [7], and [8], the authors used the Raspberry Pi development environment to realize the system, characterized by a higher cost (than microcontroller we use), which made the whole system they described more expensive. Most of these environments have a LAN network protocol, limiting communication to wired internet communication. The microcontroller we used to realize our system is characterized by low cost as well as easy accessibility for users. It should be noted that the used microcontroller has performance that does not lag behind the development environments used by the authors in their work. It should be noted that low reliability sensors were used in the works, which is the case with works [4], [6], and [7]. In [8] and [9] the authors did not define exactly which sensors they used, more precisely in [9] the authors stated that they measured the humidity of the air in the greenhouse, but without specifying which sensor was used. In this way, the value and credibility of the system they were describing are greatly reduced. In [4] and [7], the authors used a DHT11 sensor for measuring temperature and humidity, characterized by a temperature measurement range from 0°C to 50°C, while that range for air humidity was from 20% to 80%. In a greenhouse, the air humidity is usually above 80% RH, and therefore, using this sensor, the measured results are not valid for the system operation. Similarly, in [6] the authors used a laboratory sensor to measure the pH of water, which is less reliable than a commercial sensor. In [9], the authors used an analog sensor LM35 to measure temperature.
Unlike the sensors mentioned above, commercial sensors of high confidence, which feature large ranges of measurements with high resolutions, were used to realize our system. In [4], [5], [6] and [7], the authors used a WiFi module to send data to the Internet to send data, which limits such systems to internet access and inability to use them over long distances. Unlike this mode of communication, our system is equipped with a GSM / GPRS module, which is independent of the Internet. It should be noted that the use of this module is an advantage of our system, since it is possible to use the system in hard-to-reach places. In [9], the authors used a ZigBee module that uses an RF communication protocol to send measurement data, which by itself does not offer the ability to send data to the Internet. From the standpoint of power supply, in [4], [5], [6], [7], [8], and [9], the authors partially defined the power supply of the systems described, indicating that all of these systems are directly dependent on the power supply and do not offer complete autonomy, which is the case with our solar-powered system. Besides, battery power is available in the form of backup power. It should be noted that in [5], [6] and [8], the authors did not even cite the results, indicating the possibility that these systems were not tested or tested in laboratory conditions. In [4], [7] and [9], the authors reported the results, but without a more detailed explanation, as well as without a defined measurement period. The basic idea of the Internet is to enable data collection in-situ and send it and present it on the Internet to the end user. With the development of Internet of Things technology, there is an increasing number of commercial services (free Cloud platform), as well as especially realized databases on private servers, which can be used to store data. In the case of free commercial services, it is necessary to note that they offer a low level of data protection. Smart things such as smart sensors are connected to the Internet and can automatically transfer data without relying on human interaction -hence being "Machine to Machine" (M2M) interaction [10]. A Machine to Machine talk (M2M) system may be generally seen as a wireless sensor network where sensor nodes are embedded systems referred to as M2M terminals. Embedded software running inside M2M terminal should manage concurrent tasks efficiently and reliably within limited hardware resources and with real-time constraints.

THE DESIGNING OF SMART SYSTEM
This manuscript describes a model of a smart agricultural system for measurement and control microclimatic parameters, based on PIC microcontroller and the Internet of Things technology. The system is designed to be scalable and easy to set up and extend and is also reliable in operation and data protection, which is most important. It is based on a powerful PIC microcontroller that controls the entire data logging and control system. It contains Figure 1: Block schematic of smart agricultural system /11/, /12/ built-in sensors for monitoring and measuring microclimatic parameters inside and outside the greenhouse or where necessary and GPRS modules that send data to the database on a web server. In addition, this system includes nodes for controlling microclimatic parameters that are vital for growing greenhouse plantings and protecting the greenhouse itself when necessary. The smart agricultural system for monitoring and controlling the microclimate parameters is realized to consist of the main control unit and control nodes that control the microclimate parameters, which is shown in Figure 1. The control nodes monitor the changes of microclimatic parameters in the greenhouse, as is the case with the temperature inside the greenhouse and on that basis, it activates ventilation or air conditioner, to maintain the temperature within the optimum limits, which correspond to the plants planted in the greenhouse. It is similar to other parameters such as the humidity of the air, while in addition to the control node, the irrigation system is in charge of soil moisture control. Within the irrigation system, there is a control node in charge of monitoring the water level in the tank, as well as the temperature of the water itself, so that the plants do not experience unpleasant temperature shocks during irrigation. As carbon dioxide (CO 2 ) increases, the control node opens the greenhouse door to ventilate it. In the event of a sudden drop in atmospheric pressure, the control node in charge of protecting the safety net starts motors that stretch the net above the greenhouse to protect it from the bad weather (hail, a heavy rainstorm, strong gusts of wind, etc.). The same applies to the control node that monitors the speed of the wind, which controls the door, to protect the plantings in the greenhouse. By monitor-ing the pH value of the soil, it is easier for the farmer to choose the right nutrition or pesticide it is necessary to add to the irrigation tank, in order to bring the soil characteristics to the optimum conditions appropriate to the crops planted in the greenhouse. The Peripheral Interface Controller PIC18F45K22 [13], which represents the core of the entire device, manages the sensor block, which serves for microclimatic measurements and observations, control nodes for irrigation and greenhouse system. Also, the GSM block, realized using the SIM800l module [14]. The sensor part of smart agricultural system consists of the following sensors: BME280 ( [21] and DS18B20 (Water temperature (in reservoir for irrigation) [°C]) [22]. How the control unit for the measurement and control system is realized can be seen on the electrical scheme of the smart agricultural system shown in Figure 2. As previously stated, the BME280 (BOSCH Sensortec) sensor was used to measure temperature, relative humidity, and atmospheric pressure in the greenhouse. Communication between microcontroller PIC18F45K22 and BME280 sensor is realized via the I2C bus. The used BME280 barometric sensor provides a wide range of measurements: Air humidity from 0% to 100% RH, Temperature from -40°C to +85°C and Atmospheric pressure from 300 to 1100 [hPa] or [mBar].

Figure 2: Electrical scheme system of the smart agricultural system
Measurement of illumination (light intensity) in a greenhouse is done by the sensor BH1750 (ROHM Semiconductor), which for communication with the microcontroller uses the software realized I2C bus, such as barometric BME280 sensor. The used sensor provides a wide range of high-resolution measurement in a range from 0 to 65535 lx with 0.5 lx resolution. An MQ-7 sensor was used to determine the percentage or concentration (in ppm) of carbon dioxide (CO 2 ) in the greenhouse. As is known to farmers and greenhouse owners, carbon dioxide is increasingly used as an organic fertilizer, as it improves yield quality. By applying the amount of CO 2 , the plant becomes lush, the leaves become intensely green and large, and the formation of generative organs is accelerated (the flowers become larger, more intense colors, the fruits are formed better) [23]. Measurement of pH soil value is made by using SEN0161 analog sensor. The pH values for this sensor are in the range of 0 to 14 (414mV for 0 pH to -414mV for 14 pH). In addition, this sensor has been used to measure soil temperature, since this sensor offers this capability in the range of 0 to 60°C. Capacitive soil moisture sensor SEN0193 was used to measure soil moisture levels. Based on the change of the value of soil moisture, the system controlled the irrigation system. This sensor is more accurately detects changes in soil moisture from ordinary sensors commonly found in many publications.
Wind speed was measured using an analog type anemometer that, like sensors for detecting and measuring CO 2 concentration, pH, and soil moisture, uses an A/D converter to communicate with the microcontroller. The voltage value given by this sensor is in the range 0V to 2V, which is proportional to the wind speed from 0 to 70 m/s (0 -252 km/h). In addition to the sensors used to measure microclimatic parameters in and out of the greenhouse (wind speed and light intensity), two sensors are used within the irrigation system. One was used to measure the water level in the irrigation tank, while the other was used to measure the water temperature in it. The HC-SR04 ultrasonic sensor was used to measure the water level in the tank. This sensor uses the Doppler effect to measure the distance of an object, in this case, it is the water level in the tank. The system can measure the water level in a tank in liters or meters. If measured in liters, the dimensions of the reservoir must be known to obtain a valid measurement value. The Dallas temperature sensor DS18B20, which is housed in a waterproof probe, is used to determine the water temperature in the tank. This sensor offers a temperature measurement range of -55°C to 125°C. The GSM/GPRS module SIM800l serves to send data to the database realized on the webserver. Also, the SIM800l module serves to send an SMS to the user with information that the measurement has been completed. The system checks for each sending whether there is a Figure 3: Data-flow organization and displaying measurement results of the smart agricultural system connection to the Internet. If the module response is that at that moment it is impossible to make a connection to the Internet or database, the data is stored on the Security Digital memory card. The data on the Security Digital memory card is stored in a previously created file. The buttons to adjust the operation of the Real Time Clock module are also used to create a name for the file in which the measurement results will be stored. Also, there are a Real Time Clock (RTC) module DS1307 [24], which is used to set the current time and set the measurement step. DS1307 module is used to set the duration time of the measurement. In order to have an insight into the results of the measurements stored in the database, the application for the smartphone was realized. By using the application, the user can access the measured and stored data in the database at any time. The method of displaying the measurement results is in the form of charts, where each of the parameters is displayed on separate charts and such this application would follow component and data-flow organization is shown in Figure 3.
The application provides the ability to monitor real-time measurement results as well as control them. The presented system was realized for the monitoring of several greenhouses and yields. During measurements within the application, it is possible to choose which microclimatic parameters can be monitored. The display of the measured parameters is in the form of graphs, for each of the parameters separately. Also, it is possible for the user to provide a statistical overview of the measured values of the parameters.

EXPERIMENTAL RESULTS
The microclimatic parameters were measured with a prototype of a smart agricultural system for 9 days (from 18 th of March to 25 th of March, 2020), in Nis, Serbia. Measured parameters are shown in Figures 4 and 5, respectively. During the first two days, warm and sunny weather prevailed, and accordingly, the highest temperatures of both air and soil were measured during this period, where the air temperature was in the range of 3°C (during the night between 18th and 19th of March) to 25°C (during the day of the 21 st of March between 14h). The soil temperature during this period ranged from 2°C to 17°C (maximum temperature on 21 st March when the highest air temperature was recorded). During this period, the lowest humidity of air and soil was recorded, which ranged from 50% to 73%, while the soil humidity was in the range of 27% to 44%. During this period, it was necessary to activate the irrigation system in the greenhouse, in parts where certain crops required it, as in the case of cucumbers. This period was followed by a period of rapid cooling, which was reflected in the measured parameters, first of all temperature and humidity, since in the following days it was raining and then snow (March 22). During this period, a sudden change in other parameters was also observed, such as the pH value of the soil changing with precipitation, which influenced the change in the composition of the soil. As these sudden changes in soil pH do not affect the development of plants and fruits, it is necessary to add nutrition to the irrigation system to minimize these fluctuations in soil pH as much as possible on plant development and future yield. The fall in atmospheric pressure that preceded the days of rain and snow may also be considered a warning of impending bad weather. It can be seen that the wind was blowing more intensively in the period before the weather worsened, indicating that the greenhouse control system had to be activated to protect the greenhouses so that the structure would not be damaged, since the wind gusts during that period were more frequent and with speeds in the range of 10 m/s to 52 m/s. For the light intensity, the highest values were changed according to the weather during the first days of measurement, when the illumination values ranged from 4000 to 34000 lx. After the worsening weather, where most of the day was cloudy, the lighting intensity did not exceed 20000lx.

DISCUSSION
Based on the farmer's experience (the holder of the agricultural holding/farm Djordjevic Barbara), the following conditions must be met for optimal greenhouse placement: Places where winds are not strong or damage to the nylon/structure will otherwise occur; No low temperatures, which can have a detrimental effect on plant development and increased electricity consumption when greenhouses are heated to provide the optimum temperature for growing crops; Places where with a minimum rainfall of 500mm per year, which is important because of the seedlings to which, in addition to temperature, humidity is important; Places where there is not too much air pollution, because a lot of dust reduces light transmission, which is crucial in the development of plants in terms of photosynthesis; Places, where the terrain is sunlit for as much of the day as in the winter the trajectory of the sun, is different and the greenhouse may be in the shade in winter, which further slows down the growth and development of plants and increases the consumption of electricity for additional greenhouse lighting; Position of the greenhouses in the north-south direction, to protect the construction of the greenhouses as much as possible from the impact of the wind, that is, so that the smaller surface of the greenhouse is exposed to the impact of the wind; Special foils 0.2mm thick are used because they are UV resistant, to further protect the plants and reduce the cost of nutrition and protection necessary for proper plant cultivation.
If it is impossible to fully meet these conditions, or to provide the ideal conditions for growing plants, the use of smart systems like the one described in this manuscript is necessary. As this system is fully autonomous (using solar/battery power supply), optimal conditions for growing plants in a greenhouse can be ensured, while minimizing the human factor, as well as electricity, water, and nutrition / pesticide consumption. Within the THEO-RETICAL BACKGROUND chapter, papers are outlined that describe systems that have been implemented to improve the growing conditions of greenhouse plants, and also outline all the benefits our system offers over these systems. In the next chapter, the entire system is elaborated, with a brief look at each of the sensors used to realize the smart agricultural system. Of course, the disadvantages of this system, which can be attributed to cheaper sensors, which can affect the accuracy of the measurement, should be noted. Concerning the implementation of such a system, the following conclusions can be made that support why our yield improvement system should be implemented: For the greenhouse, the constant soil moisture is important, the water temperature of the irrigation water should be close to the soil temperature, so that the plants do not experience temperature shocks during irrigation, which adversely affects the development of the plants and the fruit. From planting, ie arrangement of crops in the greenhouse, care should be taken that cucumbers seek constant irrigation in smaller quantities, tomatoes can be watered less frequently and more abundantly, so they are better in separate strips or parts of the greenhouse. Accordingly, cucumbers produce a larger leaf mass so they do not plant in the middle of the greenhouse for better ventilation. Higher humidity and air temperature are better during emergence, while later good ventilation is important. In the morning and in the afternoon the temperature inside the greenhouse is lower, so processing in the greenhouse is carried out at this time for less evaporation. As stated in the paper, the concentration of carbon dioxide favorably affects the development of plants, and therefore the concentration of CO 2 is monitored, to add a certain amount of nutrition to the plants through the irrigation system if necessary.

CONCLUSION
This paper describes a reconfigurable smart agriculture system as part of a smart farm. The system presented is fully autonomous, which means that it monitors the microclimatic parameters in the greenhouse and atmospheric parameters that can adversely affect the greenhouse and, in accordance with the requirements of the user, controls the parameters in the greenhouse and protects the construction of the greenhouse. The smart agricultural system presented in this paper provides the ability to monitor, measure, collect and control microclimatic and atmospheric parameters to achieve optimal crop conditions for increasing yield quality. In addition to the main control of the unit that monitors the microclimat-ic parameters in the greenhouse, the control nodes that control the irrigation system, the system that controls the safety net, and also systems such as ventilation, lighting, greenhouse doors, etc. are activated. The monitoring of measurement results is possible using the implemented smartphone application. With this application, it is possible to control all parameters in the greenhouse being monitored, and in particular multiple data logging systems. MQTT (Machine to Machine (M2M)/Internet of Things) protocol was used as the main communication protocol for greater data security. Compared to similar systems published in reference journals, this system has some advantages in terms of implementation. One of the advantages is that it is manufacturer independent, so it enables integration of this smart agricultural system with other smart agrotechnical services or e-agriculture/horticulture. It should be noted that the implemented system does not use the free commercial Cloud storage platform, as is the case in some papers published in reference journals. This paper also provides measurement results when the system is active and controls the microcultural parameters and atmospheric parameters according to user requirements, thus confirming the functionality of the system (monitoring, measuring, and controlling soil moisture). Similar can be realized for other parameters being monitored. The disadvantages of this system are unreliable cheap sensors.