Abstract
The goal of this article is the application of a non-adaptive classification algorithm to support the variable management process for internal climate control. The protected agriculture has given many advantages for the care and improvement in the production of almost any food. This work is focused on improving a control system for climate variables. The decision for activating an actuator for the correct care of the crop is very important. A sorting network technique with predefined compare–interchange operations and designed to order data very efficiently is proposed. This approach has been applied to the process of handling actuators within a control system. An advantage of using the sorting networks is that it has an inflexibility when processing a data list; it always takes the same units of time and is executed in the same number of operations for an input size of n. Sorting network–based applications are scarce in the state-of-the-art because there are not many techniques that are effective for sorting very small data sizes. The use of sorting networks in the process of assessing the determination of actuators is proposed. This operation is scheduled in the design of control and performed at each reading back data.
Keywords
Introduction
Due to the global flow of an endless demand for quality, safety, and food presentation, as well as complications of environmental conditions that have been occurring, the greenhouse products have become a niche high level. 1 Currently, Mexico has a steady progress in the implementation of technologies available for the production scheme. These have increased the needs of population and strong climatic changes. 2
The Commission for the Development of Marginal Areas in the late 1970s promoted the use of greenhouses, and for the decade of the 1990s are a variety of greenhouses in Mexico. 3 They acquired advances and technological innovations as well as simple systems of automatic climate control. According to the above, researchers from computer science and electronic areas have joined experts in agronomy, whose efforts to develop automatic control systems have allowed more and better productive results, optimizing the resources used and contributing to preserve the environment.
Recently, applications have been successfully developed in industry based on various automated systems with control algorithms. 4 A control system for greenhouses consists of a series of sensors and slogans that aid to reduce error margins, increase productivity, raise quality standards, and decrease environmental impact. 3
Thus, software development and hardware monitoring have established communication between the user, several sensors and actuators of the system, and database for recording and monitoring parameters. According to Eggins 5 a sensor is a device that produces a usable signal based on the value of a physical quantity, property, or specific condition to be measured. Each acquired measure is recorded and handled according to user needs; thus, he can verify the instructions or establish an order taking into consideration the conditions presented. For example, a heat-sensitive system can perceive the presence of a person, and it may be used for controlling the temperature in a building. Other variables can be directly transmitted to the computer as follows: water levels, pH radiation, among others.
Systems installed in greenhouses have required a great effort to use some sensors and data acquisition systems, such as power cables, distribution, and actuators as mechanical devices that are also part of the environmental system in general. Other works are focused on reducing the costs in time and improving information security for the actuators.3,6 In recent years, different control techniques have been studied such as the feedback control (feed-forward).7,8 Other systems are designed to optimization control,9,10 predictive control, 11 and so on. However, in design controls, low cost and approaches oriented to the crop are focused on infrastructure. An important detail is that the control considers a descriptive value of the average of the received data by the sensors. 7
Sorting technique is essential in many areas of computer science. It is the process of arranging an input dataset into ascending or descending order. Moreover, sorting algorithms are very important due to the large number of applications in data processing of systems, 12 and there are many studies in various areas such as to artificial intelligence, 13 network communication systems, 14 cryptography, 15 cybersecurity, 16 information systems, 17 among others.
Furthermore, there are a large number of sorting techniques in the state-of-art, namely, heapsort, introsort, shear sorting, mergesort, quicksort, and so on.18,19 According to the application domains, the election of the most efficient sorting approach is selected. Thus, taking into account the behavior of comparators during the execution, sorting techniques are classified in two categories: (1) adaptive sorting algorithms, in which the behavior and performance of its operations are marked by the input dataset, and (2) non-adaptive sorting algorithms, in which the permutation of the input data does not impact during the execution, and then the comparison operations are predefined.20,21 Thus, the sorting network (SN) is a non-adaptive technique and executes the same permutation of comparing-interchanging operations.
In this article, the obtained dataset from the sensors is based on the frequency of states regardless of the ends of data; the frequency distribution curves can be relatively skewed to such problems. This work is an opportunity to improve the process between reading data from the sensors and actuators of the system. The proposal is to use SNs for classifying pooled data from the sensing operation by control and ordering them according to the environmental situation to drive and assess the corresponding actuator.
Thus, the environmental control is programmed using open hardware and software. Climatic environment variables help in optimal production of habanero chile (Capsicum chinense Jacq.) In the Bajio Guanajuato, habanero production occurs largely in exotic climes, as Yucatán, Quintana Roo, Tabasco, Chiapas, and Veracruz. In less proportion in Guerrero, San Luis Potosi, Tamaulipas, Zacatecas, and Nayarit. 22 The United States is one of the first places in the production and China Nicole. 23 The intended production of habanero chile in Guanajuato is due to several factors: (1) it is a vegetable of high commercial value in fresh and (2) it has pungency qualities that give healing alternatives and vitamin content. 24
In the past years, different techniques to acquire information for managing greenhouse environment have been proposed.25,26 Usually, in specific regions where a computational system is not present, the agronomists rely on physical recording of lectures based on independent sensors and devices that are randomly placed inside the greenhouse, such as thermometers or wet sensors. With this information, it is possible to determine the current state of environmental variables. When all sensor data are obtained, a specialist proceeds to analyze the information by means of a manual inspection, to determine some region that requires attention. On the other hand, the variables related to greenhouse automation require the use of many devices and sensors that should be installed in strategic regions, according to the specialist experience. Unfortunately, this procedure does not use some analysis to guarantee the uniformity of obtained information related to temperature, both ground and plant humidity, wind speed outside the greenhouse, among others.
According to Hasni et al.,
27
the dynamic behavior of a system is performed considering the formula:
Application of SNs to greenhouse control
This work shows the implementation of an SN in a microcontroller that supports in the ordering of data obtained from the sensing operation. However, this operation has not yet been implemented for that purpose.
The use of controls designed for the transmission of data uses asynchronous communication channels for their information transfer. In case of not having antennas of transmission in different channels, the sending of information (reading temperature or humidity takes about 250 ms) is carried out in a disorderly manner because the sending of any device does not have a certain time unless it is considered a timer within the same control. In addition, sensors present fundamental characteristics and parameters that determine the accuracy of the obtained value such as calibration, sensitivity, accuracy, and resolution. 29 Other characteristics such as delay and dynamic error influence the output value given by the sensor to the control, where the actual value is received. According to the above, it is important to determine the action of the actuators. So it is recommended to codify SNs that are small and fast; this helps operations during the process of data acquisition or for the necessary operations in real-time that minimize resources and prompt information transfer to the database.
To mention some automatization systems that record and transmit information every time, it is the network stations performed by SAGARPA (Secretaría de Agricultura, Ganadería, Desarrollo Rural, Pesca y Alimentación). 30 These systems handle sequential times. Other systems such as by Al-Hadithi et al. 31 have instruments that record the data in memory and analyze the information later, so they use classic sorting methods outside the microcontroller.
For years, the advantage of programming parallel processes in a field programmable gate array (FPGA) for different purposes has been successful (Miller); even the programming is not simple to manipulate the hardware. On the other hand, the use of microcontrollers is increasing, because its predefined configuration helps make the programming more practical and simple.
There are microcontrollers that have been programmed to perform various tasks such as by Al-Hadithi et al. 31 and SAGARPA 30 used by the devices to acquire data and transfer. However, a configuration that contains an SN, which supports the management of data reading, is not programmed. Thus, another purpose of this research is to present an ordering scheme called SN, configured within a microcontroller to support the process of data statistical analysis for decision-making in the management of an automated system for a greenhouse.
The article is organized as follows. Theoretical concepts with respect to the environmental control system greenhouse and SN approaches are discussed in section “Theoretical foundation.” A method to apply an SN technique for improving the data acquisition in a sensing control is described in section “The proposed control system.” The experimental results regarding the proposed method are presented in section “Experimental results.” Section “Conclusion and future work” describes the conclusion and future work.
Theoretical foundation
The environmental control system for the greenhouse
Controlled environments manipulate data from several sensors and send signals to output devices. It is composed of an interface that converts the sensor signal to the processor.32,33 Moreover, the physical sensors are useful for quantitative measurements such as temperature, light, pressure, humidity, among others.
For example, heat sensors are used to detect a person in a building with infrared sensors in alarm systems. Other sensors that can transmit information directly to the processor are as follows: sensors to measure water levels, radiation levels, pH, and oxygen levels. 34
A monitoring program to measure whether a pool is filled out with water is presented in Figure 1. The control system aims to monitor environmental conditions to improve conditions for crop growth. In this system, sensors connected to the control program of humidity, temperature, and other sensors are used to monitor climate environment such as radiation, soil moisture, among others. The greenhouses are equipped mostly by heating, sprinklers, window motor, fans, and control connections to be in constant communication for the sensing task. These systems are called monitoring and they need to activate the actuators.35,36 For example, if the soil moisture is below the lower limit, then the sprinklers are activated to reach soil moisture within limits and prevent the plant from being stressed out. 37

Example of a feedback program control cycle for a fish tank.
The relative humidity (RH) is a measurement of water vapor contained in the air. These
data define the RH that is reflected by different amounts of water vapor in air at
different temperatures. For example, if the vapor density is
Hygrometer data are based on a standardized control to devote the crop. The electrical resistance of this device is low when the RH is high; in case the RH is low, then the electrical resistance is high. So the crop could be susceptible to diseases. Otherwise, whether it is surrounded by high humidity, and the plant does not receive enough moisture, some stress perceptions could be present in the plant.
Solar radiation is the energy source for the growth and development of plants, the main component of plant bio-productivity. 38 However, during the winter months, light generally constitutes the main restriction factor of production. In contrast, an increase of temperature and light inside the greenhouse and the crop are presented in the summer. That is why the importance to have a record of the evolution of the solar radiation.
SNs
SNs are tools that have been used to sort a fixed-size input data. Moreover, the
operations that integrate an SN are known as comparators.18,39 Comparison and interchange among two
elements are the operations performed by a comparator. Thus, if a comparator that receives
the elements (x, y) is to be ordered, then this means that x must not be
larger than y. Hence, after introducing a given size
In the state-of-the-art, an SN is schematically represented by horizontal and vertical
lines. The first one is known as buses, which represent the size of

Example of a sorting network with
For instance, Figure 2 presents
an SN with size
The design of optimal SN is a non-trivial problem, and the research of this issue has
started five decades ago. The construction of an optimal SN is still a challenge. The
optimality is considered according to different criteria, such as parallelism or the
number of comparisons performed. In this work, we refer to the optimal SN as the minimal
number of comparators. In the literature, SN for only small input sizes (less than 16) is
found.
18
So the
most intensively studied in SN is for input size
Algorithm 1 describes the
required code to implement the SN depicted in Figure 2. In general, the quality of the permutation
of comparators is evaluated under certain criteria: (a) whether the SN contains at least
the minimum number of comparators to order a list of
Moreover, to design an SN with quality requires to find the best permutation with the
least number of comparators; this proves that it is the best way to sort a set of
To verify the SN validity and guarantee that it really sorts any input configuration, it
is necessary to evaluate all the
In our example with

Example of the SN for
The first known optimal SN was published in 1945 by P. N. Armstrong, R. J. Nelson, and D.
G. O’Connor for input sizes of
Some recent works are mainly focused on reducing the execution time and complexity
algorithms. However, there are no better solutions than the previous ones considering the
number of compare–interchange operations that conform the SN. For example, in 1997, J.
Koza applied genetic programming that was able to find optimal solutions only for SN with
size
In Batcher
14
and
Al-Haj Baddar and Batcher,
41
an algorithm was formulated with the idea of combining two SNs and
obtaining a new SN; this proposal was known as merge odd–even. In fact, the objective is
to obtain an SN of
Therefore, a non-adaptive algorithm is less common because they are inflexible during the
sorting process. For a given set of comparators, the elements are fixed in an SN to sort a
corresponding input size
In this article, an SN defined by a clonal selection algorithm of the artificial immune system using a subset of comparators is proposed. 19
The proposed control system
In this section, the implementation of an SN for a small size input data in a
microcontroller to order sensors’ data in a greenhouse is presented. The control system is
designed for a greenhouse tunnel type, with 12 m of length and 4 m of width, as well as the
crop is habanero.
45
The system is composed of an microcontroller (Arduino Mega 2560 card and Arduino Ethernet
Shield board), which has connected 16 sensors of soil moisture

Location of sensors inside the greenhouse. The circles represent the sensors of soil moisture distributed in the greenhouse. The temperature is represented with squares and a dotted circle represents the humidity.
The habanero is a demanding crop in temperature; it requires between

The control system design.
The idea is to use an SN to classify data received from several factors. The strategy is to
estimate the value that enables or disables an actuator by the frequency in the data. Algorithm 2 manipulates a set of
where
From lines 5 to 10, they serve to validate the value of
Experimental results
To determine the availability of the actuator humidity, we consider the following
assumptions. The humidity sensor sends (see Table 1) and clusters data in Table 2. The expert establishes the value of
Pooled data of the humidity sensor at a specific time.
Frequency of pooled data under a preset interval.

SN design for
Comparators for sorting network of Figure 6.
The implementation of the SN for activating actuators of environmental control is straightforward. These avoid the delay for the value that triggers the actuator; due to the operation in this exercise, almost every 3000 s is requested.
Figure 7 shows distributed asymmetrical data marked by circular points, and the straight line with square points represents the value obtained after the evaluation operation using equation (1). The SN has been equipped with independent settings’ predefined value comparators to sort data, and the system time is linear.

Data distribution of Table 1.
Conclusion and future work
This article presented the implementation of an SN for a small size input data in a microcontroller to order sensors’ data in a greenhouse. Although the operation of system control design is obvious, its application was not known in these operations. The advantage of the operation is to determine whether the actuators are executed iteratively for each factor, to obtain more accurate results at low cost. The non-linear behavior of environmental factors in the greenhouse is caused by different situations and elements of the infrastructure itself. Therefore, the evaluation of the actuators, according to experts, is more successful if it is based on the frequency of data received by the sensors.
The main purpose of an SN is to design its set of comparators using the minimum quantity to
make an optimal performance with respect to the amount of operations. On the other hand, for
a sensor that receives instrumentation variables and converts them to electrical variables,
it would be interesting to apply SNs to use some combinations of
Thus, the implementation of SN, both in software programs and hardware cards, is easier than traditional sorting algorithms, because an optimal SN requires only the use conditional instructions if-else if-else. The main objective of the designed SN is to apply a reasoning process similar to the human being. Our future works are focused on gathering, storing, and comparing results by means of SNs with different input sizes versus information of manually supervised greenhouses.
This work shows the implementation of an SN in a microcontroller that supports in the ordering of data obtained from the sensing operation. This operation has not yet been implemented for that purpose, considering that the SN algorithm has the advantages mentioned in this research.
Footnotes
Acknowledgements
The authors are thankful to the reviewers for their invaluable and constructive feedback that helped improve the quality of the article.
Handling Editor: Paolo Barsocchi
Declaration of Conflicting Interests
The author(s) declared no potential conflicts of interest with respect to the research, authorship, and/or publication of this article.
Funding
The author(s) disclosed receipt of the following financial support for the research, authorship, and/or publication of this article: This work was partially sponsored by the Instituto Politécnico Nacional (IPN), Consejo Nacional de Ciencia y Tecnología (CONACyT), and the Secretaría de Investigación y Posgrado (SIP) under grants 20170048, 20171918, and 20171192.
