Next Article in Journal
EEG_DMNet: A Deep Multi-Scale Convolutional Neural Network for Electroencephalography-Based Driver Drowsiness Detection
Previous Article in Journal
Dehaze-UNet: A Lightweight Network Based on UNet for Single-Image Dehazing
 
 
Font Type:
Arial Georgia Verdana
Font Size:
Aa Aa Aa
Line Spacing:
Column Width:
Background:
Article

Intelligent Regulation of Temperature and Humidity in Vegetable Greenhouses Based on Single Neuron PID Algorithm

School of Computer and Artificial Intelligence, Beijing Technology and Business University, Beijing 100048, China
*
Author to whom correspondence should be addressed.
Electronics 2024, 13(11), 2083; https://doi.org/10.3390/electronics13112083
Submission received: 22 April 2024 / Revised: 21 May 2024 / Accepted: 22 May 2024 / Published: 27 May 2024

Abstract

:
In order to meet the demands of autonomy and control optimization in solar greenhouse control systems, this paper developed an intelligent temperature and humidity control system for greenhouses based on the Single Neuron Proportional Integral Derivative (SNPID) algorithm. The system is centered around the Huada HC32F460 Micro-Controller Unit (MCU) and the RT-Thread operating system, integrated with the SNPID control algorithm. Through comprehensive simulation, model construction, and comparative experiments, this system was thoroughly evaluated in comparison with traditional PID control systems (cPID) that rely on overseas software and hardwsbuare. Simulation results show that our new system significantly outperforms traditional PID (Proportional Integral Derivative) systems in terms of temperature control stability and accuracy. Experimental data further confirm that, while ensuring cost-effectiveness, the new system achieves a remarkable 50.2% improvement in temperature and humidity control precision compared to traditional systems. The temperature Root Mean Square Error (RMSE) in the experimental greenhouse is 0.734 compared to 1.594 in the comparison greenhouse, indicating better stable temperature control capability. The vents in the experimental greenhouse have a maximum opening of 67 cm and a minimum of 5 cm, showing a quick response property to high temperatures. In contrast, the control greenhouse has a maximum vent opening of 55 cm, remaining unchanged during the test period, which reflects its slower response to temperature fluctuations. These results demonstrate the significant advantages of the designed solar greenhouse temperature and humidity control system in terms of autonomy and control optimization, providing an efficient and economical solution for solar greenhouse environmental management. This system shows significant practical application perspective in promoting intelligent agriculture and sustainable agricultural production, highlighting its broad impact and potential significance.

1. Introduction

With the rapid development of the global agricultural industry, solar greenhouses, as facilities capable of providing optimized growing environments for crops, are increasingly gaining widespread attention. These greenhouses utilize natural sunlight, combined with modern agricultural technology, to provide ideal growth conditions for various crops. This not only enhances crop yield and quality, but also promotes sustainable agricultural development. The use of solar greenhouses has significant advantages in improving crop growth efficiency, reducing energy consumption, and minimizing environmental impacts, hence attracting increasing global interest [1,2]. In Northern China, the sloped solar greenhouse, with its unique structure and energy-saving characteristics, has become an integral part of facility agriculture [3,4,5]. However, traditional solar greenhouse management relies heavily on manual operation, which is not only labor-intensive and inefficient, but also challenges the precise control of the crop growth environment [6,7,8,9,10]. Therefore, the introduction and application of intelligent control technology have become the key technological approach to modernizing solar greenhouse management and improving crop yield and quality [11,12,13].
In recent years, some solar greenhouses have introduced modern intelligent control technologies, achieving automated control of temperature and humidity. These greenhouse systems not only encompass classical automatic control theories, but also support nonlinear, time-varying, and complex systems. For instance, PID control systems that combine expert systems [14], genetic algorithms [15], fuzzy control [16], and neural networks [17] maintain the simplicity and convenience of PID, while significantly enhancing accuracy, stability, and robustness. In recent years, with the increasing demands for controlling complex industrial systems and nonlinear dynamic systems, various advanced control algorithms have emerged. Among these, single neuron PID control and finite-time adaptive event-triggered control based on fuzzy logic are particularly noteworthy in their applications for stochastic nonlinear systems. Single neuron PID control combines the advantages of traditional PID controllers and neural networks, enabling the effective handling of system disturbances and uncertainties through online PID parameter adjustments. However, with the increasing complexity of control systems, single neuron PID control may face certain limitations in some scenarios. In contrast, finite-time adaptive event-triggered control based on fuzzy logic can handle more complex system dynamics and multiple constraints, offering better adaptability and robustness. In recent years, significant progress has been made in the study of the stability of nonlinear systems based on fuzzy control and adaptive control. For example, Wang et al. [18] proposed a finite-time adaptive fuzzy event-triggered control method for nonstrict feedback stochastic nonlinear systems with multiple constraints. This method achieves system stability within a finite time and offers good adaptability and robustness, making it particularly suitable for complex nonlinear systems. The method enhances control adaptability through fuzzy logic systems and reduces system communication burdens via an event-triggered mechanism, thereby improving overall system efficiency. Additionally, Yuan et al. [19] investigated the rapid finite-time stability in the mean square sense of stochastic nonlinear systems and applied it to a single-joint robotic arm. This study not only emphasizes the practical application of achieving system stability within a finite time, but also demonstrates the effectiveness of the method in robotic arm control. Experimental verification and application tests proved the practicality and effectiveness of the method, providing valuable references for the design of control systems in other fields.
Nonetheless, fuzzy logic-based control methods still have several shortcomings in practical applications. Firstly, their design and implementation are complex, requiring the handling of multiple constraints and input delays of fuzzy logic systems and event-triggered mechanisms, which undoubtedly increases the difficulty of development and debugging [19,20]. Secondly, such control methods demand substantial computational resources, which may not be suitable for real-time control and embedded systems with limited computational resources [21,22]. Moreover, although fuzzy event-triggered control has a certain degree of adaptability, its complex design process might result in less robustness in dealing with uncertainties and external disturbances compared to single neuron PID control [23,24]. Regarding the scope of application, single neuron PID control, due to its simple design and low computational resource requirements, is widely used in industrial control, process control, and other fields, offering high flexibility. In contrast, fuzzy event-triggered control is mostly used for specific types of nonlinear stochastic systems and has a relatively narrower application scope, requiring customized designs for specific systems [25,26]. Furthermore, fuzzy event-triggered control relies on complex data transmission mechanisms, reducing data transmission through event-triggered mechanisms but still requiring the design of complex triggering conditions and communication strategies, which increases the difficulty of system implementation to some extent [27,28]. In conclusion, although finite-time adaptive event-triggered control based on fuzzy logic demonstrates unique advantages in handling complex nonlinear systems, its drawbacks in terms of design complexity, computational resource requirements, and flexibility in practical applications still need to be balanced and optimized in specific applications. Additionally, the following literature provides important references for the direction of this study. For example, Yang et al. [29] extensively explored an observer-based event-triggered adaptive fuzzy control strategy in their research, which is applicable to fractional order nonlinear multi-input multioutput systems containing unknown time-varying delays and actuator faults. By constructing an adaptive fuzzy state observer and a serial parallel estimation system, this method can effectively handle the problem of complexity explosion. Through dynamic surface control technology, it has been proven that the signal of the closed-loop system is semi-globally consistent and ultimately bounded, effectively avoiding Zeno behavior and emphasizing its stability and robustness. Wang et al. [18] proposed a finite time adaptive fuzzy event-triggered control strategy for nonstrict feedback stochastic nonlinear systems. This strategy takes into account time-varying output constraints and input delays. By constructing a random nonlinear mapping and using the Pade approximation method to handle input delays, the number of data transmissions is reduced and the impact of tracking errors is alleviated. Finally, the semi-global finite time stability of the closed-loop signal in a probabilistic sense is demonstrated through stability analysis, fully demonstrating its accuracy and stability. Liu et al. [30] studied the finite time containment control problem of fractional order nonlinear multiagent systems with event-triggered inputs. This study developed a new Lyapunov stability lemma and designed an event-triggering condition that combines control inputs and a decreasing function related to errors to reduce communication burden and balance the relationship between system performance and communication resources, ensuring that followers are guided to the convex hull composed of leaders within a limited time. Chen et al. [31] investigated the synchronization problem of fractional order chaotic systems with input delays. By proposing an event-triggered adaptive neural network backstepping sliding mode controller, this method not only reduces the use of communication resources, but also enhances the robustness of the system by introducing fractional order dynamic surface control technology and sliding terms, effectively handling the impact of input delay, and proving the boundedness of all closed-loop signals. Despite significant advancements, current technologies exhibit notable limitations when dealing with the complexity and dynamic changes of greenhouse environments. For example, in the field of greenhouse environment management, Abbood H M et al. [15] developed an intelligent monitoring model based on Radial Basis Function (RBF) neural networks, aimed at optimizing the microclimate of greenhouses by precisely adjusting set points. In a 2021 study, Jia Y. [32] published research on an intelligent greenhouse remote control system based on fuzzy neural networks, which uses fuzzy logic and neural networks to handle complex variables of the greenhouse environment, enhancing the intelligence of remote monitoring. Cheng Y. [16] explored an intelligent control system for agricultural greenhouses based on fuzzy PID control, which optimizes the greenhouse environment by combining fuzzy logic with PID control, improving the system’s adaptability and robustness. In a 2020 study, Qun R. [33] investigated intelligent control technologies for agricultural greenhouse operating robots based on a fuzzy PID path tracking algorithm, aiming to enhance navigation precision and adaptability in complex greenhouse environments. Elanchezhian A and their team [34] evaluated various models used to predict microclimatic parameters inside greenhouses, highlighting the utility of these models in accurately simulating and predicting greenhouse conditions. Yao Y. et al. [35] introduced a research study in which a finite-time tracking control strategy is used for handling nonstrict feedback state delay nonlinear systems with full state constraints and unmodeled dynamics. Although precise in theory, this method could be complex and demanding on computational resources in practice. In a 2023 study, Hou Y. et al. [36] introduced an adaptive finite-time fuzzy control method suitable for uncertain nonlinear systems with asymmetric full state constraints, which optimizes the control process through fuzzy logic to address the system’s uncertainties and asymmetry. Despite the achievements of the above literature, there are still the following limitations: The various greenhouse environment management technologies mentioned in the literature generally exhibit several major limitations: 1. High computational burden and implementation difficulty: Most systems mentioned in the studies, such as the intelligent monitoring model based on RBF neural networks and the remote control system based on fuzzy neural networks, rely on complex neural networks or fuzzy logic. While these technologies are effective in handling data uncertainty and fuzziness, they also significantly increase the system’s computational demands and the difficulty of implementation. 2. Complexity in system maintenance and adjustment: Systems such as fuzzy PID control systems and nonlinear system control strategies with full state constraints, although enhancing operational flexibility and precision, have complex configuration and maintenance processes that usually require in-depth expertise, limiting their application in resource-constrained environments. 3. High implementation costs: The complex system structure and high computational resource demands lead to increased implementation costs, such as the agricultural greenhouse operating robot based on the fuzzy PID path tracking algorithm, which, although increasing the flexibility and efficiency of path tracking, may limit its widespread application in actual agricultural production due to high costs. 4. Gap between theory and practical application: Some theoretically precise control strategies may be overly complex in practice, demanding high computational resources, which may hinder their application in the real world, especially in regions with underdeveloped technological infrastructure. To address the challenges of high computational burdens and complex system maintenance in greenhouse environment management, this study proposes a novel adaptive PID controller integrated with a multilayer perceptron neural network. This controller does not rely on preset models, but adjusts control parameters online through self-learning capabilities, fully leveraging its high adaptability and strong anti-interference ability. This makes the controller particularly suitable for dynamic, rapidly changing, and complex greenhouse environments. Specifically tailored to the characteristics and needs of northern China’s inclined solar greenhouses, we have designed and implemented an intelligent temperature and humidity control system. This system focuses on air temperature as the main control target and air humidity as the secondary target, developed on a domestic independent software and hardware platform. By improving existing control algorithms and adapting low-cost hardware, this system achieves automated precise control of temperature and humidity in the greenhouse, meeting the needs of unattended operation, remote monitoring, and intervention control. The goal of this research is to provide a practical, low-cost, and efficient solution for intelligent control of solar greenhouses in China, promoting the development of smart agriculture. Additionally, this study also provides new theoretical and technical support for intelligent control of solar greenhouses, looking forward to contributing to global agricultural technology innovation. This field of intelligent greenhouse management technology has made several novel contributions, including: 1. Simplified control system design: This study significantly simplifies the design and implementation process of the greenhouse control system using a single neuron PID controller. This simplification reduces the reliance on complex algorithms and advanced computational resources, making the system easier to implement and maintain, especially suitable for resource-limited environments. 2. Improved operational convenience and technological accessibility: The simplicity and efficiency of the single neuron PID control system allow nonprofessional users to easily understand and operate, significantly lowering the technical threshold, enhancing system popularity and user-friendliness. 3. Rapid response to external environmental changes: Due to its directness and efficiency, the single neuron structure can quickly respond to external environmental changes, timely adjusting key parameters such as temperature and humidity, ensuring optimal growing conditions in the greenhouse, thus improving crop growth efficiency and quality. 4. Reduced costs and enhanced economic benefits: Due to low computational demands and system simplicity, the single neuron PID controller reduces operational costs, making intelligent greenhouse technology more economically viable. This is particularly applicable to budget-limited small and medium agricultural operations. 5. Ease of maintenance and expandability: The system’s simple design not only facilitates daily maintenance and troubleshooting, but also allows for technological upgrades and functional expansion based on specific needs, providing higher flexibility and customization.
The rest of the paper is structured as follows: Section 2 provides a system overview, concisely explaining the composition of the system and its functions. Section 3 delves into the design process of the system, covering various aspects of algorithm design. Section 4 discusses the practical implementation of the algorithms on the hardware platforms, detailing the integration challenges and solutions. Section 5 focuses on the validation of the designed system, including simulation comparison tests based on simulation models and comparative tests in actual greenhouse conditions, to ensure the effectiveness and reliability of the system.

2. System Overview

This study is dedicated to the design and implementation of a temperature and humidity control system for sloped solar greenhouses, particularly focusing on the improvement of temperature control algorithms based on ventilation methods. As shown in Figure 1, the core components of the control system include sensors, a central controller, a main control board, and motors. The sensors are responsible for providing real-time temperature and humidity data. The central controller, serving as the core of human–machine interaction and system management, connects to the main control board and is also responsible for communication with the client unit’s server. The main control board, connected to the motors and sensors, controls the operation of the motors based on temperature and humidity information, thereby adjusting the size of the ventilation openings to regulate indoor temperature and humidity. The central controller and main control board’s core is an autonomous platform system-on-chip, comprising an independent MCU and operating system, forming an autonomous software and hardware platform. The MCU uses Huada Semiconductor’s HC32F460 low-power MCU embedded processor, characterized by its low cost, low power consumption, and general architecture. The operating system employs the RT-Thread embedded real-time operating system [37,38], supporting multitasking processes such as multithreading, message queues, event-triggering, and compatible with various communication protocols and peripherals, meeting the system’s requirements for real-time and multitasking processing.
The heart of the control algorithm is the single neuron PID control [39], which uses neurons for online tuning of PID parameters, enhancing the controller’s response speed and anti-interference capability, thereby achieving more stable, accurate, and smooth control effects in complex greenhouse environments. The control algorithm is deployed within the system-on-chip of the main control board. Each main control board connects to a temperature and humidity sensor and a motor, controlling one ventilation opening. As shown in Figure 2, in large greenhouses, multiple main control boards can be configured to achieve coordinated control of multiple ventilation openings to meet the air temperature and humidity adjustment needs within the greenhouse. For example, in the scenario where a large greenhouse is divided into front, middle, and rear sections for segmented control, each master control board is connected to a sensor located near the upper middle part of a ventilation port. This ensures precise capture of the air status after ventilation adjustments, thus enabling effective control.
As depicted in Figure 2, the structure of the segmented control system for large greenhouses, each master control board is responsible for managing the ventilation ports of the corresponding section. Through the RS485 bus, a single master controller can cascade multiple master control boards, allowing users to view the dimensions of each managed ventilation port and temperature and humidity information through the master controller interface, and providing manual control options. Each greenhouse requires at most one master controller to perform these management functions. The master controller, acting as a functional enhancement module, does not directly participate in the environmental control of the greenhouse. Under strict budget constraints, the master controller can be omitted, and the system can operate solely through the master control boards for temperature and humidity adjustment and control. Through this study, we have successfully designed and implemented a solar greenhouse temperature and humidity control system with adaptive online tuning capability. This system can achieve stable, precise, and smooth temperature and humidity control in complex greenhouse environments, providing valuable reference for future research and application of solar greenhouse temperature and humidity control systems.

3. Algorithm Design

This study is dedicated to developing an efficient temperature and humidity control system for sloped solar greenhouses, aimed at optimizing the microclimate conditions within the greenhouse. The main strategy involves precise control of air temperature supplemented by humidity regulation to achieve comprehensive optimization of the greenhouse environment. The system employs ventilation regulation as the primary control strategy, which is not only efficient, but also cost-effective. Considering the limitations of the microcontroller’s computational resources, we designed and implemented a lightweight control algorithm. This algorithm, primarily focused on air temperature, also integrates an auxiliary dehumidification function, ensuring effective operation under diverse environmental conditions. To enhance control efficiency, the algorithm innovatively incorporates a single neuron learning mechanism, endowing the system with the ability for self-learning and adaptive adjustment of PID parameters. This innovation not only improves the system’s control precision, but also enhances its adaptability to various environmental conditions, significantly optimizing the efficiency and effectiveness of greenhouse environmental management.

3.1. Temperature and Humidity Decoupling Control Method

As society progresses, the manufacturing processes across various industries become increasingly complex. Often, these processes involve not just a single controlled and controlling variable, but may feature multiple control loops. To stably and precisely adjust multiple variables, multiple stages must be set. In such production states, there can be various degrees of correlation, coupling, and mutual influence among the loops. Controlling a single loop independently might, due to the coupling effect, interfere with other loops and, in severe cases, even affect the normal operation of the entire system. For systems with significant coupling, adjusting the controllers or matching the variables alone cannot achieve the ideal control effect. Therefore, decoupling becomes particularly crucial for multivariable systems with severe coupling.
Take, for example, the temperature and humidity environment in greenhouse environments, where temperature and humidity are strongly coupled. If the temperature inside the greenhouse increases while the internal air’s moisture content remains unchanged, the saturation vapor pressure in the control system will change, leading to a decrease in internal humidity; conversely, an increase in humidity could also lead to a change in temperature. This coupling issue in the temperature and humidity control process indicates that adjusting a single parameter might trigger a chain reaction affecting other parameters. The greater the degree of coupling in actual production processes, the greater its impact on production, potentially even leading to system imbalance. Thus, decoupling the temperature and humidity in greenhouses can make the control of these variables more convenient.

3.1.1. Decoupler Design

Given the strong coupling characteristics of temperature and humidity inside greenhouse environments, effective methods must be adopted to decouple temperature and humidity to achieve single-loop control of these environmental variables. Although various decoupling methods each have their characteristics, they exhibit different degrees of limitations in practical applications. For instance, while adaptive decoupling algorithms are flexible, they are complex, computationally intensive, and lack robustness in the system; intelligent decoupling has theoretical support, but due to incomplete research, using intelligent decoupling alone fails to meet practical needs; traditional decoupling methods, due to their maturity, are more suitable for this study.
Among conventional decoupling methods, the diagonal matrix method, feedforward compensation method, and identity matrix method have seen extensive practical application. The identity matrix decoupling theoretically achieves the best decoupling effect because the characteristic of the decoupled generalized object is one, but it is difficult to implement, especially in cases of complex object characteristics where decoupling may not be achievable. The diagonal matrix decoupling is similar to the identity matrix method, but also struggles to effectively decouple complex objects due to differences in transfer functions. In contrast, due to its simple network structure, good stability, and high efficiency, the feedforward compensation decoupling method has become the most widely used.
Based on the above analysis, this paper opts to use the feedforward compensation decoupling method to design a temperature and humidity decoupler. The basic structure of this method is shown in Figure 3; the system input consists of two signals, X1(s) and X2(s), representing temperature and humidity, respectively; the system outputs are Y1(s) and Y2(s), reflecting the system’s response to temperature and humidity; the controller uses a single neuron PID controller, with transfer function models labeled as GP21(s) and GP12(s). Moreover, the mutual coupling transfer functions of temperature and humidity in the system are G11(s), G21(s), G22(s), G12(s), ensuring that the control system can effectively decouple in response to changes in temperature and humidity, thereby maintaining the stability of the internal environment of the vegetable greenhouses.
The feedforward compensation technique was initially developed to mitigate disturbances in systems, and is similarly applicable to decoupling control systems. In practical applications, the impact of the controller’s output U1 on the output variable Y2, and U2 on Y1, are considered internal disturbances. This method enables effective elimination of these disturbances. According to the principle of disturbance compensation in feedforward compensation, the influence of U1 on the controlled parameter Y2 is governed by Equation (1), while U2’s impact on Y1 is described by Equation (2). To ensure the complete neutralization of the effects of U1 on Y2 and U2 on Y1, the conditions in Equations (3) and (4) need to be fulfilled.
Y 2 ( s ) = U 1 ( s ) G 21 ( s ) + U 1 ( s ) G P 21 ( s ) G 22 ( s ) = U 1 ( s ) ( G 21 ( s ) + G P 21 ( s ) G 22 ( s ) )
Y 1 ( s ) = U 2 ( s ) G 12 ( s ) + U 2 ( s ) G P 12 ( s ) G 11 ( s ) = U 2 ( s ) ( G 12 ( s ) + G P 12 ( s ) G 11 ( s ) )
G 21 ( s ) + G P 21 ( s ) G 22 ( s ) = 0
G 12 ( s ) + G P 12 ( s ) G 11 ( s ) = 0
Based on satisfying the conditions outlined in the aforementioned equations, we can derive the mathematical model for the temperature and humidity decoupling stage, GP21(s), as indicated in Equation (5). Similarly, the mathematical model for the humidity to temperature decoupling stage, GP12(s), is represented by Equation (6). By analyzing the transfer function matrix of the control system (Equation (7)) and applying Equations (5) and (6), we can compute and determine the mathematical models for the decoupling compensation stages GP21(s) and GP12(s), represented by Equations (8) and (9), respectively. This series of models and compensation techniques offers an effective solution for the design of control systems, ensuring high accuracy and stability.
G P 21 ( s ) = G 21 ( s ) G 22 ( s )
G P 12 ( s ) = G 12 ( s ) G 11 ( s )
G 11 ( s ) G 12 ( s ) G 21 ( s ) G 22 ( s ) = 5 180 s + 1 4 162 s + 1 2.1 175 s + 1 3 126 s + 1
G P 21 ( s ) = 0.8 180 s + 1 162 s + 1
G P 12 ( s ) = 0.7 126 s + 1 175 s + 1
After integrating the decoupling stages for temperature and humidity into the control system, the original system—comprising two mutually influencing coupled systems—transforms into two independent single-input single-output systems. This transformation prevents interference between the outputs of various variables, thereby simplifying the control process. Through this decoupling, each system can be adjusted independently, significantly enhancing the control’s flexibility and precision. The equivalent system’s structure post-decoupling is detailed in Figure 4. This approach not only optimizes control strategies, but also offers a more efficient and intuitive solution for managing complex systems.
The implementation procedure of the single neuron PID decoupling control algorithm is outlined as follows:
Step (1): Initialization. Set initial weight coefficients, proportional coefficients, and learning rates for the proportional, integral, and derivative aspects for two single neuron controllers.
Step (2): Data Collection. Collect actual temperature and humidity readings from the decoupling control system, compare these to preset values, and compute the current control errors for temperature and humidity.
Step (3): State Transition. Process the obtained control errors to produce the state variables required for neuronal control, which serve as the network’s two groups of input signals.
Step (4): Weight Adjustment. Employ the supervised Hebb learning rule to update and adjust the weight coefficients for controlling temperature and humidity.
Step (5): Control Output Calculation. Based on the updated weight coefficients, calculate the control outputs for temperature and humidity at the current moment.
Step (6): Iterative Loop. Return to Step (2) to commence the next cycle of temperature and humidity sampling and control.
This algorithm enhances the performance of traditional PID controllers by integrating concepts and mechanisms from neural networks, rendering them more adept at handling complex and nonlinear control environments.

3.1.2. Simulation Experiments and Results Analysis

By integrating the SNPID controller with the feedforward compensation decoupler, the decoupling control system is structured to manage temperature and humidity environmental variables, enabling temperature and humidity decoupling simulation experiments in greenhouse environments to validate the decoupling effects. The design of the simulation experiment for assessing the decoupling effects of temperature and humidity is outlined as follows:
Phase 1: The environmental temperature is set to 25 °C and humidity to 60%.
Phase 2: The temperature setting is adjusted to 30 °C, with the humidity setting remaining constant.
Phase 3: The humidity setting is adjusted to 70%, while the temperature setting remains unchanged.
The initial parameters for the single neuron PID decoupling controller in disturbance and dynamic tests are detailed in Table 1.
(1)
Undecoupled dynamic test
In the undecoupled dynamic test, the decoupling components GP21(s) and GP12(s) are omitted from the control system, with the controller’s PID parameters set as outlined in Table 1. Figure 5 displays the temperature and humidity control curves without decoupling, revealing the coupling impact between these variables. The temperature control curve in Figure 5 shows that initially, the temperature rises sharply and peaks quickly before dropping and fluctuating, eventually stabilizing. During the second phase, from 100 to 150 s, alterations in the temperature set point induce fluctuations, with noticeable oscillations in the temperature curve indicating system instability due to humidity’s coupling effects.
The humidity control curve in Figure 5 illustrates a rapid increase at the start, followed by several fluctuations before stabilizing. In the third phase, from 150 to 200 s, changes in the humidity set point lead to a significant change in humidity, causing fluctuations in an otherwise stable temperature. This further confirms the disturbance of humidity regulation on temperature stability, showcasing the system’s coupling problems.
Overall, Figure 5 vividly illustrates the interplay and coupling between temperature and humidity, which significantly disrupts the system’s operational stability, highlighting the necessity of decoupling. In the absence of effective decoupling, any adjustment in temperature or humidity could provoke unstable responses in the system, adversely affecting the productivity and quality control within the greenhouse.
(2)
Dynamic test
The dynamic test utilizes a single neuron PID decoupling controller. Figure 6 depicts the results of temperature and humidity control using this controller during the dynamic test. The experiment is segmented into three stages, adjusting the set points for temperature and humidity across these phases to evaluate the controller’s effectiveness and responsiveness.
As indicated by the temperature control curve in Figure 6, during the first stage, the temperature is set at 25 °C. The temperature quickly rises, overshooting to approximately 37 °C, then rapidly decreases and stabilizes at 25 °C within 21 s. In the second stage, the set point increases to 30 °C. The temperature starts to climb at 100 s, reaches the new set point in 4 s, begins to decrease after 8 s, and stabilizes at the set point after 18 s, demonstrating a quick response and minimal overshoot.
The humidity control curve in Figure 6 for the first stage shows a set point of 60%, with humidity rapidly rising and briefly overshooting to 90% before gradually declining to stabilize at 60% around 47 s. In the third stage, the humidity set point is raised to 70%, with humidity starting to increase at 150 s, achieving the new set point in 11 s, and thereafter maintaining stability. These graphs reveal that the single neuron PID decoupling controller manages temperature and humidity variations with rapid responsiveness and commendable steady-state performance. Despite some overshoot during adjustments, the controller efficiently adapts to new set points and swiftly stabilizes following perturbations, demonstrating its efficacy in dynamic control despite certain structural limitations that occasionally prevent perfect stabilization at set points.
(3)
Perturbation experiments
Figure 7 illustrates the control outcomes for temperature and humidity using a single neuron PID decoupling controller during a disturbance test. Disturbance signals were applied to both temperature and humidity at 100 s within the test to evaluate the control system’s responsiveness and stability. According to the temperature control curve shown in Figure 7, the temperature initially rose rapidly, then overshot and quickly decreased to the set point, maintaining relative stability thereafter. At 100 s, the system received a disturbance signal that increased the temperature by 2 °C, resulting in a brief rise and oscillation in temperature, but it swiftly stabilized near the original set point by approximately 120 s. This indicates that the control system possesses excellent disturbance suppression capabilities and rapid recovery characteristics.
Likewise, the humidity control curve in Figure 7 indicates that at 100 s, the humidity was subjected to a disturbance signal that increased by 3%. This led to a brief increase and minor fluctuations in humidity before the system quickly adjusted, stabilizing back at the original set point around 110 s. This further demonstrates the control system’s ability to swiftly adjust its response to disturbances, effectively maintaining the stability of environmental parameters.
In summary, Figure 7 showcases the single neuron PID decoupling controller’s ability to respond to disturbances in a dynamic environment, quickly reverting to a stable state despite changes in external conditions, thus confirming its efficacy and reliability in practical applications.

3.2. Adaptive Fuzzy PID Controller Settings

3.2.1. Overview of Traditional PID

The acronym PID stands for “Proportional”, “Integral”, and “Differential”, which are derived from the initial letters of these three English words. These terms represent three fundamental control strategies. A PID controller is a type of parallel controller widely used in the field of automatic control. It integrates these three control methods to adjust errors during the control process, thereby stabilizing the controlled system. For instance, in process control models like greenhouse temperature control, PID controllers are commonly used to achieve precise regulation. In most cases, a control system will include at least one standard PID controller and a specific control target. The operating principle of a standard PID controller is illustrated in Figure 8: the controller receives the error between the actual value and the set value of the controlled parameter as input. It then adjusts this through proportional, integral, and differential calculations, thereby outputting a control signal and acting on the controlled object to achieve the purpose of closed-loop control.

3.2.2. Control System Structure

In the field of fuzzy control systems research, systems are typically classified into single-variable fuzzy control and multivariable fuzzy control. To ensure the effectiveness of control while avoiding excessive system complexity, this study employs a two-dimensional variable fuzzy controller, hereinafter referred to as the fuzzy controller. The operational framework of this fuzzy control system is illustrated in Figure 9. In this system, the fuzzy controller is integrated with a traditional PID controller: the fuzzy controller is responsible for real-time adjustment of PID parameters, while the PID controller directly controls the system based on these adjustments. Specifically, the inputs to the fuzzy controller include the error (E) and the rate of change of the error (EC). According to the principles of fuzzy control, this process encompasses three stages: fuzzification of input variables, aggregation of fuzzy rules, and defuzzification. Ultimately, the controller outputs three adjustment parameters, ΔKP, ΔKI, and ΔKD, which are then used as inputs to the traditional PID controller, allowing for real-time dynamic adjustment of PID control coefficients. This integration not only optimizes control precision, but also enhances the system’s adaptability to complex dynamic environments.
K P = K P 0 + α 1 Δ K P
K I = K I 0 + α 2 Δ K I
K D = K D 0 + α 3 Δ K D
In Equations (10) to (12), KP, KI, and KD represent the current values adjusted by fuzzy control; KP0, KI0, and KD0 denote the initial values of the control coefficients; α 1 , α 2 , and α 3 represent the proportional factors.

3.2.3. Control Principle

In this study, the input variables of the system are initially fuzzified, transforming deterministic values into fuzzy vectors. During this process, the error (E), the rate of change of the error (EC), and the adjustment parameters ΔKP, ΔKI, and ΔKD are uniformly defined within a seven-level scale: Negative Big (NB), Negative Medium (NM), Negative Small (NS), Zero (O), Positive Small (PS), Positive Medium (PM), and Positive Big (PB). The domain of these fuzzy sets comprises the integer set {−6, −5, −4, −3, −2, −1, 0, 1, 2, 3, 4, 5, 6}, and all membership functions utilize triangular shapes to simplify the calculation process and enhance intuitive interpretation. Specific assignments for fuzzy variables are detailed in Table 2 of the study. The fuzzy control rule table is based on the summarized experience of operators and experts, guiding the output decisions of the fuzzy controller. For instance, when both the error E and the rate of change of the error EC are large, ΔKP should be increased to accelerate the system response, while ΔKI and ΔKD should be decreased to avoid oversaturation and significant overshooting during the control process. The specific fuzzy control rules are displayed in Table 3, Table 4 and Table 5. Based on these control rules, the fuzzy vector outputs for ΔKP, ΔKI, and ΔKD are obtained. These fuzzy vectors are then converted into specific numerical values through the center of maximum method, thereby allowing real-time adjustment of the parameters in the traditional PID controller. Through this method, the fuzzy control system can flexibly adjust its control strategy based on real-time data, thus enhancing its ability to adapt to complex changing environments while ensuring system stability and response speed.

3.2.4. Model Building

The greenhouse system is a complex system; with the help of MATLAB/Simulink, a simulation model was constructed, as shown in Figure 10. The PID parameters were adjusted using the critical ratio method. The proportional coefficient is 0.8, the integral coefficient is 0.005, and the differential coefficient is 32.89. Input the proportional factors for inputs and outputs, as well as the fuzzy control rules, into the adaptive fuzzy PID controller.

3.3. Design of SNPID Controller

Single neuron networks are a significant branch in the field of intelligent control, inspired by studies of brain physiology. These networks mimic the working mechanisms and processes of the brain, forming an entirely artificial network with a directed graph topology. The basic principles of neural control include using neuron models to simulate the transmission and processing mechanisms of neural cell electrical signals. Within this framework, single neuron networks handle information by responding to continuous or intermittent input states, optimizing the generation of control commands.
In terms of complex system control, single neuron networks demonstrate remarkable advantages. Compared to traditional PID control algorithms, single neuron PID control algorithms show superior performance in improving the quality of control systems, adapting to environmental changes, and enhancing the robustness of control systems. Therefore, research on neuron networks in control and recognition has become a focal point in the current field of control systems.
The SNPID algorithm is an advanced control strategy that has evolved from the traditional PID algorithm and is widely used in the control field [40,41]. This algorithm combines the adaptive learning characteristics of artificial neurons, enabling it to dynamically adjust PID parameters based on system errors, significantly enhancing control precision and system robustness [42]. The self-learning capability of the neuron endows the SNPID algorithm with powerful adaptability when dealing with nonlinear, uncertain, and time-varying systems. This not only maintains the simplicity and high reliability of the traditional PID algorithm design, but also significantly improves its control performance in complex dynamic systems [43,44]. Compared to traditional PID, the SNPID algorithm exhibits stronger adaptability and real-time performance, making it particularly suitable for handling systems with complex nonlinearity and time-varying characteristics, such as greenhouse environment control. In practical applications, the SNPID algorithm has been successfully applied to various control system designs, including DC (direct current) stepper motors, pH (potential of hydrogen) control systems, and agricultural machinery [45,46], demonstrating faster adjustment times and lower error rates than traditional PID and fuzzy PID algorithms. Therefore, given the complex nonlinearity and dynamic characteristics of greenhouse environments, as well as the computational resource limitations of control systems, adopting the SNPID algorithm can be considered an effective solution to meet the demands for adaptability, interference resistance, and response speed of control algorithms. In this study, we employed the SNPID algorithm for air temperature control. Figure 11 comprehensively illustrates the structure of the controller design based on the SNPID algorithm, revealing its application and working mechanism in the regulation of greenhouse environments.
In the SNPID controller depicted in Figure 11, adjustment of the vent opening to u(k) the core component is a neuron with three inputs and three outputs. The neuron’s input parameters are directly related to the temperature difference, denoted as e ( k ) , and include  x 1 ( k ) = e ( k ) x 2 ( k ) = e ( k ) x 3 ( k ) = 2 e ( k ) . The neuron employs a supervised Hebbian learning rule for its learning process, a rule formulated by combining the supervised Δ (Delta) learning rule with the Hebbian learning rule [47]. According to this learning mechanism, the adjustment formulas for the three input weights of the neuron,  w k p w k i w k d , can be derived. These specific formulas are detailed in Equations (13) to (15).
w k p ( k ) = w k p ( k 1 ) + η k p u ( k 1 ) x 1 ( k 1 ) z ( k )
w k i ( k ) = w k i ( k 1 ) + η k i u ( k 1 ) x 2 ( k 1 ) z ( k )
w k d ( k ) = w k d ( k 1 ) + η k d u ( k 1 ) x 3 ( k 1 ) z ( k )
In this context,  η k p η k i η k d  represent the learning rates, playing a crucial role in the adjustment of the neuron’s weights. For the weight adjustment, the error from the previous moment is used as a teacher signal, denoted as z ( k ) and z ( k ) = e ( k 1 ) . This design ensures that the neuron’s learning process can adaptively adjust based on actual error conditions, thereby enhancing the accuracy and efficiency of the entire greenhouse temperature control system.
Determining the learning rates η k p , η k i , and η k d is a key step, requiring multiple adjustments during the experimentation process to precisely set these parameters. To assist this debugging process, we referred to general methods provided in the existing literature [48,49,50]. After determining the learning rates, the next step is to adjust the neuron’s weight output through normalization. The main purpose of normalization is to ensure the convergence of the system’s control and to expedite this process [51]. The outputs after normalization determine the proportional, integral, and derivative coefficients of the PID controller, which are crucial elements in the control process. The specific formulas for normalization are detailed in Equations (16) to (19). Through this series of steps, the SNPID control system can more accurately reflect and adapt to dynamic changes during the system’s learning process, thus improving the performance and efficiency of the entire greenhouse control system. This process not only optimizes the controller’s response, but also enhances the system’s adaptability to changes in the greenhouse environment.
w s u m ( k ) = w k p ( k ) + w k i ( k ) + w k d ( k )
k p ( k ) = w k p ( k ) w s u m ( k )
k i ( k ) = w k i ( k ) w s u m ( k )
k d ( k ) = w k p ( k ) w s u m ( k )
The core of the control algorithm described in this study is centered on the tuning process of a single neuron. Initially, the system is initialized by inputting error values, which form the basis for subsequent adjustments. Then, based on these error inputs, the system precisely adjusts the control weights to optimize the control process. Finally, the adjusted PID (Proportional-Integral-Derivative) control coefficients are calculated and outputted, critically affecting the controller’s performance and responsiveness. During this process, the self-learning function of the single neuron allows for the PID coefficients to be adaptively adjusted online according to changes in error. This mechanism not only enables real-time adjustment of PID coefficients, thereby significantly enhancing control precision, but also allows for effective operation on low-cost computational platforms due to the lightweight and low complexity characteristics of the single neuron tuning module. Although the accuracy of a single neuron might be slightly reduced compared to a Multi-Layer Perceptron (MLP), its impact on improving PID control is still significant. After completing the PID coefficient tuning, the control laws of the SNPID controller are derived based on the principles of incremental PID, as shown in Equations (20) and (21). The rules for setting these coefficients reflect a critical balance between system response speed and stability: larger coefficient values can speed up system response but may lead to greater overshoot; smaller values slow down the response but contribute to enhanced stability [52,53,54,55].
u ( k ) = K k p ( k ) x 1 ( k ) + k i ( k ) x 2 ( k ) + k d ( k ) x 3 ( k )
u ( k ) = u ( k ) + u ( k 1 )
The SNPID controller, while retaining the classic structure of PID, introduces adaptability in its control coefficients. This adaptability allows the SNPID to dynamically adjust its proportional, integral, and differential coefficients based on the changes in error. Therefore, compared to traditional PID controllers with fixed coefficients, the SNPID offers superior tracking performance and robustness when dealing with systems characterized by nonlinearity and significant time delays [56,57]. In the temperature and humidity control system designed in this study, the workflow of the SNPID controller is illustrated in Figure 12. This flowchart elaborately displays the real-time adjustment and control execution process of the SNPID controller, thereby demonstrating its efficient adaptability and control capabilities in dynamic environments.
For large agricultural greenhouses, considering the relatively slow changes in temperature, the control cycle of the SNPID controller should be appropriately long to reduce the frequency of control operations and allow the temperature to stabilize. Based on this characteristic, the control cycle is set to respond once every 5 to 10 min. Such a setting helps to smooth out short-term temperature fluctuations and reduces the system’s overreaction. In each control cycle, the controller calculates the difference between the average air temperature over the past five minutes (denoted as T i ) and the target temperature (denoted as T g ). The controller’s output is the adjustment amount of the ventilation opening, denoted as u ( k ) , which represents the current opening area of the ventilation as a percentage of its maximum area.
To illustrate specifically, consider a ventilation opening with a transverse width of 60 m and a top length of 1.5 m, with a maximum area of 90 square meters. The actuator controlling this ventilation opening is a constant-speed DC motor, set at a certain speed M v . If the area of the ventilation opening in the previous control cycle was A ( k 1 ) with a corresponding opening degree of u ( k 1 ) , the area of the ventilation opening at the previous moment can be determined using formula A ( k 1 ) = A max × u ( k 1 ) . For the current moment, the area of the ventilation opening is set to A ( k ) = A max × u ( k ) , with an area change of A = A ( k ) A ( k 1 ) , and the maximum longitudinal length of the opening is l . Therefore, the relationship between the change in the opening degree of the ventilation u ( k ) and the running time of the constant-speed DC motor t is as shown in Equation (22). Based on the change in opening degree, the required running time of the motor can be calculated. This calculation process is crucial for achieving temperature control, as it ensures that the adjustment of the ventilation opening matches the needs of temperature change.
t = A max M v l u ( k )
Based on the theoretical framework and formulae of the algorithm, this study employs the Simulink toolkit within MATLAB 2023 software to construct a simulation model of the SNPID controller for experimental verification of the proposed method. The SNPID controller utilizes an input mechanism based on discrete incremental PID. Therefore, the specific implementation of the SNPID controller simulation model can be referred to in Figure 13.
This study is based on the principles of discrete incremental PID control, taking the current temperature error (delta temp) as the input variable x 1 ( k ) . By employing the Delay module in Simulink software, we are able to obtain the error values of the previous moment and the moment before that, which are calculated as x 2 ( k ) and x 3 ( k ) , respectively. These inputs are then fed into the weight adjustment modules (namely, get_wkp, get_wki and get_wkd) for processing.
The core principle of the weight adjustment module is based on supervised Hebbian learning, which adjusts the neuron weights based on the input errors. The adjusted weights are subsequently input into the PID coefficient tuning module (get_PID), where the PID coefficients are tuned according to Equations (16) to (19). Finally, the incremental control signal u ( k ) is calculated as the output according to Equations (20) and (21).

3.4. Temperature and Humidity Control Algorithm Design

The crux of this design centers on the SNPID controller, supplemented by a dehumidification algorithm, aiming to adjust the air temperature and humidity in the greenhouse based on preset times, temperature, and humidity values. Taking the daylight hours from 7:00 to 19:00 as an example, and particularly considering the ideal temperature range for tomato growth is 20 °C to 30 °C [58], we set the target temperatures for the morning and afternoon to 24 °C and 25 °C, respectively, given the large area of the greenhouse and the limitations of ventilation regulation. The primary task of the SNPID controller is to regulate the ventilation openings to ensure the greenhouse temperature remains within ±1 °C of the target temperature. Additionally, we set a low-temperature alert at 18 °C and a high-temperature alert at 28 °C for corresponding ventilation adjustments.
During the critical periods of 7:00 to 8:00 and 18:00 to 19:00, if the humidity inside the greenhouse exceeds 80% and the temperature is above 19 °C, the auxiliary dehumidification algorithm will be activated. This process is mainly controlled by the SNPID controller, known as the SNPID auto-control mode. Furthermore, we introduced Morning Breeze and Evening Breeze modes, focusing on dehumidification operations. Under specific temperature conditions, the system will enter a preparatory mode before transitioning from Morning Breeze to SNPID auto-control mode to ensure a smooth control transition.
The entire workflow of the temperature and humidity control algorithm is shown in Figure 14. If the trigger conditions for Morning Breeze, Preparatory, and Evening Breeze modes are not met, the system will directly switch to the SNPID auto-control mode, with the SNPID controller responsible for adjusting the ventilation openings. The following will introduce the control algorithm using the SNPID auto-control mode as an example.
The essence of the SNPID controller lies in its unique SNPID control algorithm. To illustrate with a specific example, suppose the greenhouse is cultivating tomatoes, and during the daylight hours of 7:00 to 19:00, the Morning Breeze, Preparatory, and Evening Breeze modes are not triggered, then the greenhouse temperature will be controlled by the SNPID auto-control mode. At night, from 19:00 to the following morning at 7:00, to maintain the temperature, the ventilation openings will be sealed.
In some cases, if the Morning Breeze, Preparatory, and Evening Breeze modes are all triggered, such as after the Morning Breeze and Preparatory modes have ended and before the Evening Breeze mode begins, the temperature control of the greenhouse is still executed by the SNPID auto-control mode. This mode is the core control mode of the entire system, responsible for maintaining the ideal temperature of the greenhouse under complex and dynamic environmental conditions. The workflow of this mode is displayed in Figure 15.
Table 6 comprehensively presents the operating procedures of the SNPID auto-control mode, along with its relevant parameters and conditions. This table clearly displays the control flow and operational steps under the SNPID auto-control mode and details the system’s responses and handling methods under various temperature and humidity conditions in the greenhouse.

4. Algorithm Deployment on Hardware Platforms

4.1. Migration and Implementation of the Runtime Environment

4.1.1. Bootloader Program Design and Implementation

In traditional embedded platforms, firmware updates typically involve replacing storage or using programmers to burn new system code. This not only increases time and cost investments, but also, due to the high-level permissions required, improper operations can easily lead to damage to hardware and software integrity, thereby significantly increasing maintenance risks. Thus, reducing the frequency of operations that require high permissions is crucial for enhancing project stability. By incorporating a bootloader and supporting In-Application Programming (IAP) technology, it is possible to deploy bootloader code programmatically in the initial phase. Subsequently, the bootloader can use communication ports such as USB serial ports or RS485 serial ports to achieve online updates of RT-Thread system code without needing to replace hardware or use high-permission JTAG ports. During the update process, the bootloader first downloads the new program to a reserved area in internal storage and performs program verification after the download is complete. Once verification is successful, the program is written into the main system data area, thus achieving a seamless system update. Additionally, the program verification mechanism further enhances the security and reliability of the update process.
The bootloader also possesses basic safeguard functions. Without bootloader support, the system might return to a faulty state upon restart after encountering severe errors that cannot be resolved by reset. In such cases, it is impossible to repair via communication means such as serial ports, and reprogramming through a programmer is required, which is not only time-consuming and labor-intensive, but also carries higher risks. However, due to its simple structure and high stability, the bootloader does not participate in actual control, and can effectively isolate itself from complex control codes and operating systems, maintaining independence. Therefore, in the event of a main system crash, the integrity of the bootloader’s code remains unaffected, and the system can still reboot into bootloader mode to communicate with the external world for fault repair.
In this design, the bootloader implements basic judgment-wait-jump functionality. By default, the system waits for 5 s. If no command represented by the number 0 is received through the USB serial port during this period, the system will jump to the main system space to perform regular business functions. If a command represented by the number 0 is received during the waiting period, the bootloader activates the IAP function, receives the upgrade data packet via the Ymodem protocol from the port, writes the data to the main system area after parity checks, and then jumps to the updated application to execute corresponding functions after the update is complete. Additionally, in its workflow, the bootloader also needs to load the Huada Chip Function Library Device Driver Library Utility, configure the Clock Management Unit (CMU) to high-speed mode at 168 MHz, set up the timer to count at a frequency of 1 ms, and enable the UART serial port to support efficient communication and timing management. The workflow design of the bootloader is detailed in Figure 16.
After the bootloader starts and completes initialization, it polls the serial port approximately every 5 milliseconds within a 5 s window. If no command represented by the number 0 is received during this period, the bootloader will deactivate the peripherals that were enabled during this time, such as GPIO and UART, and then jump to the main system to continue execution. Conversely, if a command represented by the number 0 is received, the bootloader activates the Ymodem library to receive firmware update data from the serial port according to the Ymodem protocol. After the data are received, they undergo parity checking. If the check is successful, the new firmware is written to the system. Subsequently, the system will jump to the updated main system to perform corresponding functions. If the check fails or if an error occurs during data transmission, the bootloader will discard the received data and output an error message via the serial port, stating “Transmission error, please resend.” It will then check again if the command represented by the number 0 is received from the serial port to decide whether to continue receiving firmware data or jump to the main system. This process ensures the safety and reliability of the firmware update while providing an error handling mechanism to address potential data transmission issues.

4.1.2. Tsraide’s Real-Time System Porting

Considering that the Huada HC32F460 chip has not received support from RT-Thread at the early stage of system development, it is necessary in this design to integrate the source code of the RT-Thread real-time operating system with Huada’s Device Driver Library. This integration enables RT-Thread to run smoothly on this MCU. The version of the RT-Thread system used in this porting is 3.1.3, and its program files have been categorized and organized according to their functions. The specific functions corresponding to the files are described in Table 7.
Based on the template routines provided by Huada, this design has integrated the RT-Thread source code and enabled core components within the project, as shown in Figure 17, Figure 18 and Figure 19. In Figure 17, the ‘app’ folder is used to store user programs, and all subsequent functional module codes are placed here. The ‘startup’ folder contains essential files needed for startup, such as ‘main.c’, ‘startup_hc32f460.s’, ‘ddl_config.h’, and ‘rtconfig.h’. The ‘driver’ folder houses the function codes from the Device Driver Library, while the ‘finsh’ folder contains the codes for RT-Thread’s terminal manager component. The ‘cpu’ folder and ‘rtt’ folder store the codes related to the ARM processor and the RT-Thread kernel source code, respectively.
In the project configuration files ‘ddl_config.h’ and ‘rtconfig.h’, the FinSH, GPIO, and USART components are enabled through macro definitions. Additionally, this design involves writing library functions related to register unprotection, clock configuration, interrupt handling, timers, and serial communication.
After completing the porting and code writing, compilation and debugging were conducted. Once the compilation was successful, the program was burned onto the device, and upon startup, a preset welcome screen (as shown in Figure 20) was displayed through the terminal output, verifying the proper functioning of program logic and serial communication. These steps ensured the normal operation of the control system software modules within the software environment, providing solid software support for the overall system’s stability and functionality.

4.2. Control System Software and Hardware Architecture Design

4.2.1. Overall Hardware Design

This control system consists of two parts: the main control board and the central controller. The part directly related to the control task and connecting external devices such as motors and sensors is called the main control board, responsible for actual greenhouse environment regulation. The part that provides an interactive interface, connects to the unit cloud server, and is responsible for networking, uploading greenhouse information, receiving instructions, managing the main control board, and other functions is called the central controller. It is responsible for monitoring and managing the working status of the main control board, as shown in the block diagram in Figure 21.
Both the central control unit and the main control board are implemented using the autonomous MCU HC32F460, connected through the RS485 bus. A single central control unit can manage multiple main control boards, and a single main control board is only managed by one central control unit. It can also work independently without the central control unit. The structure of the central control unit is relatively simple, with GSM module providing networking function, EEPROM module storing equipment information of the central control unit, power module supplying power to the equipment, screen and button module for staff operation, RS485 module providing connection function with the main control board, and the central control unit mainly serving as a transfer management function and not responsible for actual control. The design process is similar to the main control board, but the components carried are different, which will not be repeated here. In addition to supporting components such as RS485 module, power supply, buttons, digital tube, buzzer, and module, the main control board also adds motor drive and motor detection modules to achieve motor control functions, temperature and humidity sensor module, and achieving detection of the greenhouse environment. At the same time, it also provides debugging/burning modules for debugging and program burning.
As shown in Figure 22, the design scheme of the central controller includes a main control board, which can be connected to other central controllers and main control boards through RS485 interface, and also supports independent operation. All code related to control functions is executed in the on-chip system. The main control board is equipped with digital tubes to provide basic display functions and integrates buttons to achieve basic user interaction. In addition, two relays are installed on the main control board, which are connected to the motor and controlled to turn on or off through GPIO to achieve forward and reverse rotation of the motor. This design does not limit the model of the motor, so it can be compatible with DC motors produced by multiple manufacturers.
The operating speed of the motor is a fixed speed. By changing the direction of rotation of the motor, the motor can roll up or unfold the plastic film on the roof to adjust the size of the roof ventilation opening. Due to the fixed width of the plastic film, the adjustment of the ventilation opening is actually equivalent to controlling the roll up length of the ceiling film, which is the circumference of the motor rotation. Considering the constant speed operation characteristics of the motor, the adjustment of the ventilation opening can be achieved by controlling the running time of the motor. Therefore, by precisely controlling the running time of the motor, the length of the film covering the ventilation opening can be adjusted, thereby changing the opening area of the ventilation opening.
This article focuses on the software and hardware development of the main control board. The stable driving of the main control board hardware and the accurate execution of software programs are key to ensuring the normal operation of control algorithms, thereby achieving the predetermined control functions. The successful deployment and operation of the single neuron PID control algorithm on the main control board is the algorithm core of this design scheme.

4.2.2. Main Control Board Program Process Design

This article takes the control system scheme of a single central controller and a single main control board as an example to explain the independent operation ability of the main control board and its ability to interact with the central controller through RS485 bus and Modbus communication protocol. As shown in Figure 23, the program workflow of this system includes steps such as starting the device, executing Bootloader, jumping to the main system program, and executing various status checks and control tasks.
After the system starts, the Huada HC32F460 chip on the main control board will enable its internal processor and memory resources. The first step is to execute the bootloader stored in the first address segment of the memory, which is responsible for program updates and system jumps. After completing these initial steps, the system will enter the main system program and first perform the preparatory work, including checking the network status, sensor status, device resources, and reporting the system status. After completing these preparations, the system will perform automatic or manual temperature and humidity control tasks according to the configuration. After the control task is completed, the system may shut down or continue to wait for the next control task.
In this system, the main control board and the central controller each contain multiple functional modules. Table 8 shows a brief introduction to the functions of the main control board and the central control module. All these functional modules run in the RT Thread real-time operating system, and they work together and communicate based on the thread management, message queue, and interrupt management functions provided by the system. By using the driver management function of the system, call the Huada Device Driver Library function to access hardware resources and achieve control functions.
In terms of software development, the main control board and the central controller adopt similar methods. This article will take the main control board as an example to provide a detailed introduction to the design and implementation process of functional modules. After the system is started, the main control board functional modules will be initialized sequentially. The initialization process of the system is shown in Figure 24.

4.2.3. Design and Implementation of Thread Time Slices and Interrupt Priority Tables

In this design, the priority table for each thread and interrupt is designed as shown in Table 9.
In this design, we adopted the RT Thread real-time operating system, which supports 0 to 255 thread priorities and is managed through a multilayer priority table. However, considering that the thread scheduling requirements for this project are not too complex, we have chosen to use a single-layer priority table. This configuration allows us to manage 0 to 31 priorities, which is sufficient to meet the needs of the current design.
In terms of specific priority allocation, the functional module threads are set to medium priority. In contrast, Modbus threads and automatic control threads are given higher priority. This setting ensures that these threads can complete tasks without preempting high priority threads at the bottom of the system, while also avoiding the problem of insufficient processor resources due to low priority. Through this priority configuration, we can effectively balance the system’s responsiveness and resource allocation.

4.2.4. Automatic Temperature and Humidity Control Module

This section takes the automatic temperature and humidity control module as an example to explain in detail the deployment process of control algorithms in hardware. The temperature and humidity automatic control module is mainly responsible for automatic adjustment of temperature and humidity when the system is set to automatic control mode. The workflow of this module is shown in Figure 25, which begins with the initialization of the system.
Firstly, the system will start and initialize the RT Thread operating system, followed by necessary human–machine interaction operations. This stage includes receiving user input and adjusting system settings. After completing human–computer interaction, the system will perform real-time tasks related to temperature and humidity control. These tasks are responsible for adjusting temperature and humidity settings based on current environmental data to maintain the set environmental conditions.
During real-time task execution, if any errors or exceptions are encountered, the system will enter the “error exception handling” phase. This stage includes error detection and user notification. If an error is detected, the system will record relevant error information and may prompt the user to intervene. In the absence of errors, the system continues to execute subsequent real-time tasks.
After the real-time task is completed, the system will collect environmental data, which is crucial for achieving precise temperature and humidity control. The system first determines whether the data collection is successful. If successful, store the data for future use; if it fails, handle the data collection exception and attempt to collect the data again.
After the data collection and processing are completed, it marks the end of a working phase of the temperature and humidity control module. The entire workflow is iterative, emphasizing the importance of data collection and processing while maintaining suitable environmental conditions, and systematically addressing any possible errors and anomalies.
The initialization of the temperature and humidity automatic control module is the starting point of the key steps in the system. After initialization, the system first performs a series of checks on the motor and sensors to ensure that all functional components are in normal working condition. Afterwards, the control module executes automatic control tasks based on the instructions in the message queue, which are centered around the SNPID controller.
When the system is not set to automatic control mode, the temperature and humidity control module will enter a waiting state and do not perform any operations. In automatic control mode, the module will continuously listen to the message queue. This mechanism ensures that the system can flexibly respond to external commands, immediately stopping automatic control or maintaining the current automatic control state based on the received message.
The detailed functions and code implementation examples of the control module are detailed in Table 10. Through the examples in the table, we can gain a detailed understanding of the specific logic of implementing automatic temperature and humidity control through program code, including key technical details such as task scheduling, message processing, and exception management.
The functional codes of the SNPID controller are shown in Table 11.

5. System Testing and Discussion of Results

5.1. Temperature Control Testing Based on Simulation Modeling

In this section, we focus on conducting thorough simulation tests of the SNPID control algorithm to accurately assess its performance. As the first step of verification, we employ a step response test to evaluate the algorithm’s fundamental performance indicators, which is a standard method for assessing the response speed and stability of control systems. Through this test, we gain preliminary insights into how the algorithm adjusts its output under sudden changes in input conditions.
Subsequently, to comprehensively evaluate the effectiveness of the SNPID control algorithm in controlling temperature within a simulated greenhouse environment, we conducted a series of greenhouse temperature tracking simulation experiments. These experiments simulate temperature variations within the greenhouse and examine the SNPID algorithm’s adjustment and control capabilities under these changing conditions. For a more in-depth analysis and validation, we compared these results with those obtained using traditional PID control algorithms. This comparison allows us to more clearly understand the advantages and limitations of the SNPID algorithm in practical applications compared to traditional methods.

5.1.1. Step Response Performance Test of SNPID Algorithm

In this section, we focus on showcasing the theoretical performance test results of the SNPID control algorithm. To conduct an effective PID performance test, we simplified the temperature model of the solar greenhouse, modeling it as a nonlinear first-order inertia system with a time delay [51]. Although this model is a simplified version, it provides sufficient accuracy to compare the performance of different control algorithms. The related transfer function is detailed in Equation (23) in the text.
In our study, this transfer function is used to abstractly describe the greenhouse environment. It is important to emphasize that, while this transfer function does not completely conform to the full thermodynamic simulation model of a solar greenhouse, it effectively captures key system characteristics of the greenhouse model. This approximation method is particularly suitable for conducting step response tests, providing a practical basis for evaluating and comparing the performance of different control strategies [59,60].
H s = e 80 s 100 s + 1
In traditional PID control, determining the PID coefficients usually relies on a trial-and-error method [61,62]. This method involves continuously adjusting the PID coefficients and tuning time and minimizing the overshoot to determine the optimal coefficients for the traditional PID controller, set as k p = 0.02, k i = 0.01, k d = 0.04. In the case of the SNPID controller, the parameter set is defined as k = 0.04, with η k p = η k i = η k d = 1. We conducted a comparative analysis by simultaneously testing the step responses of the traditional PID controller, the Adaptive Fuzzy PID controller, and the SNPID controller in a greenhouse model. The simulation structure is shown in Figure 26, where SNPID, cPID, and AFPID represent the simulation modules for the Single Neuron PID control algorithm, the traditional PID control algorithm, and the Adaptive Fuzzy PID, respectively.
Figure 27 presents the step response performance simulation results, and Table 12 lists the associated performance metrics. In the step response tests, SNPID exhibited a smaller overshoot (only 0.03%) and demonstrated superior rise time, settling time, and peak time compared to both AFPID and cPID. Specifically, SNPID showed a 26.6% reduction in rise time, an 11.5% reduction in settling time, and a 24.3% reduction in peak time. Relative to cPID control, SNPID achieved a 9.038% decrease in rise time, a 1.49% decrease in settling time, and a 5.327% reduction in peak time. These results indicate that in terms of step response control performance, the Single Neuron PID algorithm outperforms both the traditional PID and Adaptive Fuzzy PID control algorithms.

5.1.2. Simulation Tests of Controlled Temperature Profiles of Greenhouse Models

After completing the step response test simulations, this study proceeded to integrate the SNPID controller and the traditional PID (cPID) controller with the mathematical model of a solar greenhouse. The aim was to verify and compare the temperature tracking performance of these systems under control. The structure of this greenhouse simulation model is detailed in Figure 28, where we focus on several key components: the ventilation opening input module, the heat component analysis module, and the heat-to-temperature conversion module. The output of the PID controller, u(k), serves as the input for the ventilation opening module, calculating the required size of the ventilation openings. The motor module (Motor Model) adjusts the size of the ventilation openings based on these calculations, thereby altering the heat distribution inside the greenhouse. These distributions correspond to the parts of the simulation model that include heat from solar radiation Q s u n , conductive heat Q c o n d , ventilation cooling Q v e n t i , long-wave radiation heat Q l o n g w , and the heat stored in the walls Q st [63]. Through this process, after the total heat inside the greenhouse changes, the adjusted internal air temperature of the greenhouse can be obtained after processing by the heat-to-temperature conversion module.
In this study, the controlled greenhouse simulation model displayed in Figure 29 was designed with two independent simulation models for a direct comparison of control effects: one equipped with a Single Neuron PID (SNPID) controller and the other with a traditional PID (cPID) controller. Specifically, both greenhouse models, namely, Greenhouse Model and Greenhouse Model1, utilize the solar greenhouse thermodynamic simulation model described in Figure 28. The target temperature for both models was set at 25 °C, with an initial temperature of 20 °C.
The simulation time frame mainly focused on daytime, considering that in actual greenhouse environments, ventilation openings are typically closed at night to maintain temperature. Therefore, our simulation started at sunrise (t = 0 h) and lasted for 12 h. Solar radiation was simulated as a Gaussian normal distribution curve, peaking at 500 W/m2 around noon, and then the radiation intensity dropped to 0 after t ≥ 8.3 h. This curve is displayed in Figure 30. Additionally, the trend of the external temperature was designed to match the changes in sunlight, with a temperature range of 16–21 °C. During the night, the external temperature was set to a constant 16 °C. This setting aimed to assess whether the controllers could effectively implement insulation strategies under continuous low temperature conditions.
In the simulation experiments, we set a goal: to maintain the internal temperature of the greenhouse during the day at the optimal growth temperature for tomatoes, approximately a constant level of 25 °C. At night, due to the lack of solar heat input, the control system needs to minimize ventilation cooling to ensure effective operation of the controller, and ensure that the ventilation openings are completely closed to prevent heat loss. Additionally, to increase the challenge of the simulation and test the algorithm’s resistance to environmental changes, we introduced Gaussian noise into the external temperature input, simulating the impact of environmental noise on the temperature control system. Figure 31a shows the changes in the internal temperature of the greenhouse under SNPID and cPID control strategies. Figure 31b shows the trends in ventilation opening adjustments under these two control strategies. In these illustrations, the temperature and ventilation adjustment curves under SNPID control demonstrate the effectiveness of the Single Neuron PID control algorithm, while the cPID control curves reflect the performance of the traditional PID control algorithm.
Specifically, during the periods from t = 0 h to t = 1.9 h and t = 5.7 h to t = 12 h, both control systems face the challenge of achieving the set target temperature indoors. As shown in Figure 31b, both control systems can precisely close the ventilation openings to minimize heat loss and maintain the internal temperature of the greenhouse. During the phase from t = 1.9 h to t = 5.7 h, thanks to strong solar radiation, both control systems stabilize the indoor temperature around the target temperature of approximately 25 °C. In responding to external disturbances, the SNPID control system shows higher efficiency, limiting temperature fluctuations to a smaller range, between 26.40 °C and 23.76 °C, while the temperature range for the cPID control system is larger, between 27.12 °C and 22.99 °C. This comparison indicates that the Single Neuron PID control system is superior to the traditional PID control system in terms of stability and accuracy in temperature control.
As shown in Figure 31b, by analyzing the changes in the opening of the ventilation, we can see that the SNPID controller adjusts more actively and frequently compared to the cPID controller. In some peak periods, the adjustment extent is even about 40% higher than the traditional controller, reflecting its rapid response characteristic, which allows it to adapt quickly to environmental changes while maintaining control precision. Furthermore, in the face of external disturbances, the SNPID and cPID controllers adopted different strategies to stabilize the temperature, with these differences particularly evident at t = 3.33 h. As shown in Figure 32, the immediate adjustments to the ventilation openings made by these two controllers in response to interference signals reflect their respective adaptability and efficiency. By comparing these two control strategies, we can more accurately evaluate the performance of each controller in dynamic environments.
Under temperature fluctuations caused by Gaussian noise, the Single Neuron PID controller (SNPID) and the traditional PID controller (cPID) exhibited different adaptation and response patterns. Particularly when facing disturbances, the SNPID controller managed to control the peak temperature fluctuation at 26.4 °C, while the peak for the cPID controller reached 27.12 °C. Notably, the SNPID controller required only 0.157 h to readjust the temperature back to within the range of 25 °C ± 0.5 °C (achieved at t = 3.487 h), while the cPID controller required at least 0.285 h. Before the next wave of disturbance, the cPID controller was even unable to stabilize the temperature, highlighting the significant advantage of SNPID in quickly restoring a stable state. Its adjustment time is at least 45.0% faster than that of cPID.
Overall, the SNPID controller demonstrated rapid and proactive response capabilities in dealing with disturbances, enabling it to stabilize temperature at a higher speed. Compared to the traditional cPID controller, the SNPID controller exhibits superior performance in several key aspects such as stability, adaptability, and interference resistance. Particularly noteworthy is the SNPID controller’s performance in terms of system overshoot, which is crucial for agricultural production scenarios that require precise temperature control. The ability of the SNPID controller to achieve such performance is mainly due to its unique algorithm design, which allows for rapid adaptation to environmental changes and precise adjustment of control parameters. This efficient control mechanism not only improves the accuracy of temperature control, but also enhances the overall system’s stability and reliability in the face of external changes. Therefore, the SNPID controller holds significant application value in modern precision agriculture and other fields requiring precise environmental control.

5.2. Control System Testing Based on Real Greenhouses

After successfully designing and validating the control algorithm through simulation, we further applied this algorithm to the main control board of an actual greenhouse, conducting on-site temperature and humidity control tests. The core task of this phase was to verify the functionality of the system components and the control efficacy of the developed algorithm, along with detailed recording and analysis of the overall control performance.
Given the crucial role of the main control board in executing control tasks, we first conducted rigorous tests of its functional usability, including checking the stability of the hardware, the responsiveness of the software, and the accurate execution of control commands. After comprehensively testing and confirming the normal functioning of the main control board, we shifted our focus to further in-depth testing and evaluation of the control algorithm’s performance. This process covered not only the adaptability and stability assessment of the algorithm under different environmental conditions, but also included a detailed analysis of its response efficiency and control precision under actual greenhouse conditions. These on-site tests provided us with direct evidence of the algorithm’s performance in practical applications, marking an important step from theory to practice.

5.2.1. Main Control Board Function Test

After completing the wiring of the main control board with the 220 V mains power, sensors, motor power supply module, and motor, and powering up the system, the working status of the system is as shown in Figure 33a. On the left side of the system is the main control board unit, and on the right side marked as the WX-DC2412 unit is the motor drive module, responsible for driving high-power DC motors. Once the system is powered on, the indicator light on the main control board lights up, and the LED digital tube sequentially displays the current temperature, humidity, vent opening, and motor current values, as shown separately in Figure 33b–e.
Specifically, the digital tube in Figure 33b displays “T26.6”, indicating the current temperature is 26.6 °C. Due to the display limitation of the seven-segment digital tube, the letter T is used here with “-|” pattern. Figure 33c shows “H24.1”, indicating the relative humidity is 24.1%; Figure 33d displays “P046”, indicating the vent opening is 46 cm, which can be adjusted by the user via a toggle switch; Figure 33e shows “A 01”, indicating the motor current is 0.01 A. These intuitive display messages make monitoring and adjusting the system state simple and direct.

5.2.2. Temperature and Humidity Control Effect Test

In this study, the control algorithm we developed was field-validated in a standard experimental greenhouse in Dandong, Liaoning Province. The interior and exterior environments of this greenhouse are depicted in Figure 34. This east–west sloping solar greenhouse covers an area of approximately 400 square meters, with its ventilation opening centrally located at the top. It is a rectangular shape, measuring 20 m wide and 1.5 m high, covered with transparent plastic film. To precisely adjust the area of the ventilation opening, we used a motor drive to roll up and down the plastic film. Such a setup allows for fine-tuning of the vent opening according to the instructions of the control algorithm, effectively controlling the temperature and humidity inside the greenhouse. The motor’s speed is set at 15 cm per second to ensure smooth and rapid response in opening the vents.
For a comprehensive evaluation of the performance of the control algorithm, we selected a control greenhouse with a similar structure and orientation for comparison, which used a traditional PID control algorithm based on the STM32F407. Given the consistent structure and orientation of the two greenhouses and similar external environmental influences, this provided an effective benchmark for comparing algorithm performance. The testing was conducted remotely, with local engineers responsible for installing and configuring the control systems and programs, deploying the control algorithm according to the methods described in Section 3, and transmitting the test data back in real-time. These data were then used for in-depth analysis and evaluation to ensure the accuracy and reliability of the conclusions drawn.
A.
Testing the effectiveness of air temperature control in chambers
The control system underwent a preliminary test lasting about 5 h on February 20th, using the proportional coefficient k = 0.04 and learning rates η k p = η k i = η k d = 1 as the parameter set for the SNPID algorithm, as in the simulation tests. The test results indicated that this set of parameters could converge the temperature to the target level. Therefore, on March 5th, we conducted a 24 h practical test using the same parameter set.
According to the meteorological data, on March 5th, the highest temperature in Dandong City was 5 °C, and the lowest was −3 °C, indicating a cold climate. Considering that the crop being cultivated was tomatoes, with an optimal growth temperature of 25 °C, we set the following control objectives: during the sunny hours (9:00 to 15:00), the air temperature inside the greenhouse should be maintained between 24 °C and 26 °C, with a deviation of ±1 °C from the optimal growth temperature. If the temperature deviation from the optimal growth temperature was within ±1 °C for 80% of the control period, the control accuracy was considered to be ±1 °C. At other times, the temperature should be as close as possible to the target value of 25 °C. The control accuracy for both the experimental greenhouse and the control greenhouse was set at 6 min, meaning the ventilation openings were adjusted every 6 min.
On March 5th, the experiment we conducted displayed a comparison of temperature changes between the experimental greenhouse equipped with an autonomous platform control system and improved algorithm, and the control greenhouse using traditional control methods, as shown in Figure 35a. During the sunny hours (9:00 to 15:00), the average temperature of both the experimental and control greenhouses successfully remained within the range of 25 ± 1 °C, with the experimental greenhouse averaging 24.9 °C and the control greenhouse averaging 25.8 °C.
It is noteworthy that the two greenhouses showed significant differences in the amplitude of temperature fluctuations. The Root Mean Square Error (RMSE) of the temperature in the experimental greenhouse was 0.734, while that in the control greenhouse was 1.594, indicating greater temperature stability in the experimental greenhouse. Particularly in the experimental greenhouse, 90.2% of the temperature readings were within the range of 25 ± 1 °C, compared to only 40% in the control greenhouse. During the night and early morning hours, both greenhouses exhibited good insulation performance, with no significant temperature fluctuations.
The adjustment of the ventilation opening is a key factor in controlling the greenhouse temperature. As shown in Figure 35b, the adjustments in the experimental greenhouse were more active and sensitive, with a maximum opening of 67 cm, showing a rapid response to high temperatures, and a minimum length of 5 cm, indicating appropriate adjustments at lower temperatures. In contrast, the ventilation adjustments in the control greenhouse were more conservative, with a maximum opening of 55 cm, and remained unchanged during certain periods, reflecting a less timely response to temperature fluctuations.
From these analyses, it is evident that the experimental greenhouse using the SNPID algorithm demonstrated higher stability and precision in temperature control. The temperature control accuracy of the experimental greenhouse reached ±1 °C, compared to ±2.5 °C in the control greenhouse. According to the above description and analysis, the comparison of temperature management and ventilation control between the experimental greenhouse and the control greenhouse is shown in Table 13. These results effectively validate the adaptability and robustness of the SNPID algorithm, proving its ability to enhance the precision and stability of temperature control in greenhouses in practical applications.
B.
Testing the effectiveness of air humidity control in chambers
In this test, although air humidity was considered a secondary control target and no strict control standards were set, we explored the effects of humidity control by introducing Morning Breeze and Evening Breeze modes. These modes aim to manage humidity more effectively during specific periods.
According to the humidity curve in Figure 36, we observed several key points: First, during periods of abundant sunlight, as temperature control became the primary objective, both greenhouses reduced humidity to a minimum level of about 40% by adjusting ventilation ports. Second, the experimental greenhouse triggered the Morning Breeze mode at 8:09 AM and the Evening Breeze mode between 4:05 PM and 4:35 PM. However, the activation of these modes did not show a significant difference in humidity control between the experimental and control greenhouses.
A deeper analysis of the data in the charts revealed that the current humidity control strategy did not achieve the expected results, indicating that adjustments to the control algorithm might be necessary. Comparing the humidity data of the experimental and control greenhouses, although both showed similar fluctuation trends, there were significant differences in response time and magnitude. These differences could be caused by several factors: First, minor changes in external environmental conditions, such as sudden temperature fluctuations or rainfall, could lead to rapid changes in humidity. Second, internal greenhouse conditions, such as soil moisture and plant water status, also affect air humidity. For example, an increase in soil moisture can raise air humidity through evaporation. Additionally, differences in the opening and closing strategies of ventilation ports, even under the same control policy, could result in variations in humidity control due to sensor data delays or inconsistencies in the ventilation system’s response speeds. Finally, the transpiration of vegetation is an important factor; differences in the growth status and types of vegetation in different greenhouses can cause variations in humidity responses, especially during the day when photosynthesis is most active.
To better understand how these factors affect humidity control and to improve our strategies in future work, we plan to take the following steps: (1) Collect environmental data at a higher frequency to monitor humidity changes more precisely; (2) Adjust control parameters such as the frequency and extent of ventilation openings; (3) Explore humidity management methods that are more coordinated with temperature control; (4) Conduct a deeper study on the relationship between plant transpiration and changes in greenhouse humidity. We hope that these measures will allow us to more accurately assess and optimize humidity control strategies, achieving efficient humidity management under different environmental conditions.

6. Conclusions

This study comprehensively explored the design and optimization process of a temperature and humidity control system for sloped solar greenhouses. It focused on the software and hardware design and implementation of a control system based on an autonomous platform, the development of innovative temperature and humidity control algorithms, and the testing of these systems in real-world environments. The specifics are as follows: 1. In terms of engineering implementation, this study successfully utilized an embedded MCU chip with domestic intellectual property rights to build the hardware framework and developed an embedded real-time operating system. 2. Regarding theoretical algorithms, this study designed and validated a control algorithm based on the Single Neuron PID to optimize temperature and humidity control in solar greenhouses. Simulation tests showed that this algorithm outperforms the traditional PID algorithm in key performance indicators such as overshoot, rise time, settling time, and peak time. 3. Field tests further confirmed its effectiveness, especially in maintaining the stability and precision of temperature within the greenhouse, significantly improving temperature control accuracy. Specifically, the experimental greenhouse using the SNPID algorithm and autonomous software and hardware platform successfully maintained the temperature within the set range of 25 ± 1 °C for 90.2% of the time, compared to only 40% for the control greenhouse using traditional PID algorithm and foreign software and hardware platforms. Additionally, the experimental greenhouse demonstrated a lower Root Mean Square Error (RMSE) in temperature compared to the control greenhouse, confirming the effectiveness of the SNPID algorithm in improving the efficiency and stability of temperature control. However, in terms of humidity control, although Morning Breeze and Evening Breeze modes were introduced, the differences in these strategies were not apparent in the practical application comparison experiments, indicating a need for more in-depth experiments and optimization of humidity control strategies in future work.
Overall, this study provides a set of solutions for temperature and humidity control in sloped solar greenhouses, including the design of an autonomous control system, innovation in control algorithms, and practical testing of the system. The implementation of this research holds significance for smart agriculture and sustainable agricultural production. Future studies should further explore the applicability of this algorithm under different environmental conditions and consider its potential applications in other aspects of temperature and humidity control technology.

Supplementary Materials

The following supporting information can be downloaded at: https://www.mdpi.com/article/10.3390/electronics13112083/s1.

Author Contributions

Conceptualization, C.L.; Software, G.H.; Investigation, T.D.; Writing—original draft, S.H.; Writing—review & editing, H.X. All authors have read and agreed to the published version of the manuscript.

Funding

This research received no external funding.

Data Availability Statement

Data is contained within the article or Supplementary Materials.

Conflicts of Interest

The authors declare no conflict of interest.

References

  1. Ravishankar, E.; Booth, R.E.; Hollingsworth, J.A.; Ade, H.; Sederoff, H.; DeCarolis, J.F.; O’Connor, B.T. Organic solar powered greenhouse performance optimization and global economic opportunity. Energy Environ. Sci. 2022, 15, 1659–1671. [Google Scholar] [CrossRef]
  2. Zhang, X.; Lv, J.; Xie, J.; Yu, J.; Zhang, J.; Tang, C.; Li, J.; He, Z.; Wang, C. Solar radiation allocation and spatial distribution in chinese solar greenhouses: Model development and application. Energies 2020, 13, 1108. [Google Scholar] [CrossRef]
  3. Zhang, Y.; Henke, M.; Li, Y.; Xu, D.; Liu, A.; Liu, X.; Li, T. Towards the maximization of energy performance of an energy-saving Chinese solar greenhouse: A systematic analysis of common greenhouse shapes. Sol. Energy 2022, 236, 320–334. [Google Scholar] [CrossRef]
  4. Yau, J.; Wei, J.J.; Wang, H.; Eniola, O.; Ibitoye, F.P. Modeling of the internal temperature for an energy saving Chinese solar greenhouse. Eng. Technol. Appl. Sci. Res. 2020, 10, 6276–6281. [Google Scholar] [CrossRef]
  5. Zhang, L.; Liu, X.; Shi, W.; Li, T.; Ji, J. Study of a novel front-roof-back natural ventilation system for Chinese solar greenhouses. R. Soc. Open Sci. 2022, 9, 220251. [Google Scholar] [CrossRef] [PubMed]
  6. Kang, M.; Fan, X.-R.; Hua, J.; Wang, H.; Wang, X.; Wang, F.-Y. Managing traditional solar greenhouse with CPSS: A just-for-fit philosophy. IEEE Trans. Cybern. 2018, 48, 3371–3380. [Google Scholar] [CrossRef] [PubMed]
  7. Li, Z.; Yano, A.; Cossu, M.; Yoshioka, H.; Kita, I.; Ibaraki, Y. Electrical energy producing greenhouse shading system with a semi-transparent photovoltaic blind based on micro-spherical solar cells. Energies 2018, 11, 1681. [Google Scholar] [CrossRef]
  8. Yun, J.-W.; Lee, D.-S.; Kim, S.-S. Analysis on productivity and efficiency of greenhouse rose farming. J. Korea Acad. Ind. Coop. Soc. 2020, 21, 532–542. [Google Scholar]
  9. Fokui, W.S.T.; Saulo, M.; Ngoo, L. Climate Change Mitigation in Cities by Adopting Solar Streetlights with Energy Management Capabilities: Case of Nairobi. In Proceedings of the 2022 IEEE 21st Mediterranean Electrotechnical Conference (MELECON), Palermo, Italy, 14–16 June 2022; pp. 390–395. [Google Scholar]
  10. Ding, D. Integration of Active Solar Thermal Technologies in Greenhouses: A Mini Review. Front. Energy Res. 2021, 9, 757553. [Google Scholar] [CrossRef]
  11. Nouadjep, S.N.; Djouodjinang, H.F. IoT and Arduino Based Design of a Solar, Automated and Smart Greenhouse for Vegetable. E3S Web Conf. 2022, 354, 01002. [Google Scholar] [CrossRef]
  12. Suji Prasad, S.; Thangatamilan, M.; Suresh, M.; Panchal, H.; Rajan, C.A.; Sagana, C.; Gunapriya, B.; Sharma, A.; Panchal, T.; Sadasivuni, K.K. An efficient LoRa-based smart agriculture management and monitoring system using wireless sensor networks. Int. J. Ambient Energy 2022, 43, 5447–5450. [Google Scholar] [CrossRef]
  13. Ahmad, B.; Ahmed, R.; Masroor, S.; Mahmood, B.; Hasan, S.Z.U.; Jamil, M.; Khan, M.T.; Younas, M.T.; Wahab, A.; Haydar, B.; et al. Evaluation of smart greenhouse monitoring system using raspberry-pi microcontroller for the production of tomato crop. J. Appl. Res. Plant Sci. 2023, 4, 452–458. [Google Scholar] [CrossRef]
  14. Wei, X. Intelligent temperature control system of greenhouse based on STM32 single chip microcomputer. J. Phys. Conf. Ser. 2022, 2254, 012046. [Google Scholar] [CrossRef]
  15. Abbood, H.M.; Nouri, N.; Riahi, M.; Alagheband, S.H. An intelligent monitoring model for greenhouse microclimate based on RBF Neural Network for optimal setpoint detection. J. Process. Control 2023, 129, 103037. [Google Scholar] [CrossRef]
  16. Cheng, Y. Research on intelligent control of an agricultural greenhouse based on fuzzy PID control. J. Environ. Eng. Sci. 2020, 15, 113–118. [Google Scholar] [CrossRef]
  17. Wang, Y.; Lu, Y.; Xiao, R. Application of Nonlinear Adaptive Control in Temperature of Chinese Solar Greenhouses. Electronics 2021, 10, 1582. [Google Scholar] [CrossRef]
  18. Wang, Y.; Wang, Z.; Zhang, H.; Xie, X. Finite-time adaptive fuzzy event-triggered control for nonstrict feedback stochastic nonlinear systems with multiple constraints. IEEE Trans. Fuzzy Syst. 2023, 31, 3896–3905. [Google Scholar] [CrossRef]
  19. Yuan, Y.; Zhao, J.; Sun, Z.-Y.; Xie, X. Practically fast finite-time stability in the mean square of stochastic nonlinear systems: Application to one-link manipulator. IEEE Trans. Syst. Man, Cybern. Syst. 2023, 54, 312–323. [Google Scholar] [CrossRef]
  20. Xia, J.; Li, B.; Su, S.-F.; Sun, W.; Shen, H. Finite-time command filtered event-triggered adaptive fuzzy tracking control for stochastic nonlinear systems. IEEE Trans. Fuzzy Syst. 2020, 29, 1815–1825. [Google Scholar] [CrossRef]
  21. Sun, K.; Qiu, J.; Karimi, H.R.; Fu, Y. Event-triggered robust fuzzy adaptive finite-time control of nonlinear systems with pre-scribed performance. IEEE Trans. Fuzzy Syst. 2020, 29, 1460–1471. [Google Scholar] [CrossRef]
  22. Wu, Y.; Zhang, G.; Wu, L.-B. Finite-time adaptive fuzzy switching event-triggered control for nonaffine stochastic systems. IEEE Trans. Fuzzy Syst. 2022, 30, 5261–5275. [Google Scholar] [CrossRef]
  23. Sui, S.; Chen, C.P.; Tong, S. Event-trigger-based finite-time fuzzy adaptive control for stochastic nonlinear system with un-modeled dynamics. IEEE Trans. Fuzzy Syst. 2020, 29, 1914–1926. [Google Scholar] [CrossRef]
  24. Zhou, H.; Sui, S.; Tong, S. Fuzzy adaptive finite-time consensus control for high-order nonlinear multiagent systems based on event-triggered. IEEE Trans. Fuzzy Syst. 2022, 30, 4891–4904. [Google Scholar] [CrossRef]
  25. Li, Y.-X.; Yang, G.-H. Observer-based fuzzy adaptive event-triggered control codesign for a class of uncertain nonlinear systems. IEEE Trans. Fuzzy Syst. 2017, 26, 1589–1599. [Google Scholar] [CrossRef]
  26. Ma, H.; Li, H.; Liang, H.; Dong, G. Adaptive fuzzy event-triggered control for stochastic nonlinear systems with full state constraints and actuator faults. IEEE Trans. Fuzzy Syst. 2019, 27, 2242–2254. [Google Scholar] [CrossRef]
  27. Wu, R.; Yu, K.; Li, Y. Adaptive Fuzzy 1-Bit Event-Triggered Control for Stochastic Nonlinear Systems. In Proceedings of the 2021 13th International Conference on Advanced Computational Intelligence (ICACI), Wanzhou, China, 14–16 May 2021; pp. 68–73. [Google Scholar]
  28. Zhang, R.-Y.; Wu, L.-B.; Zhao, N.-N.; Yan, Y. Adaptive event-triggered fuzzy tracking control of uncertain stochastic nonlinear systems with unmeasurable states. IEEE Trans. Fuzzy Syst. 2021, 30, 2183–2196. [Google Scholar] [CrossRef]
  29. Yang, W.; Zheng, W.X.; Yu, W. Observer-based event-triggered adaptive fuzzy control for fractional-order time-varying delayed MIMO systems against actuator faults. IEEE Trans. Fuzzy Syst. 2022, 30, 5445–5459. [Google Scholar] [CrossRef]
  30. Liu, Y.; Zhang, H.; Sun, J.; Wang, Y. Event-triggered adaptive finite-time containment control for fractional-order nonlinear multiagent systems. IEEE Trans. Cybern. 2022, 54, 1250–1260. [Google Scholar] [CrossRef] [PubMed]
  31. Chen, T.; Yang, H.; Yuan, J. Event-triggered adaptive neural network backstepping sliding mode control for fractional order chaotic systems synchronization with input delay. IEEE Access 2021, 9, 100868–100881. [Google Scholar] [CrossRef]
  32. Jia, Y. Design of an intelligent greenhouse remote control system based on a fuzzy neural network. Int. J. Autom. Technol. 2021, 15, 243–248. [Google Scholar] [CrossRef]
  33. Qun, R. Intelligent control technology of agricultural greenhouse operation robot based on fuzzy PID path tracking algorithm. INMATEH Agric. Eng. 2020, 62, 181–190. [Google Scholar] [CrossRef]
  34. Elanchezhian, A.; Basak, J.; Park, J.; Khan, F.; Okyere, F.; Lee, Y.; Bhujel, A.; Lee, D.; Sihalath, T.; Kim, H. Evaluating different models used for predicting the indoor microclimatic parameters of a greenhouse. Appl. Ecol. Environ. Res. 2020, 18, 2141–2161. [Google Scholar] [CrossRef]
  35. Yao, Y.; Tan, J.; Wu, J. Finite-time tracking control for nonstrict-feedback state-delayed nonlinear systems with full-state constraints and unmodeled dynamics. Complexity 2020, 2020, 8887925. [Google Scholar] [CrossRef]
  36. Hou, Y.; Xu, X.; Liu, R.; Bai, X.; Liu, H. Adaptive finite-time fuzzy control for uncertain nonlinear systems with asymmetric full-state constraints. Mathematics 2023, 11, 4313. [Google Scholar] [CrossRef]
  37. Ungurean, I. Timing Comparison of the real-time operating systems for small microcontrollers. Symmetry 2020, 12, 592. [Google Scholar] [CrossRef]
  38. Xie, X.; Ye, J.; Wu, L.; Li, R. RTOSExtracter: Extracting user-defined functions in stripped RTOS-based firmware. In Proceedings of the 2022 International Conference on Cyber-Enabled Distributed Computing and Knowledge Discovery (CyberC), Suzhou, China, 14–16 October 2022; pp. 87–96. [Google Scholar]
  39. Zhang, H.; Yang, L. Position and attitude control based on single neuron pid with gravity compensation for quad rotor UAV. J. Aerosp. Technol. Manag. 2023, 15, e1023. [Google Scholar] [CrossRef]
  40. Li, Y.; Dong, Y.; Fan, P. Positioning Control of Piezoelectric Stick-slip Actuators Based on Single Neuron Adaptive PID Algo-rithm. In Proceedings of the 2021 11th International Conference on Intelligent Control and Information Processing (ICICIP), Dali, China, 3–7 December 2021; pp. 227–234. [Google Scholar]
  41. Su, D.; Yao, W.; Yu, F.; Liu, Y.; Zheng, Z.; Wang, Y.; Xu, T.; Chen, C. Single-neuron PID UAV variable fertilizer application control system based on a weighted coefficient learning correction. Agriculture 2022, 12, 1019. [Google Scholar] [CrossRef]
  42. Zhiqi, Y. Application of Improved PID Control Algorithm in Intelligent Vehicle. In Proceedings of the 2022 IEEE 6th Advanced Information Technology, Electronic and Automation Control Conference (IAEAC), Beijing, China, 3–5 October 2022; pp. 910–913. [Google Scholar]
  43. Wan, S.; Wang, K.; Xu, P.; Huang, Y. Numerical and experimental verification of the single neural adaptive PID real-time inverse method for solving inverse heat conduction problems. Int. J. Heat Mass Transf. 2022, 189, 122657. [Google Scholar] [CrossRef]
  44. Zhou, X.; Wang, J.; Huang, L.; Li, D.; Duan, Q. Modelling and controlling dissolved oxygen in recirculating aquaculture systems based on mechanism analysis and an adaptive PID controller. Comput. Electron. Agric. 2022, 192, 106583. [Google Scholar] [CrossRef]
  45. Ghany, M.A.; Shamseldin, M.A.; Ghany, A.A. A novel fuzzy self tuning technique of single neuron PID controller for brushless DC motor. In Proceedings of the 2017 Nineteenth International Middle East Power Systems Conference (MEPCON), Cairo, Egypt, 19–21 December 2017; pp. 1453–1458. [Google Scholar]
  46. Yu, M.; Zou, Z.; Wang, Z. Single Neuron PID Controller Based on Quadratic Optimization and its Application on pH Process Control. In Proceedings of the 2019 Chinese Control Conference (CCC), Guangzhou, China, 27–30 July 2019; pp. 2868–2873. [Google Scholar]
  47. Wu, Y.; Hou, B.; Zhou, G.; Yang, J.; Jun, F.; Zhang, Y. A Smooth Angle Velocity Active Return-to-Centre Control Based on Single Neuron PID Control for Electric Power Steering System. In Proceedings of the 2020 Chinese Control and Decision Conference (CCDC), Hefei, China, 22–24 August 2020; pp. 3945–3950. [Google Scholar]
  48. Wang, Z.; Zhang, J. Incremental PID controller-based learning rate scheduler for stochastic gradient descent. IEEE Trans. Neural Netw. Learn. Syst. 2022, 35, 7060–7071. [Google Scholar] [CrossRef]
  49. Cheng, Y.-M.; Liu, C.; Wu, J.; Liu, H.-M.; Lee, I.-K.; Niu, J.; Cho, J.-P.; Koo, K.-W.; Lee, M.-W.; Woo, D.-G. A back propagation neural network with double learning rate for PID controller in phase-shifted full-bridge soft-switching power supply. J. Electr. Eng. Technol. 2020, 15, 2811–2822. [Google Scholar] [CrossRef]
  50. Dai, M.; Zhang, Z.; Lai, X.; Lin, X.; Wang, H. PID controller-based adaptive gradient optimizer for deep neural networks. IET Control Theory Appl. 2023, 17, 2032–2037. [Google Scholar] [CrossRef]
  51. Kobyzev, I.; Prince, S.J.; Brubaker, M.A. Normalizing flows: An introduction and review of current methods. IEEE Trans. Pattern Anal. Mach. Intell. 2020, 43, 3964–3979. [Google Scholar] [CrossRef] [PubMed]
  52. Panda, R.C.; Yu, C.-C.; Huang, H.-P. PID tuning rules for SOPDT systems: Review and some new results. ISA Trans. 2004, 43, 283–295. [Google Scholar] [CrossRef] [PubMed]
  53. Zheng, W.; Luo, Y.; Chen, Y.; Wang, X. A simplified fractional order PID controller’s optimal tuning: A case study on a PMSM speed servo. Entropy 2021, 23, 130. [Google Scholar] [CrossRef] [PubMed]
  54. Rospawan, A.; Tsai, C.-C.; Tai, F.-C. Intelligent PID Temperature Control Using Output Recurrent Fuzzy Broad Learning System for Nonlinear Time-Delay Dynamic Systems. In Proceedings of the 2022 International Conference on System Science and Engineering (ICSSE), Taichung, Taiwan, 26–29 May 2022; pp. 11–16. [Google Scholar]
  55. Li, C.-L.; Yan, H.-S.; Zhang, J.-J. Multi-dimensional Taylor network adaptive predictive control for single-input single-output nonlinear systems with input time-delay. Trans. Inst. Meas. Control 2022, 44, 595–608. [Google Scholar] [CrossRef]
  56. Li, Z. Adaptive single neural network control for a class of stochastic nonlinear time-delay system with unknown dead-zone. In Proceedings of the 2021 International Conference on Security, Pattern Analysis, and Cybernetics (SPAC), Chengdu, China, 18–20 June 2021; pp. 200–205. [Google Scholar]
  57. Abidi, K.; Postlethwaite, I. Discrete-time adaptive control for systems with input time-delay and non-sector bounded nonlinear functions. IEEE Access 2018, 7, 4327–4337. [Google Scholar] [CrossRef]
  58. Yamaura, H.; Kanno, K.; Takano, N.; Isozaki, M.; Iwasaki, Y. Supra-optimal daily mean temperature stimulates plant growth and carbohydrate use in tomato. Sci. Hortic. 2021, 276, 109780. [Google Scholar] [CrossRef]
  59. Saków, M.; Miądlicki, K. Transport delay and first order inertia time signal prediction dedicated to teleoperation. In Automation 2018: Advances in Automation, Robotics and Measurement Techniques; Springer: Berlin/Heidelberg, Germany, 2018; pp. 142–151. [Google Scholar]
  60. Rodriguez-Abreo, O.; Rodriguez-Resendiz, J.; Fuentes-Silva, C.; Hernandez-Alvarado, R.; Falcon, M.D.C.P.T. Self-tuning neural network PID with dynamic response control. IEEE Access 2021, 9, 65206–65215. [Google Scholar] [CrossRef]
  61. Mai, T.A.; Dang, T.S.; Duong, D.T.; Le, V.C.; Banerjee, S. A combined backstepping and adaptive fuzzy PID approach for trajectory tracking of autonomous mobile robots. J. Braz. Soc. Mech. Sci. Eng. 2021, 43, 156. [Google Scholar] [CrossRef]
  62. Farag, W. Complex trajectory tracking using PID control for autonomous driving. Int. J. Intell. Transp. Syst. Res. 2020, 18, 356–366. [Google Scholar] [CrossRef]
  63. Atia, D.M.; El-Madany, H.T. Analysis and design of greenhouse temperature control using adaptive neuro-fuzzy inference system. J. Electr. Syst. Inf. Technol. 2017, 4, 34–48. [Google Scholar] [CrossRef]
Figure 1. Abstract structure of slant type solar greenhouse.
Figure 1. Abstract structure of slant type solar greenhouse.
Electronics 13 02083 g001
Figure 2. Schematic structure of sectional control system for a large greenhouse.
Figure 2. Schematic structure of sectional control system for a large greenhouse.
Electronics 13 02083 g002
Figure 3. Structure diagram of SNPID feedforward compensation decoupling system.
Figure 3. Structure diagram of SNPID feedforward compensation decoupling system.
Electronics 13 02083 g003
Figure 4. System structure diagram after decoupling.
Figure 4. System structure diagram after decoupling.
Electronics 13 02083 g004
Figure 5. Undecoupled temperature and humidity setpoints vs. simulated test curves.
Figure 5. Undecoupled temperature and humidity setpoints vs. simulated test curves.
Electronics 13 02083 g005
Figure 6. Temperature and humidity curves of a single neuron PID decoupling control dynamic experiment.
Figure 6. Temperature and humidity curves of a single neuron PID decoupling control dynamic experiment.
Electronics 13 02083 g006
Figure 7. Temperature and humidity curves of single neuron PID decoupling control perturbation test.
Figure 7. Temperature and humidity curves of single neuron PID decoupling control perturbation test.
Electronics 13 02083 g007
Figure 8. Schematic diagram of PID controller.
Figure 8. Schematic diagram of PID controller.
Electronics 13 02083 g008
Figure 9. Block diagram of the fuzzy PID control system.
Figure 9. Block diagram of the fuzzy PID control system.
Electronics 13 02083 g009
Figure 10. Greenhouse simulation model.
Figure 10. Greenhouse simulation model.
Electronics 13 02083 g010
Figure 11. SNPID controller structure.
Figure 11. SNPID controller structure.
Electronics 13 02083 g011
Figure 12. Workflow of SNPID controller.
Figure 12. Workflow of SNPID controller.
Electronics 13 02083 g012
Figure 13. SNPID Simulation Module.
Figure 13. SNPID Simulation Module.
Electronics 13 02083 g013
Figure 14. Temperature and humidity control algorithm workflow.
Figure 14. Temperature and humidity control algorithm workflow.
Electronics 13 02083 g014
Figure 15. SNPID self-control mode workflow.
Figure 15. SNPID self-control mode workflow.
Electronics 13 02083 g015
Figure 16. Bootloader workflow design.
Figure 16. Bootloader workflow design.
Electronics 13 02083 g016
Figure 17. Keil MDK Engineering Code Structure.
Figure 17. Keil MDK Engineering Code Structure.
Electronics 13 02083 g017
Figure 18. Keil MDK CORE Component Enabling Method.
Figure 18. Keil MDK CORE Component Enabling Method.
Electronics 13 02083 g018
Figure 19. Keil MDK header file inclusion method.
Figure 19. Keil MDK header file inclusion method.
Electronics 13 02083 g019
Figure 20. RT Thread Welcome Interface.
Figure 20. RT Thread Welcome Interface.
Electronics 13 02083 g020
Figure 21. Hardware Architecture of Control System.
Figure 21. Hardware Architecture of Control System.
Electronics 13 02083 g021
Figure 22. Main control board design scheme.
Figure 22. Main control board design scheme.
Electronics 13 02083 g022
Figure 23. Control System Program Workflow.
Figure 23. Control System Program Workflow.
Electronics 13 02083 g023
Figure 24. Initialization process of various functional modules on the main control board.
Figure 24. Initialization process of various functional modules on the main control board.
Electronics 13 02083 g024
Figure 25. Workflow of Temperature and Humidity Automatic Control Module.
Figure 25. Workflow of Temperature and Humidity Automatic Control Module.
Electronics 13 02083 g025
Figure 26. Comparison test simulation structure.
Figure 26. Comparison test simulation structure.
Electronics 13 02083 g026
Figure 27. Simulation results of the comparison test of the step response.
Figure 27. Simulation results of the comparison test of the step response.
Electronics 13 02083 g027
Figure 28. Greenhouse Simulation Model Structure.
Figure 28. Greenhouse Simulation Model Structure.
Electronics 13 02083 g028
Figure 29. Controlled greenhouse simulation model.
Figure 29. Controlled greenhouse simulation model.
Electronics 13 02083 g029
Figure 30. Solar radiation simulation curves.
Figure 30. Solar radiation simulation curves.
Electronics 13 02083 g030
Figure 31. Variation curves of controlled temperature and vent opening of greenhouse. (a) Controlled Temperature Curves of Greenhouse Under SNPID And cPID Control and (b) SNPID and cPID Output Vent Opening Change Curve.
Figure 31. Variation curves of controlled temperature and vent opening of greenhouse. (a) Controlled Temperature Curves of Greenhouse Under SNPID And cPID Control and (b) SNPID and cPID Output Vent Opening Change Curve.
Electronics 13 02083 g031aElectronics 13 02083 g031b
Figure 32. Details of temperature profiles before and after t = 3.33 h.
Figure 32. Details of temperature profiles before and after t = 3.33 h.
Electronics 13 02083 g032
Figure 33. Schematic diagram of the working state of the main control board. (a) the working status of the system, (b) current temperature, (c) relative humidity, (d) vent opening and (e) motor current.
Figure 33. Schematic diagram of the working state of the main control board. (a) the working status of the system, (b) current temperature, (c) relative humidity, (d) vent opening and (e) motor current.
Electronics 13 02083 g033
Figure 34. Internal and external views of the experimental Chinese solar greenhouse.
Figure 34. Internal and external views of the experimental Chinese solar greenhouse.
Electronics 13 02083 g034
Figure 35. Plot of variation in greenhouse temperature and air opening size. (a): Internal Air Temperature and (b) Tuyere Size.
Figure 35. Plot of variation in greenhouse temperature and air opening size. (a): Internal Air Temperature and (b) Tuyere Size.
Electronics 13 02083 g035
Figure 36. Greenhouse humidity variation graph.
Figure 36. Greenhouse humidity variation graph.
Electronics 13 02083 g036
Table 1. Parameter list of single neuron PID decoupling control system.
Table 1. Parameter list of single neuron PID decoupling control system.
Temperature ControllerValueHumidity ControllerValue
Neuron proportion coefficient0.2Neuron proportion coefficient0.2
Proportional weight coefficient0.5Proportional weight coefficient0.5
Integral weight coefficient0.5Integral weight coefficient0.5
Differential weight coefficient0.5Differential weight coefficient0.5
Proportional coefficient learning rate0.3Proportional coefficient learning rate
Integral coefficient learning rate
0.3
Integral coefficient learning rate0.3Differential coefficient learning rate0.3
Differential coefficient learning rate0.3Humidity controller0.3
Table 2. Assignment table of fuzzy variables.
Table 2. Assignment table of fuzzy variables.
DomainPBPMPSONSNMNB
−60000001
−5000000.50.5
−4000000.50.5
−40000010
−300000.50.50
−20000100
−10000.50.500
00000000
1000.50.5000
20010000
300.50.50000
40100000
50.50.500000
61000000
Table 3. Fuzzy Control Rules for Δ K P .
Table 3. Fuzzy Control Rules for Δ K P .
EEC
NBNMNSOPSPMPB
NBPBPBPMPMPSOO
NMPBPBPMPSPSONS
NSPMPMPMPSONSNS
OPMPMPSONSNMNM
PSPSPSONSNSNMNM
PMPSONSNMNMNMNB
PBOONMNMNBNBNB
Table 4. Fuzzy Control Rules for Δ K I .
Table 4. Fuzzy Control Rules for Δ K I .
EEC
NBNMNSOPSPMPB
NBNBNBNMNMNSOO
NMNBNBNMNSNSONS
NSNBNMNSNS0PSPS
ONMNMNSOPSPMPM
PSNMNSOPSPSPMPB
PMOOPSPSPMPBPB
PBOOPSPMPMPBPB
Table 5. Fuzzy Control Rules for Δ K D .
Table 5. Fuzzy Control Rules for Δ K D .
EEC
NBNMNSOPSPMPB
NBPSNSNBNBNBNMPS
NMPSNSNBNMNMNSO
NSONSNMNMNSNSO
OONSNSNSNSNSO
PSOOOOOOO
PMPBPSPSPSPSPSPB
PBPBPMPMPMPSPSPB
Table 6. SNPID self-control mode operation and response flow.
Table 6. SNPID self-control mode operation and response flow.
Parameters/ConditionsDescriptiveOperation/Response
Temperatures below the low
temperature warning
temperature or above the high
temperature warning
Trigger the safety mechanism and wait for the temperature
to return to the 18 °C~28 °C
range
-
Difference between temperature
and target temperature
Calculate the length of the air opening to be openedThe drive motor adjusts the air vents
to change the temperature inside the greenhouse
Temperature below the
optimal temperature range
According to the PID
principle, the size of the air outlet is gradually reduced to 0
If the air vent is closed for a certain period of
time and the temperature is still low, it is
reported that the heat input from sunlight is
insufficient
Temperature above the
optimal temperature range
Expand the air opening to the maximumIf the temperature is still high after ventilation, report that the ventilation and heat dissipation have reached the limit
Late wind mode time periodChecking that the conditions for the evening air mode
trigger are met
If satisfied, transfer to the evening air mode; otherwise, continue to execute the SNPID self-control mode
Thin Film Protection
Algorithm
Reduce the frequency of vent
adjustments to prolong film
and motor life
According to the average temperature
difference between the current and the last time to decide whether to adjust the air outlet or keep the air outlet unchanged
Table 7. Code Corresponding Function Table.
Table 7. Code Corresponding Function Table.
CatalogueDescribe
RT-Thread/includeThe header file of the source code
RT-Thread/components/finshRT Thread component—FinSH command-line interface file
RT-Thread/libcpu/arm/commonCommon interface files related to ARM processors
RT-Thread/lipcpu/arm/cortex-m4Interface files related to ARM Cortex-M4
RT-Thread/srcRT Thread kernel source code
Table 8. Comparison Table of Main Control Board and Central Controller Function Modules.
Table 8. Comparison Table of Main Control Board and Central Controller Function Modules.
NumberMain Control Board Function ModuleCentralized Controller Function Module
1Clock module: configure the clock frequency and working mode during program runtimeClock module: configure the clock frequency and working mode during program runtime
2Main thread module: used for message forwarding of various threads in the central controllerMain thread module: used for message forwarding of various threads in the central controller
3Display module: used for LED digital tube displayNetwork module: used to manage GSM network connections
4Buzzer module: used to configure the buzzerRTC Clock Module: used to configure UTC time
5Watchdog management module: used to manage the working situation of the watchdogFinSH Terminal Manager Module: used to provide a command-line interface
6RTC Clock Module: used to configure UTC timeEEPROM module: used to manage the reading and writing of EEPROM
7FinSH Terminal Manager Module: used to provide a command-line interfaceDisplay module: used to configure LCD screens
8EEPROM module: used to manage the reading and writing of EEPROMModbus module: used to configure Modbus communication
9Motor status detection module: used to call the electricity meter to read the working status of the motor-
10Motor drive module: used to control the on/off of relays-
11Temperature and humidity sensor monitoring module: used to read the values of temperature and humidity sensors-
12Modbus module: used to configure Modbus communication-
13Temperature and humidity automatic control module: used for automatic control of temperature and humidity-
14Temperature and humidity manual control module: used to receive manual control information-
Table 9. Time slices and interrupt priority table.
Table 9. Time slices and interrupt priority table.
NumberThread NameTime Slice LengthInterrupt Priority
1Main thread5 ms15
2Show threads5 ms15
3Buzzer thread5 ms15
4Watchdog management thread5 ms15
5EEPROM Management Thread5 ms15
6Motor status detection thread5 ms15
7Motor drive thread5 ms15
8Temperature and humidity sensor monitoring thread5 ms15
9Modbus thread10 ms10
10Temperature and humidity automatic control thread10 ms10
11Manual temperature and humidity control thread10 ms25
Table 10. Function Code Example of Temperature and Humidity Automatic Control Module.
Table 10. Function Code Example of Temperature and Humidity Automatic Control Module.
 // Algorithm for Temperature and Humidity Automatic Control Module.

#include “temp_humidity_control.h” // Include necessary header files.

// Definitions for easier understanding.
#define NOON_TIME_MIN 720 // Noon in minutes from midnight.

// Function prototypes for clarity.
ResultType AutomaticTemperatureControl(int current_time, ControlParams* params, MotorStatus* motor_status);

// Entry point for the SNPID automatic control mode.
case AOPERA_TIME_AUTO_SNPID:
  ResultType result = AutomaticTemperatureControl(mins_from_midnight, params, motor_status);
  if (result == RT_EOK) {
    motor_status->work_status = DEVIC_WORK_STATUS_AUTO; // Set device to automatic work status.
  }
  break;

// Implement the temperature control logic based on the time of day.
ResultType AutomaticTemperatureControl(int current_time, ControlParams* params, MotorStatus* motor_status)
{
  if (current_time <= NOON_TIME_MIN) {
    // Morning automatic mode.
    return app_auto_temp_oper(params->AM_close_temp, params->AM_best_temp, params->AM_open_temp, motor_status, params);
  } else {
    // Afternoon automatic mode.
    return app_auto_temp_oper(params->PM_close_temp, params->PM_best_temp, params->PM_open_temp, motor_status, params);
  }
}
Table 11. Sample SNPID Function Code.
Table 11. Sample SNPID Function Code.
// Function to perform neural network-based PID control
void NeuralKeywordPID(NEURALPID *vPID, float pv)
{
  // Define error variables and weight variables
  float x[3];  // Array to hold error, change in error, and rate of change in error
  float w[3];  // Array to hold normalized weights for PID
  float sabs;  // Sum of absolute values of weights for normalization
  float deltaResult; // Computed result change based on PID formula

  // Calculate current error and its derivatives
  x[0] = error;           // Current error
  x[1] = error - vPID->lasterror;       // Difference in error from last measurement
  x[2] = error - 2*vPID->lasterror + vPID->preerror; // Second derivative of the error

  // Normalize the weights of the PID components to ensure stable control
  sabs = fabs(vPID->wi) + fabs(vPID->wp) + fabs(vPID->wd); // Sum of absolute values of weights
  w[0] = vPID->wi / sabs; // Weight for the integral component normalized
  w[1] = vPID->wp / sabs; // Weight for the proportional component normalized
  w[2] = vPID->wd / sabs; // Weight for the derivative component normalized

  // Compute the PID control result using the normalized weights and error values
  deltaResult = (w[0]*x[0] + w[1]*x[1] + w[2]*x[2]) * vPID->kcoef; // Adjusted control output

  // Update the result in the PID structure
  vPID->result = result;  // Save the control result for use in the system

  // Execute learning rules for the neural network to adjust PID parameters based on performance
  NeureLearningRules(vPID, error, result, x);

  // Update error values for next iteration
  vPID->preerror = vPID->lasterror; // Save the previous error
  vPID->lasterror = error;      // Save the last error
}
Table 12. Step Response Performance Metrics.
Table 12. Step Response Performance Metrics.
Control MethodsRising Time (s)Adjustment Time (s)Peak Time (s)Overtone (%)
cPID1694.861036.951953.000.4
SNPID1246.72917.761477.000.03
AFPID1359.40931.461398.320.032
Table 13. Comparison of temperature management and ventilation control between experimental greenhouse and comparison greenhouse.
Table 13. Comparison of temperature management and ventilation control between experimental greenhouse and comparison greenhouse.
ParameterExperimental GreenhouseComparison Greenhouse
Average Temperature During Daytime (9:00–15:00)24.9 °C25.8 °C
Root Mean Square Error (RMSE)0.7341.594
Percentage of Temperature Readings Within 25 ± 1 °C90.2%40%
Maximum Ventilation Opening67 cm55 cm
Minimum Ventilation Opening5 cmUnchanged during certain periods
Temperature Control Accuracy±1 °C±2.5 °C
Temperature Stability and PrecisionHigh stability and high precision (using SNPID algorithm)Lower stability and precision
Insulation Performance at Night and Early MorningGood, with no significant temperature fluctuationsGood, with no significant temperature fluctuations
Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content.

Share and Cite

MDPI and ACS Style

Huang, S.; Xiang, H.; Leng, C.; Dai, T.; He, G. Intelligent Regulation of Temperature and Humidity in Vegetable Greenhouses Based on Single Neuron PID Algorithm. Electronics 2024, 13, 2083. https://doi.org/10.3390/electronics13112083

AMA Style

Huang S, Xiang H, Leng C, Dai T, He G. Intelligent Regulation of Temperature and Humidity in Vegetable Greenhouses Based on Single Neuron PID Algorithm. Electronics. 2024; 13(11):2083. https://doi.org/10.3390/electronics13112083

Chicago/Turabian Style

Huang, Song, Huiyu Xiang, Chongjie Leng, Tongyang Dai, and Guanghui He. 2024. "Intelligent Regulation of Temperature and Humidity in Vegetable Greenhouses Based on Single Neuron PID Algorithm" Electronics 13, no. 11: 2083. https://doi.org/10.3390/electronics13112083

Note that from the first issue of 2016, this journal uses article numbers instead of page numbers. See further details here.

Article Metrics

Back to TopTop