Environment monitoring system based on Internet of Things architecture
Through multi-sensor network and edge computing combined with fuzzy PID control, the problems of traditional greenhouse control systems are solved, and the rapid response and precise adjustment of greenhouse environmental parameters are achieved, and the control accuracy and resource utilization efficiency are improved.
Patent Information
- Application Number
- CN202510197581.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-02-21
- Publication Date
- 2025-07-08
AI Technical Summary
Traditional greenhouse control systems have lagged response, low adjustment accuracy and insufficient data integration. The existing Internet of Things and fuzzy control logic have failed to effectively solve the problems of rapid response and energy waste in nonlinear and time-varying systems.
It adopts multi-sensor network, edge computing and fuzzy PID control, combined with RS485 communication, MQTT protocol and STM32F103ZET6 controller to realize real-time acquisition, processing and precise regulation of environmental data, and adjust environmental parameters through PWM signal control actuator.
It realizes rapid response and precise adjustment of greenhouse environmental parameters, improves control accuracy and resource utilization efficiency, and provides real-time monitoring and abnormal warning capabilities.
Smart Images

Figure FT_1 
Figure SMS_1 
Figure SMS_3
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of smart agriculture, and particularly to a small greenhouse control system and method based on fuzzy control logic and an intelligent monitoring platform, which realizes real-time monitoring, dynamic adjustment, and intelligent management of greenhouse environmental parameters by combining Internet of Things technology. Background Art
[0002] Traditional greenhouse control systems usually adopt conventional PID control or manual adjustment methods, and there are the following problems: Response lag: The changes in environmental parameters (such as temperature and humidity) are complex, and traditional control methods are difficult to quickly respond to non-linear and time-varying systems. Low adjustment accuracy: In a multi-parameter coupling environment, fixed PID parameters cannot adapt to dynamic changes, resulting in large overshoot and poor stability. Insufficient data integration: Sensor data is scattered, lacking a unified intelligent monitoring platform, and real-time visualization and abnormal warning cannot be achieved. In the prior art, some studies have tried to introduce Internet of Things (IoT) and fuzzy control logic to optimize greenhouse management, but there are still the following deficiencies: The design of the fuzzy control rule base is single, without combining dynamic PID parameter adjustment, and the adaptive ability is limited; The control strategy of the actuator is not optimized in layout, resulting in energy waste and uneven distribution of environmental parameters. The present invention aims at the above problems and proposes a small greenhouse system integrating fuzzy PID control, edge computing, and real-time monitoring, which significantly improves the control accuracy and resource utilization efficiency. Summary of the Invention
[0003] Object of the Invention To provide a small greenhouse control system and method based on fuzzy control logic and an intelligent monitoring platform, solve the problems of response lag, low adjustment accuracy, and insufficient data integration in traditional greenhouse control, and realize precise control and intelligent management of environmental parameters.
[0004] The object of the present invention can be achieved by the following technical solutions: Deploy multiple temperature sensors and humidity sensors inside the greenhouse, collect environmental data in real time according to the time series, and transmit the data to the central control unit through a wireless communication module; Each sensor is connected to a hub through an RS485 interface. RS485 is a reliable long-distance communication standard, which has the advantages of strong anti-interference ability, long transmission distance, and support for multi-device connection.
[0005] The hub aggregates the data from each sensor and communicates with the edge gateway through a serial port. The edge gateway is responsible for receiving the environmental data from the hub in the system and performing preliminary processing and format conversion on these data. First, receive sensor data such as temperature and humidity from the hub through a pre-configured interface. Then, perform preliminary processing on the data to ensure the accuracy of the data.
[0006] After the processing is completed, the data is encapsulated into the JSON format, and the server address, topic, and client ID of the MQTT connection are set. These JSON data are sent to the specified MQTT topic through the MQTT protocol. To ensure the real-time nature of the data, the edge gateway sends the processed JSON data once every second.
[0007] The received JSON data is sent to the STM32F103ZET6 controller through serial communication. The controller code is written in Keil5 and is responsible for processing and analyzing the received environmental data.
[0008] The real-time data is compared with the preset parameters, and the actuator control time is adjusted through fuzzy PID control.
[0009] According to the control result, the duty cycle of the PWM (pulse width modulation) signal is adjusted. Through the PWM signal, the controller can accurately control the on / off state of the electromagnetic relay, thereby controlling the operation of the actuator (such as a fan, heater, cooler, etc.) and adjusting the environmental parameters to achieve the set goal.
[0010] The backend of the big data platform receives data through WebSocket and updates the display interface in real time. Any change in the data can be immediately reflected on the user interface, helping users conduct long-term environmental monitoring and trend analysis.
[0011] As a further solution of the present invention: an air temperature and humidity sensor (measurement range: -40°C to 80°C, accuracy ±0.5°C; humidity 0% to 100%RH, accuracy ±3%RH); a soil multi-parameter sensor (monitoring soil temperature, moisture, conductivity, pH value); connected to an industrial-grade hub using an RS485 interface, supporting 8-channel signal input, with an anti-interference ability of ±10kV. Edge gateway module: based on the STM32F103ZET6 microcontroller, integrated with the ESP8266 WiFi module; converts RS485 signals into JSON format data and transmits it to the control module in real time through the MQTT protocol (QoS = 1).
[0012] As a further solution of the present invention: the system architecture includes three main parts: an environmental monitoring system, a control system, and a data display platform. The main task of the environmental monitoring system is to collect, transmit, and preliminarily process environmental data. The system consists of 6 RS485 sensing nodes and an edge gateway. Each sensor is connected to the hub through an RS485 interface. RS485 is a reliable long-distance communication standard with the advantages of strong anti-interference ability, long transmission distance, and support for multi-device connection. The hub aggregates the data from each sensor and communicates with the edge gateway through the serial port.
[0013] As a further solution of the present invention: The edge gateway is responsible for receiving environmental data from the hub in the system, and performing preliminary processing and format conversion on this data. First, it receives sensor data such as temperature, humidity, etc. from the hub through a pre-configured interface. Then, it performs preliminary processing on the data to ensure the accuracy of the data. After the processing is completed, the data is encapsulated into JSON format, and the server address, topic, and client ID of the MQTT connection are set, and these JSON data are sent to the specified MQTT topic through the MQTT protocol. To ensure the real-time nature of the data, the edge gateway sends the processed JSON data once per second.
[0014] As a further solution of the present invention: The MQTT protocol is a lightweight message transmission protocol designed for communication between Internet of Things devices, featuring low bandwidth and high reliability. It adopts the publish / subscribe model, classifies and delivers messages through topics, and devices can subscribe to or publish messages of specific topics as needed. In addition, MQTT supports three message service quality (QoS) levels to ensure reliable message transmission, from at least once transmission to exactly once transmission, meeting the requirements for data reliability in different application scenarios. The platform receives environmental data by subscribing to this MQTT topic and performs visual display on the data display platform for users to monitor and analyze environmental changes in real time. The entire process realizes the full-process automation processing from data collection to transmission, processing, and then to display.
[0015] As a further solution of the present invention: The data collected by the sensor is first received and preliminarily processed by the edge gateway, and then the processed data is sent to the specified MQTT topic. The system uses the ESP8266 WiFi module to connect to the MQTT server and subscribes to this topic to receive environmental data, and the received JSON data is sent to the STM32F103ZET6 controller through serial communication.
[0016] As a further solution of the present invention: The controller code is written by Keil5 and is responsible for processing and analyzing the received environmental data. It compares the real-time data with preset parameters and adjusts the duty cycle of the PWM (pulse width modulation) signal according to the comparison result. Through the PWM signal, the controller can precisely control the on / off state of the electromagnetic relay, thereby controlling the operation of actuators (such as fans, heaters, coolers, etc.) and adjusting environmental parameters to reach the set target. This control mechanism forms a closed-loop control system through continuous data reception, processing, transmission, comparison, and adjustment, ensuring that environmental parameters are monitored and adjusted in real time and maintained within the preset target range. Through precise PWM signal control, the system can efficiently and reliably adjust environmental conditions and achieve the expected control effect.
[0017] As a further solution of the present invention: The data display platform is a crucial part of the system, which is used to receive, process, and display the data sent by the environmental monitoring system. This platform is written in Python and adopts the front-end and back-end MVVM separation framework, ensuring the modularity and efficiency of the system. The back-end is implemented through the Django Channels framework, and its main task is to process the data from the edge gateway and communicate with the front-end in real time through WebSocket.
[0018] As a further solution of the present invention: WebSocket is a full-duplex communication protocol that allows the server to actively push data to the client, ensuring the real-time nature of data display. The back-end creates an MQTT client through the paho.mqtt.client library developed by Eclipse Paho, connects to the MQTT broker to receive the environmental JSON data published on the MQTT topic. The Django framework processes this data and supports WebSocket communication through Django Channels extensions, sending the data to the front-end in real time. The front-end is implemented using a JavaScript framework, receives the data pushed by the back-end through WebSocket, and updates the display interface in real time. Any change in the data can be immediately reflected on the user interface, helping users conduct long-term environmental monitoring and trend analysis. The entire system is designed efficiently and reliably, ensuring that users can monitor environmental data in real time and accurately and make timely responses.
[0019] As a further solution of the present invention: A PTC heater is installed below the small greenhouse, and fans are installed on both sides above. Temperature and humidity sensors are placed at different positions in the greenhouse, and different target temperatures are set to simulate the working process of the greenhouse operation and infer the transfer function model of the greenhouse. Experimental data shows that in the closed greenhouse model, when the environmental temperature is about 25.4 °C and the target temperature is set to 30.0 °C, the internal heat load needs to be increased at this time, and the internal electric heater works and stops when the target temperature is reached; if the temperature is higher than the target temperature, the ventilation fan is turned on to cool down. Temperature data is recorded every 1 second within the 750-second time period.
[0020] To identify the object model, the recorded sample values are imported into the MATLAB / Simulink environment to determine the transfer function of the object model. The nonlinear least squares method is applied for identification using the System Identification Toolbox provided in the MATLAB environment. The best fit value is calculated using the following relationship: After importing the collected temperature data into MATLAB, the least squares method is applied using the System Identification Toolbox in Simulink to analyze and identify the transfer function of the system. The best fit degree of the model is calculated through the following formula
[0021] Among them R 2 is the best goodness of fit of the model, y is the actually collected temperature data, y m is the temperature data predicted according to the identified transfer function model., is the mean of the actual temperature data. This formula evaluates the accuracy of the model by calculating the ratio of the sum of squared errors (the numerator part) between the model predicted value and the actual measured value to the total variance (the denominator part) of the actual measured value deviating from its mean. If the R2 value is close to 100%, it indicates that the identified transfer function model can well fit the actual data, otherwise it indicates a low matching degree between the model and the data. As shown, the temperature output by the greenhouse system and the fitting curve are given. The obtained fitting curve is:
[0022] The goodness of fit of this curve is: 94.54% Fuzzy control module: The output variables are the dynamic adjustment amounts of PID parameters (△KP, △KI, △KD), including 49 fuzzy rules. Through MATLAB / Simulink simulation optimization, the overshoot is reduced to 5.85% (12.3% for traditional PID). In this study, the three parameters of the PID controller, namely KP , KI and KD are all obtained according to the PID regulator in matlab. The obtained initial PID parameters are: KP =1.048, KI =0.0064, KD =5.43. In the system simulation and analysis, the initial temperature of the greenhouse is set to 25°C, and the simulation time is set to 750 seconds. The fuzzy PID control effect is compared with the PID control effect. Description of the drawings
[0023] Figure 1 is the overall conceptual diagram of the system The overall conceptual diagram of the system proposed in this paper is as Figure 1As shown below. This system architecture consists of three main parts: an environmental monitoring system, a control system, and a data display platform. The main task of the environmental monitoring system is to collect, transmit, and preprocess environmental data. This system consists of 6 RS485 sensing nodes and an edge gateway. Each sensor is connected to a hub through an RS485 interface. RS485 is a reliable long-distance communication standard with the advantages of strong anti-interference ability, long transmission distance, and support for multi-device connection. The hub aggregates data from each sensor and communicates with the edge gateway through a serial port. The edge gateway in the system is responsible for receiving environmental data from the hub and performing preliminary processing and format conversion on this data. First, it receives sensor data such as temperature and humidity from the hub through a pre-configured interface. Then, it performs preliminary processing on the data to ensure the accuracy of the data. After the processing is completed, the data is encapsulated into JSON format, and the server address, topic, and client ID of the MQTT connection are set, and these JSON data are sent to the specified MQTT topic through the MQTT protocol. To ensure the real-time nature of the data, the edge gateway sends the processed JSON data once per second.
[0024] The data collected by the sensors is first received and preprocessed by the edge gateway, and then the processed data is sent to the specified MQTT topic. The system uses an ESP8266 WiFi module to connect to the MQTT server and subscribes to this topic to receive environmental data. The received JSON data is sent to the STM32F103ZET6 controller through serial communication. The controller code is written in Keil5 and is responsible for processing and analyzing the received environmental data. The real-time data is compared with preset parameters, and the duty cycle of the PWM (Pulse Width Modulation) signal is adjusted according to the comparison result. Through the PWM signal, the controller can precisely control the on / off state of the electromagnetic relay, thereby controlling the operation of actuators (such as fans, heaters, coolers, etc.) and adjusting the environmental parameters to achieve the set goals. This control mechanism forms a closed-loop control system through continuous data reception, processing, transmission, comparison, and adjustment, ensuring that the environmental parameters are monitored and adjusted in real time and maintained within the preset target range. Through precise PWM signal control, the system can efficiently and reliably adjust the environmental conditions and achieve the expected control effect.
[0025] The data display platform is a crucial part of the system, which is used to receive, process, and display the data sent by the environmental monitoring system. This platform is written in Python and adopts the front-end and back-end MVVM separation framework, ensuring the modularity and efficiency of the system. The back-end is implemented through the Django Channels framework, and its main task is to process the data from the edge gateway and communicate with the front-end in real time through WebSocket. WebSocket is a full-duplex communication protocol that allows the server to actively push data to the client, ensuring the real-time nature of data display. The back-end creates an MQTT client through the paho.mqtt.client library developed by Eclipse Paho, connects to the MQTT broker to receive the environmental JSON data published on the MQTT topic. The Django framework processes this data and supports WebSocket communication through Django Channels extensions, sending the data to the front-end in real time. The front-end is implemented using a JavaScript framework, receives the data pushed by the back-end through WebSocket, and updates the display interface in real time. Any data changes can be immediately reflected on the user interface, helping users conduct long-term environmental monitoring and trend analysis. The entire system is designed to be efficient and reliable, ensuring that users can monitor environmental data in real time and accurately and make timely responses.
Claims
1. A small greenhouse control system based on fuzzy control logic and an intelligent monitoring platform, characterized in that, It includes the following steps: S1: Deploy multiple temperature sensors and humidity sensors inside the greenhouse. Collect environmental data in real time according to the time series, and transmit the data to the central control unit through the wireless communication module; S2: Each sensor is connected to the hub through the RS485 interface. RS485 is a reliable long-distance communication standard, which has the advantages of strong anti-interference ability, long transmission distance, and support for multi-device connection. S3: The hub aggregates the data from each sensor and communicates with the edge gateway through the serial port. The edge gateway is responsible for receiving the environmental data from the hub in the system and performing preliminary processing and format conversion on these data. First, receive sensor data such as temperature and humidity from the hub through the pre-configured interface. Then, perform preliminary processing on the data to ensure the accuracy of the data. S4: After the processing is completed, the data is encapsulated into the JSON format, and the server address, topic, and client ID of the MQTT connection are set. The JSON data is sent to the specified MQTT topic through the MQTT protocol. To ensure the real-time nature of the data, the edge gateway sends the processed JSON data once per second. S5: The received JSON data is sent to the STM32F103ZET6 controller through serial communication. The controller code is written in Keil5 and is responsible for processing and analyzing the received environmental data. S6: Compare the real-time data with the preset parameters, and adjust the actuator control time through fuzzy PID control. S7: Adjust the duty cycle of the PWM (pulse width modulation) signal according to the control result. Through the PWM signal, the controller can accurately control the on / off state of the electromagnetic relay, thereby controlling the operation of the actuator (such as a fan, heater, cooler, etc.) and adjusting the environmental parameters to achieve the set goal. S8: The backend of the big data platform receives the data through WebSocket and updates the display interface in real time. Any change in the data can be immediately reflected on the user interface, helping the user to perform long-term environmental monitoring and trend analysis.
2. The system according to claim 1, wherein The input variables of the fuzzy PID control module are the environmental parameter error (E) and the error change rate (Ec), and the output variables are the dynamic adjustment amounts of the PID parameters (△KP, △KI, △KD). Its fuzzy rule base contains 49 control rules based on language variables, and system simulation and parameter optimization are carried out through MATLAB / Simulink.
3. The system according to claim 1, wherein The sensor network module uses an RS485 hub to achieve multi-sensor data integration, supports 8-channel RS485 signal input, and ensures data transmission stability through industrial-level anti-interference design.
4. The system according to claim 1, wherein The edge gateway module is configured as: communicate with the cloud platform through the MQTT protocol, subscribe to the specified topic and push JSON format data in real time; use the STM32F103ZET6 microcontroller and the ESP8266WiFi module to achieve data processing and wireless transmission functions.
5. The system according to claim 1, wherein The backend of the intelligent monitoring platform is based on the Django Channels framework. The front end uses JavaScript to achieve dynamic data visualization and is synchronized with the backend in real time through the WebSocket protocol, supporting the setting of abnormal thresholds and the automatic alarm function.
6. The system according to claim 1, wherein The control strategy of the actuator module includes: heaters are installed at the lower part of the greenhouse, coolers are installed at the upper part, and fans are combined to optimize air circulation; the relay switch is adjusted through PWM signals to achieve precise control of the actuator.
7. A dynamic adjustment method for greenhouse environmental parameters based on fuzzy logic, characterized in that, It includes the following steps: Real-time collect greenhouse environment data through the sensor network and transmit it to the edge gateway through the MQTT protocol; Use a fuzzy PID controller to fuzzify the error (E) and the rate of change of error (Ec), and infer and generate the adjustment amount of PID parameters according to the preset rule base; generate a control signal through the adjusted PID parameters to drive the actuator module to adjust the temperature and humidity; push the environmental data and control results to the intelligent monitoring platform in real time to achieve visual display and abnormal warning.
8. The method according to claim 1, wherein The fuzzy rule base of the fuzzy PID controller is designed based on the following membership functions: for the input variables E and Ec, the membership function adopts the Trimf type; the fuzzy universes of discourse of the output variables △KP, △KI, and △KD are respectively, and the membership function adopts a trapezoidal distribution.
9. The method according to claim 1, characterized in that, An intelligent monitoring platform for greenhouse environment monitoring, characterized by including: The main function of the data receiving module is to receive greenhouse environment data through the MQTT (Message Queuing Telemetry Transport) protocol. The edge gateway in this system is responsible for collecting various environmental parameters in the greenhouse (such as temperature, humidity, carbon dioxide concentration, soil humidity, etc.), and after encapsulating the data in JSON format, it publishes it to the topic on the server side through the MQTT protocol. On the server side, the MQTT client component in the Django framework is responsible for subscribing to the corresponding environmental data topics and receiving the real-time data stream from the greenhouse. The lightweight feature of the MQTT protocol ensures efficient data transmission and can operate stably even in low-bandwidth and high-latency network environments. The client can set the QoS (Quality of Service) level to ensure data reliability. In addition, to enhance the scalability of the system, it supports parallel reception of environmental data from multiple greenhouses, and each greenhouse can be identified by a unique Topic for the data processing module to classify and store. Data processing module The data processing module is responsible for parsing the received JSON data and storing it in the database. This module is implemented based on the Django framework and includes the following key steps: Data parsing: Use the view and model components of Django to parse the JSON data received by the MQTT client. The parsed data fields include temperature, humidity, etc. Data storage: Use a relational database (such as MySQL or PostgreSQL) to store historical data. Design a standardized data table structure, and store the data of each sensor according to the timestamp to support subsequent trend analysis and data mining. Data cleaning: Use outlier detection algorithms (such as Z-score or IQR-based outlier detection) to remove invalid data. Fill in missing values, such as using linear interpolation or mean filling methods, to ensure data integrity. Data analysis: Calculate the daily average value, maximum value, minimum value and change trend of key environmental parameters. Combine the historical data of the greenhouse to train machine learning models (such as LSTM or ARIMA) for environmental parameter prediction to assist decision-making. Real-time display module To improve the visualization effect of monitoring, this platform uses the WebSocket protocol to achieve real-time data push and dynamically update the greenhouse environment parameter curve on the front-end interface. This module mainly includes the following functions: WebSocket data push: The server-side creates a WebSocket connection based on Django Channels. When new data is inserted into the database, it automatically triggers a WebSocket message push and sends the latest environmental parameters to the front-end. Early warning module: The early warning module is used for automatic alarm when environmental parameters are abnormal to ensure that the greenhouse environment is always in a suitable state. The specific implementation of this module is as follows: Detection mechanism: Set the safety thresholds of environmental parameters. For example, the temperature range is set to 15°C to 35°C, and the humidity range is set to 50% to 80%. When a certain environmental parameter exceeds the set threshold, an early warning event is triggered. Alarm method: Deploy buzzers and LED warning lights inside the greenhouse. When the parameters exceed the standard, the warning device is controlled by a single-chip microcomputer or PLC to start.