Intelligent Automation System on a Single-Board Computer Platform for the Agro-Industrial Sector

The latest technologies in agribusiness include a range of IT solutions that reduce manual intervention with the top priority tasks to improve, develop, and implement projects based on smart agriculture, which operates on the principles of automation and robotization of production. The aim of the study is to develop a system of automated control of business processes for an agricultural enterprise. The system allows for remote collection and processing of data on technical and economic performance of the farming enterprise. It proves to be a low-cost solution due to the use of affordable and available equipment. When designing the system, the authors described its back end, as well as the connectivity architecture between sensors and modules on one side, and the microcontroller on the other. The paper features modules for monitoring and controlling electrical energy consumption, lighting, temperature, and humidity written in C ++ programming language. Test modules that were controlled by the Arduino microcontroller were analyzed. Further development of the system may involve devising and introducing IoT technologies based on the use of various architectural platforms for practical application.


Introduction
Outbreaks of massive plant diseases annually cause enormous damage to agricultural industry worldwide. Despite the successes achieved in recent years in crop production of a significant number of crops, the risk of epidemics not only has not decreased, but has got significantly higher. This fact can be explained by a number of objective reasons: Under the new land-use conditions, existing methods to monitor crop cultivation, forecast and control epidemics require significant adjustments. Modern systems of prevention and protection against epidemics must be integrated with world achievements in the fields of phytopathology, plant and pathogen genetics, ecology, phytosanitary toxicology, mathematics, computer science, engineering, etc.
Digital innovations and technologies may be part of the solution. The so-called 'Fourth Industrial Revolution' (Industry 4.0)1 is seeing several sectors rapidly transformed by 'disruptive' digital technologies such as the blockchain, Internet of things, artificial intelligence and immersive reality. In the agriculture and food sector, the spread of mobile technologies, remote-sensing services, and software. The value of the article lies in the design and development of such an automated control system that will represent an inextricable combination of equipment, programming, data, and control by obtaining valuable information using existing technologies, transferring it between devices and independently managing them. Nowadays, human life is becoming easier and more convenient; therefore, there is a need for an automated system to reduce human effort in daily activities as electronics and technology advance. The system controls enterprise's facilities using sensors to measure key indicators to ease human efforts. It is designed to continuously monitor technical condition of the premises used for agricultural purposes. For instance, if the light level is low, Arduino switches on additional lamps to ensure sufficient illumination. When the system detects enough moisture, the water pump will automatically shut off. Every time the pump is turned on or off, a message is sent to the user via the GSM module, updating the status of the water pump and humidity. The system also monitors the status of the facilities, checks for the presence of unauthorized persons, and, if necessary, reports this. It helps take measures to save enterprise's resources, such as water, electricity, human resources, etc.
The purpose of the study is to design and set up an intelligent automation system to manage business processes of an agricultural enterprise. The set purpose entails attaining the following objectives: • to define the key principles running the system of automated equipment control being developed to monitor and manage business processes in the enterprise; • to determine the set of microcontrollers, the basic components of the monitoring hardware; • to identify sensors, modules and expansion cards compatible with the selected microcontrollers; • to consider using a computing server designed to process the data transmitted from the microcontroller; • to identify the main electronic and electrical processes supporting the enterprise's activities; and, • to specify the shortcomings of the developed system and offer ways to tackle them.

Materials and Methods
Modern agriculture and agribusiness impose high requirements on the organization of the enterprises' processes, from the choice of technology for growing crops to the safety and control of auxiliary equipment. The reliability requirements for complex control systems for farming enterprises are getting stricter. As a result, the engineering equipment of agricultural enterprises is steadily becoming more complicated, and the number of devices that are involved in the shared environment is growing.
We shall define the basic procedures of the system to be developed ( Figure 1) that are necessary to achieve the above objectives. These include the following: • statistical processing and regulation (stabilization) of the controlled parameters of a technological process;  Consider the basic principles of the intelligent automation system of an agricultural enterprise. Every modern facility, to a greater or lesser extent, owns a large number of equipment functioning, providing and creating a fully-fledged working environment. The convenience of managing these systems, their integration with each other, the ability to work together seamlessly, thereby individually increasing the functionality of each of them makes it possible to call such a farm smart or intelligent. The intelligent automation system optimally maintains a constant microclimate, while keeping the desired temperature, humidity, and lighting.
An intelligent automated control system for a farming enterprise is based on IoT technologies and constantly monitors all of the engineering systems and prevents emergencies. It ensures obtaining the data on the status of the system as a whole, as well as its transmission at any distance. The type of automated control systems under consideration is an intelligent automation system for managing engineering systems of a modern farming enterprise.
The Agricultural Automation Intelligent System (AAIS; British company Raspberry Pi, Ekaterinburg, Russia) provides a centralized intelligent control mechanism for office, production, auxiliary and utility rooms, workshops, warehouses, tank farms, and garages. The application of the system allows for the enterprise to set the parameters of the customizable environment, gain access to the status information from all of its subsystems, and manage them. The AAIS interface is based on interaction with touch video panels that show a plan of any room or surrounding area and display images from CCTV video cameras.
When running the selected scenario, the system can be quickly adjusted by changing the Consider the basic principles of the intelligent automation system of an agricultural enterprise. Every modern facility, to a greater or lesser extent, owns a large number of equipment functioning, providing and creating a fully-fledged working environment. The convenience of managing these systems, their integration with each other, the ability to work together seamlessly, thereby individually increasing the functionality of each of them makes it possible to call such a farm smart or intelligent. The intelligent automation system optimally maintains a constant microclimate, while keeping the desired temperature, humidity, and lighting.
An intelligent automated control system for a farming enterprise is based on IoT technologies and constantly monitors all of the engineering systems and prevents emergencies. It ensures obtaining the data on the status of the system as a whole, as well as its transmission at any distance. The type of automated control systems under consideration is an intelligent automation system for managing engineering systems of a modern farming enterprise.
The Agricultural Automation Intelligent System (AAIS; British company Raspberry Pi, Ekaterinburg, Russia) provides a centralized intelligent control mechanism for office, production, auxiliary and utility rooms, workshops, warehouses, tank farms, and garages. The application of the system allows for the enterprise to set the parameters of the customizable environment, gain access to the status information from all of its subsystems, and manage them. The AAIS interface is based on interaction with touch video panels that show a plan of any room or surrounding area and display images from CCTV video cameras.
When running the selected scenario, the system can be quickly adjusted by changing the parameters of the devices. Additional settings allow the system to turn off or put unused rooms (climate warm chambers, air conditioners, etc.) into power saving mode, and activates the perimeter security mode. This ensures the economy and safe mode of operation of the equipment. The system notifies of emergency situations through the built-in speaker systems or, if assigned, calls the special services-the emergency service, the police, or the fire department. Table 1 presents the basic principles of the intelligent automation system for an agricultural enterprise. The reed switch contains flexible metal ferromagnetic contacts. They overlap in length, but are a small distance from each other. These are used for switching (closing or opening the circuit). When the magnet is brought near to the reed switch, the contacts close (or open). It can trigger a siren if used as a position control sensor or after lifting an object

Load control module
The maximum switching voltage is AC 250 V or DC 30 V. The rated switching current is 10 A. The relay contact group consists of three contacts, which makes it possible not only to close the circuit, but also to break it. The LED indicator used to control the operation of the module is connected to the system without any additional strapping. It has galvanic isolation and, therefore, is well protected from high-voltage power supplies

Data transfer modules
Establish wired and wireless connection between microcontrollers. Wireless communication modules (nRF24L01 + transceivers) [36] wirelessly scan the sensors and send commands to the executive devices of the system. These are the basic components of a radio control system for devices and other modules 4 Ethernet Shield Expansion Card Acts as a networking device to access other devices. It is based on the Wiznet W5100 chip, which supports both the TCP and UDP protocols 5 Web server Is designed to remotely monitor and control microcontrollers of the system with connected sensors and modules. It is responsible for receiving and processing website requests from clients. The most widespread web servers include Apache, IIS and iPlanet server. They support a large number of modules, utilities, and add-ons. For a small agricultural enterprise intranet, the Internet Information Server (IIS) is the best option. It can be easily deployed and configured, integrated with access controls, uses Performance Monitor (a performance monitoring tool for system settings control), etc. IIS is noted for its high-speed performance. Its components support the HTTP, HTTPS, FTP, NNTP, SMTP, and POP3 protocols We shall consider the Arduino microcontroller as the most affordable tool for creating an intelligent automation system for an agricultural enterprise. There are several reasons behind choosing this microcontroller. Arduino has long been showing itself as a serious development tool. In small farms, there is no point in using such systems, as, for example, Cropio (an automated satellite monitoring system for farmland, New Science Technologies, New York, NY, USA) [21], due to their complexity and high price. There is a large number of free libraries available for this microcontroller, with which the necessary control functions can be programmed. Moreover, there are many compatible sensors and other electronic components on the market that cover various needs and requirements of customers.
The microcontroller development environment contains two blocks: void setup () {} and void loop () {}. The setup block is executed at the startup. The loop block defines execution of a function in a loop. The user needs to preset the necessary parameters for the board and ports before loading the program. When loading the program, the Bootloader loads the program code without using any additional hardware. The Bootloader stays active for several seconds after rebooting the platform and loading the program into the microcontroller and flashes pin 13 LED when invoked. The microcontroller monitors serial bus and displays the data sent to the platform. The Serial.begin function sets the serial data transmission rate.

System Structure
An intelligent automation system for an agricultural enterprise based on the IoT consists of five interconnected subsystems: sensing [24], data analysis [25], communication [26], visualization [27], and execution. The sensing subsystem is interconnected with the data analysis subsystem, where the raw data from each sensor is processed and analyzed individually with various algorithms implemented in the microcontroller for the visualization and execution subsystem [28]. The process of visualizing the sensor data directly depends on the communication subsystem, since access to these data via a mobile phone, smartphone, or PC requires establishing a connection to the modules of the communication subsystem. If the user (farm worker) wants to visualize the data through a web browser, then the IoT ESP8266 module is required [29]. If one wants to receive a short message on a mobile phone, the data will be visualized through the Arduino "Sketch" IDE serial monitor, and will depend on the nRF24L01 module [30] and so on. The system is capable of making decisions and executing them based on the sensor data used by the execution subsystem, which are the main subject of the presented system. Figure 2 shows the structure of an intelligent automation system for an agricultural enterprise.

Connecting Sensors and Modules to the Arduino Microcontroller
We shall define the general requirements for the device under development. Firstly, we will identify its power consumption and remotely measure the number of kilowatts that the electricity meter shows, as well as collect the data on the current load on the circuit. The electricity meter generates pulses in accordance with the amount of electrical energy consumed. The pulses are shown

Connecting Sensors and Modules to the Arduino Microcontroller
We shall define the general requirements for the device under development. Firstly, we will identify its power consumption and remotely measure the number of kilowatts that the electricity meter shows, as well as collect the data on the current load on the circuit. The electricity meter generates pulses in accordance with the amount of electrical energy consumed. The pulses are shown by the LED indicator. The faster it flashes, the more kW the system uses.
The meter pulse rate (A) on the front panel of the device shows the number of pulses per 1 kW·h. The meter used to collect the data has A = 1000. Hence: (a) with each pulse, the meter records the consumption equal to 1/1000 of 1 kW·h. The quotient of the number of pulses after the load is applied divided by the pulse rate gives the amount of consumed electrical energy (kW·h); and, (b) since the indicator changes its blink speed, it is possible to derive the relationship between the power (kW) and the meter's pulse length, which will allow obtaining the data on power or current.
A photoresistor is used to read the electricity meter. Next, we shall turn to creating a device that can read the data from the meter and allows the user to remotely obtain the number of consumed kilowatts, as well as the current load. When connecting the photoresistor to the microcontroller, it is necessary to take into account that the voltage of 0-5 volts will be registered at the output of the photoresistor circuit. It must be converted to a specific number for the microcontroller program to work. The photoresistor circuit represents a voltage divider, the upper leg of which will vary, depending on the intensity of light incident on the face of the photoresistor. The voltage from the lower leg is fed to the analog input, which converts it into a number from 0 to 1024.
When working on the program code, it is important to keep in mind the processor sophistication, its ability to work correctly with floating point numbers, and the probability of performing complex calculations on the server. The flashes of the meter pulses at the high load are quite short and frequent, therefore the microcontroller must constantly and very quickly read the photoresistor, which makes any additional load with numerous calculations undesirable. The AAIS uses a variable that shows which input the photoresistor is connected to. The data from the photoresistor are constantly read and written to this variable in the loop block. The number of flashes is recorded, depending on whether there was a signal or not. As soon as it reaches the pulse rate, the amount of energy consumed becomes equal to 1 kW, the pulse counter gets reset, i.e., for the selected counter 1 kW is equal to 1000 pulses. The obtained value is transmitted to the server for processing and logging.
The program code for calculating energy consumption is as follows: if ((val>500) and (impulse= =false)) { impulse = true; } if ((val<500) and (impulse==true)) { imp++; } if (imp==schetchik) { imp=0;//upon reaching A, reset the pulses kilovat++; } impulse=false; The processing power of the microcontroller is sufficient enough to process these values in the normal mode of operation. However, for better performance, it is highly recommended that you avoid excessive load on the microcontroller, as it has to accurately record the number and calculate the length of flashes that may occur a number of times per second. The more accurate computation will reduce the measurement error. In addition to determining the number of kilowatts, it is important to know the current load. To do this, use the millis () function, which starts the stopwatch. The pulse length can be calculated as a difference between the on and off times of the counter. The program code for recording the time for determining the load is given below: Void loop () { Val = analogRead (photoPin); time = millis (); if ((val>500) and (impulse= =false)) { t1 = time; impulse = true;} if ((val<500) and (impulse==true)) { t2 = time; voltageTime = t2-t1;//sending the pulse length to the server imp++;//sending the number of pulses to the server if (imp==schetchik) { imp=0;//reset the pulse counter kilowatt++;//sending the number of kilowatts to the server } impulse=false; voltageTime = 0; t1 = 0; t2 = 0;//resetting the variables denoting the on/off times } Each electrical appliance in each room is plugged in one-by-one at the minimum load on the electrical grid to record their power consumption. Based on this, it is determined which appliances can be operated at the moment. The register of the plugged-in and switched on appliances can be accessed via the web server; therefore, idle equipment can be identified and turned off in order to reduce the total power consumption.
In addition to monitoring the energy consumption, the AAIS measures and captures the ambient temperature both indoors and outdoors with the temperature and relative humidity sensor DHT11 doing the former. The recorded data can be seen on the LCD 1602 screen and are sent to the server to collect statistics. While the recorded data are sent to the server, the temperature can be displayed on the screen to ease access to it without using the website. To do this, add the LiquidCrystal.h library with the #include statement. The LiquidCrystal.lcd () function initializes the display and sets the pins used to connect to the LCD. The display dimensions can be set with the lcd.begin (x, y) function in the setup block.
The following program code can be applied to read the temperature sensor: The functions added to the system include displaying the current temperature value on the screen; its minimum and maximum values; and, the humidity value. The function changing the screen every three seconds was added to fit the output on the display. It clears the screen and prints the characters on it again.
The first screen shows the current temperature value, the second one displays its minimum and maximum values, and the third one is used for indicating humidity. Such a sequence is programmed with the millis () function, which starts the counter and counts 3 s, and then changes the screen, depending on which one was displayed. The order in which the screens are shown is set using the d1, d2, and d3 Boolean variables denoting the current temperature, the minimum and maximum temperatures, and humidity, respectively. The initial values for d1, d2, and d3 are set to true, false, and false, respectively. This means that, when the program starts, the display shows the current temperature.
When the text is displayed, the time t1 equal to the current time of the counter is recorded. As soon as the difference between the time of the counter and the recorded t1 value exceeds 3000 ms (three seconds), the display clears. t1 changes again to the current time of the counter, after which the d1, d2, and d3 values become false, true, and false. This activates the screen with the minimum and maximum temperatures.
There is no need to add any libraries in this case. To receive the data from the reed switch module, the digital output on the microcontroller must be set. This information is then read in the loop block. The result is transmitted to the server, which transfers the data on whether the door is open or closed through the communication channel, and the door status is shown on the display: void loop () { val = digitalRead (gerkon); lcd.setCursor (0,1); if (val==1) { lcd.print ("Open "); } if (val==0) { lcd.print ("Close "); } } Thus, you can be completely sure that no one enters the room unnoticed. You can also find out how many times and at what time exactly the front door opened and closed, and determine how long it was open.
The system has motion sensors installed to automatically turn the light on when the personnel enter in order to reduce the electrical energy consumption. When using an infrared motion sensor, the movement of inanimate objects does not affect the automatic switching on of light. The sensor reads the thermal radiation from the object and sends 0 or 1 to the microcontroller based on the change in the position of the thermal radiation. If there is no movement, the signal is zero, otherwise-1. If the object in the room stops moving, 0 is transmitted, and the system immediately switches the light off. In order to prevent the light from turning off for some time, you can set the on time using the millis () function and stop the system from turning the light off for a certain time, even if there is no movement. Moreover, if the object moves during this time, the timer gets reset and the countdown starts over.
To implement automatic light switching, the program code below can be applied:  Figure 3 demonstrates the results of monitoring humidity in the room where crops are grown. At 12:40, the permissible humidity level was exceeded and the microcontroller initiated a command to stop the water supply to the sprayer. Figure 4 shows the report on illumination and temperature levels' change to ensure effective plant growing. It can be seen that, when the set values are exceeded, the users are notified and the indicators are adjusted using the necessary equipment (setting the intensity of main and supplemental lighting, fan speed, etc.  Figure 3 demonstrates the results of monitoring humidity in the room where crops are grown. At 12:40, the permissible humidity level was exceeded and the microcontroller initiated a command to stop the water supply to the sprayer. Figure 4 shows the report on illumination and temperature levels' change to ensure effective plant growing. It can be seen that, when the set values are exceeded, the users are notified and the indicators are adjusted using the necessary equipment (setting the intensity of main and supplemental lighting, fan speed, etc.).

Discussion
In the course of assembling and testing the modules under the control of the Arduino microcontroller, the following limitations were identified and need to be taken into account before installing the system on the premises for regular operation.

Discussion
In the course of assembling and testing the modules under the control of the Arduino microcontroller, the following limitations were identified and need to be taken into account before installing the system on the premises for regular operation.

•
The first limitation consists in a small amount of memory. 32 and 64 KB of memory is enough for writing small programs. For a significant number of operations, an external memory module is required.

•
Poor computational performance of the microcontroller. This microcontroller incorrectly processes real numbers, as shown by the analysis of its operation as an automatic reader of the electricity meter. It may lose the remainder of the quotient or reset the variables when dividing them.
To avoid this, in some cases it is necessary to send the data to an external server for processing, or use additional processing devices, such as, for example, the Raspberry Pi 2 Model B. It has a processing unit, RAM, HDMI, USB, Ethernet, analog audio and video outputs. It also has 40 general-purpose I/O pins that can be used to connect peripherals to interact with actuators, such as contact relays, servomotors, and any sensors.

•
Unlogged failures during the program operation. A failure can only be detected if something stops working. However, even if the failure is detected, the system will not report how many times it happened before. In order to record the number of program crashes, you can use EEPROM (Electrically Erasable Programmable Read-Only Memory) special memory cells. These will prevent overloading the microcontroller.

Conclusions
The AAIS performance was tested in a specific environment that was related to the agricultural enterprise, but not in the enterprise itself. The results obtained during its operation were almost equivalent to this environment. Actual results can be obtained by implementing the system in the agricultural enterprise, which is a lengthy process and requires tremendous effort. However, the theoretical tests suggest that the performance of the system is adequate, and it will give more accurate results when implemented in the agricultural enterprise.
This paper describes such an element of the agricultural complex digitalization as smart farming. The developed intelligent automation system for the agricultural enterprise uses the IoT technology to control electrical energy consumption, temperature, and humidity.
The main advantages of using the system are as follows: • The system operates on the platform of single-board computers based on the Arduino microcontroller.

•
The system represents a simple and convenient tool for managing the enterprise's business processes.

•
The use of the developed software for intelligent systems in agriculture significantly reduces labor costs, eliminates human errors, and speeds up the processing of information, even in large agricultural enterprises. Thus, the system turns out to be low-cost, more energy efficient, and easier to use when compared to its counterparts (for example, Cropio [21]).
The abovementioned advantages can increase the profitability and competitiveness of the farming enterprise on the global market and ensure its sustainable and economically sound development, which is a top priority task for any business [37].
Some elements of the artificial intelligence and machine learning technologies can be added to the AAIS to improve the performance of the developed software [38,39]. The use of advanced and powerful microcontrollers, such as the Raspberry Pi 4 [40], STM32 (Nucleo Series) [41], etc., will make the farming system even more efficient and accurate.