An internet of things environment prediction and monitoring method and system
By using an IoT-based environmental prediction and monitoring system, combined with a Transformer prediction model and intelligent control strategies, the problems of low accuracy in environmental prediction and resource waste in existing technologies have been solved. This has enabled high-precision monitoring and high-accuracy agricultural environmental prediction, while saving water resources.
Patent Information
- Application Number
- CN202310061924.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-01-15
- Publication Date
- 2025-11-04
- Estimated Expiration
- 2043-01-15
AI Technical Summary
Existing methods for predicting plantation and greenhouse environments rely on weather station data, which cannot be adjusted according to actual conditions. Furthermore, machine learning-based methods are computationally expensive, have low prediction accuracy, and lack effective intelligent irrigation control strategies, leading to resource waste and adverse effects on agricultural product growth.
An IoT-based environmental prediction and monitoring system is adopted, including an environmental data acquisition and control terminal and a cloud server. It utilizes a Transformer prediction model combined with an environmental information acquisition module, and achieves high-precision monitoring and high-accuracy prediction of environmental data through wireless communication and cloud computing technologies. It also incorporates intelligent control strategies for irrigation and ventilation operations.
It achieves high-precision monitoring and high-accuracy prediction of environmental data, reduces resource waste, improves the monitoring and prediction capabilities of agricultural production environment, avoids gradient explosion and gradient vanishing problems, supports multi-node deployment, and reduces computing and communication costs.
Smart Images

Figure CN116184891B_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of Internet of Things (IoT) environmental monitoring technology, specifically an IoT environmental prediction and monitoring method and system. Background Technology
[0002] For plantations and greenhouses, crop growth is closely related to water, temperature, air humidity, carbon dioxide concentration, and light intensity. Therefore, the control of temperature, humidity, water, and carbon dioxide content in plantations and greenhouses has a significant impact on crop growth.
[0003] Most existing methods for predicting plantation and greenhouse environments are based on weather station data or machine learning. However, weather station-based methods rely on weather station monitoring and cannot be adjusted according to actual conditions. Machine learning-based methods typically incur high computational costs, making them unsuitable for embedded terminals with limited computing and communication capabilities. Furthermore, the prediction algorithms commonly used in machine learning, such as RNNs and LSTMs, suffer from gradient explosion and vanishing gradients, and cannot effectively parallelize data processing, resulting in less than ideal training performance on long datasets. Therefore, the accuracy of existing plantation and greenhouse environment predictions is low. In addition, existing plantation and greenhouse environments lack effective intelligent irrigation control strategies, generally relying on traditional flood irrigation and other extensive irrigation methods, which not only wastes water resources severely but also hinders crop growth. Summary of the Invention
[0004] The purpose of this invention is to provide an Internet of Things (IoT) method and system for environmental prediction and monitoring, so as to improve the accuracy and precision of agricultural production environment prediction and monitoring and reduce resource waste.
[0005] To achieve the above objectives, the present invention employs the following technical methods:
[0006] An IoT-based environmental prediction and monitoring system includes an environmental data acquisition and control terminal and a cloud server. The environmental data acquisition and control terminal includes an environmental information acquisition module, an MCU control module, an execution module, a communication module, and a power supply module. The MCU control module stores the intelligent control strategy of the execution module, which includes a water supply unit. The output of the environmental information acquisition module is connected to the input of the MCU control module, and the output of the MCU control module is connected to the input of the water supply unit. The MCU control module communicates with the cloud server through the communication module. The power supply module provides power to the environmental information acquisition module, the MCU control module, and the execution module. The cloud server stores a Transformer prediction model, which includes an encoder module, an attention module, and an output fully connected module. Environmental data from the cloud server is input to the encoder module, and the output of the encoder module is input to the attention module. The attention module extracts the correlation information between environmental data within a continuous time period, and the output of the attention module is input to the output fully connected module. The output fully connected module outputs the prediction result of the environmental data for the next time period.
[0007] As a limitation: the environmental information acquisition module includes a temperature and humidity sensor, a light intensity sensor, and a CO2 sensor. The output terminals of the temperature and humidity sensor, the light intensity sensor, and the CO2 sensor are all connected to the input terminal of the MCU control module.
[0008] As a limitation: the execution module also includes a ventilation unit, the input of which is connected to the output of the MCU control module; the water supply unit uses a DC motor water pump, and the ventilation unit uses a DC motor fan.
[0009] As a limitation, the environmental data acquisition and control terminal also includes a display module, the input of which is connected to the output of the MCU control module.
[0010] As a limitation: the IoT environment prediction and monitoring system also includes a mobile app and a remote monitoring host, both of which are connected to a cloud server.
[0011] As a limitation: the MCU control module is an STM32F103C8T6 microcontroller, and the communication module is an IoT module.
[0012] This invention also provides a prediction and monitoring method for the above-mentioned Internet of Things (IoT) environment prediction and monitoring system, comprising the following steps:
[0013] S1. The environmental information acquisition module in the environmental data acquisition and control terminal collects environmental data in the plantation or greenhouse and sends it to the MCU control module.
[0014] S2, the MCU control module sends the received environmental data to the cloud server periodically through the communication module;
[0015] S3. The cloud server stores the received environmental data and inputs it into the encoder module of the trained Transformer prediction model. The output of the encoder module is input into the attention module. The attention module extracts the correlation information between environmental data in continuous time periods. The output of the attention module is input into the output fully connected module. The output fully connected module outputs the prediction result of the environmental data for the next time period. The cloud server periodically sends the predicted environmental data for the next time period back to the MCU control module.
[0016] S4. The MCU control module controls the irrigation operation of the water supply unit according to the environmental data predicted by the cloud server for the next time period and the environmental data collected by the environmental information acquisition module for the corresponding time period, based on the intelligent control strategy. As a limitation: the training process of the Transformer prediction model is as follows: the cloud server acquires the environmental data uploaded by the environmental data acquisition and control terminal, packages the environmental data into datasets according to time periods, and divides them into training and test sets; the training set data is input to the encoder module, which performs linear transformation and position encoding on the training set data. The combined output calculation formula for the linear transformation and position encoding is:
[0017] X IE =(X IN ·W0+b0)+P
[0018] In the above formula, X IN ∈i T×d The input training set data is a T x d matrix; X IE It is the combined output of linear transformation and positional encoding, X IE ∈i T×k Let be a T-row, k-column matrix; W0∈i d×k It is the first linear transformation matrix spanning all time intervals, and is a d-row, k-column matrix; b0∈i k Indicates the first bias; P∈i T×k The positional encoding matrix is a T-row, k-column matrix; P and W0 are initially initialized randomly; the combined output of the linear transformation and positional encoding is fully connected and normalized before being input into the attention module, and the normalized output X is then fed into the attention module. FF for:
[0019] X FF =Norm(X) IE +ReLU(X IE ·W1+b1)·W1+b2)
[0020] In the formula, W1∈id×k It is the second linear transformation matrix spanning all time intervals, and is a d-row, k-column matrix; b1∈i k Indicates the second bias; b2∈i k Indicates the third bias;
[0021] X FF Generate three input matrices K, V, Q for the attention module, where K ∈ i T×k ,V∈i T×k ,Q∈i T×k Each of the three input matrices K, V, and Q is a T-row, k-column matrix. Then, a softmax activation function is applied to the three input matrices K, V, and Q to obtain the connection matrix C of the attention module, where C ∈ i. T×k Let be a T-row, k-column matrix. The formula for calculating the connection matrix C of the attention module is:
[0022]
[0023] In the formula, h represents the number of multi-head attention heads used; in this embodiment, eight attention heads are used. After normalizing the connection matrix C of the attention module, the ReLU activation function is applied to output the predicted value of the fully connected layer. This refers to the predicted environmental data for the next time period, and then based on the predicted environmental data for the next time period... Calculate the loss function value MSE using the actual environmental data y for the corresponding time period; the formula for calculating the loss function value is:
[0024]
[0025] Where N is the number of samples, and y is the true value. This is a predicted value;
[0026] Determine whether the loss function value has reached the preset value. If the loss function value is greater than the preset value, adjust the parameters of the position encoding matrix P and the linear transformation matrix W. If the loss function value is less than or equal to the preset value, obtain the trained Transformer prediction model. Input the test set data into the trained Transformer prediction model and evaluate the prediction performance of the trained Transformer prediction model.
[0027] As a further clarification: the IoT environmental prediction and monitoring system also includes a mobile app and a remote monitoring host. The environmental data acquisition and control terminal in step S1 also includes a display module. The environmental information acquisition module includes a temperature and humidity sensor, a light intensity sensor, and a CO2 sensor. The environmental data includes the temperature and humidity collected by the temperature and humidity sensor, the light intensity collected by the light intensity sensor, and the CO2 concentration collected by the CO2 sensor. Step S2 also includes an MCU control module that sends the received environmental data to the display module to display the environmental data in real time. Step S3 also includes a cloud server that sends the received environmental data and the predicted environmental data for the next time period to the mobile app and the remote monitoring host. Users can view the environmental data information received by the cloud server and the environmental data predicted by the cloud server for the next time period through the mobile app and the remote monitoring host.
[0028] As a further limitation: the execution module also includes a ventilation unit; step S4 also includes the MCU control module controlling the ventilation operation of the ventilation unit according to the environmental data of the next time period predicted by the cloud server and the environmental data of the corresponding time period collected by the environmental information acquisition module, based on the intelligent control strategy; the intelligent control strategy includes a water supply control strategy and a ventilation control strategy. The water supply control strategy is as follows: in each feedback cycle of the cloud server, the humidity of the predicted next time period is compared with the preset humidity value, and the humidity of the corresponding time period collected by the temperature and humidity sensor is compared with the preset humidity value. The MCU control module controls the start frequency of the water supply unit and the duration of each start based on the comparison result; the ventilation control strategy is as follows: in each feedback cycle of the cloud server, the CO2 concentration of the predicted next time period is compared with the preset CO2 concentration value, and the CO2 concentration collected by the CO2 sensor is compared with the preset CO2 concentration value. The MCU control module controls the start frequency of the ventilation unit and the duration of each start based on the comparison result.
[0029] The beneficial effects achieved by this invention, due to the adoption of the above-described solution, compared with the prior art, are as follows:
[0030] This invention provides an IoT-based environmental prediction and monitoring method and system. By setting up an environmental data acquisition and control terminal and a cloud server, and employing IoT wireless communication and cloud computing technologies, it features simple deployment, low energy consumption, and support for multi-node deployment. It does not rely on the computing power of an embedded MCU. A Transformer prediction model is set up in the cloud server to predict environmental data for the next time period. The predicted data does not depend on weather station monitoring and can be adjusted according to actual conditions. Furthermore, it combines environmental data acquisition modules to collect environmental data for the corresponding time period, achieving high-precision monitoring and high-accuracy prediction of environmental data. Irrigation is carried out based on the predicted environmental data, the collected environmental data, and intelligent control strategies, saving water resources. The Transformer prediction model, based on the Transformer algorithm, avoids the problems of gradient explosion and gradient vanishing, exhibits good data parallel processing performance, and incorporates an attention mechanism to improve the training effect on long datasets.
[0031] This invention is applicable to monitoring and predicting agricultural production environments. Attached Figure Description
[0032] The present invention will now be described in further detail with reference to the accompanying drawings and specific embodiments.
[0033] Figure 1 This is a structural block diagram of the Internet of Things (IoT) environment prediction and monitoring system according to an embodiment of the present invention;
[0034] Figure 2 This is a flowchart of the IoT environment prediction and monitoring method according to an embodiment of the present invention;
[0035] In the diagram: 1. Environmental data acquisition and control terminal; 2. Environmental information acquisition module; 3. Execution module. Detailed Implementation
[0036] The present invention will be further described below with reference to the embodiments. However, those skilled in the art should understand that the present invention is not limited to the following embodiments. Any improvements and equivalent changes made based on the specific embodiments of the present invention are within the scope of protection of the claims of the present invention.
[0037] Example: An Internet of Things (IoT) environmental prediction and monitoring method and system
[0038] An IoT-based environmental prediction and monitoring system, its structural block diagram is as follows: Figure 1As shown, the system includes an environmental data acquisition and control terminal 1, a cloud server, a mobile app, and a remote monitoring host. The environmental data acquisition and control terminal 1 is deployed in a plantation or greenhouse. It includes an environmental information acquisition module 2, an MCU control module, an execution module 3, a communication module, a display module, and a power supply module. The MCU control module stores the intelligent control strategy of the execution module 3. The environmental information acquisition module 2 includes a temperature and humidity sensor, a light intensity sensor, and a CO2 sensor. The execution module 3 includes a water supply unit and a ventilation unit. The input terminals of the MCU control module are connected to the output terminals of the temperature and humidity sensor, the light intensity sensor, and the CO2 sensor via an IIC bus. The output terminals of the MCU control module are connected to the input terminals of the water supply unit and the ventilation unit via an IIC bus. The output terminal is connected to the input terminal of the display module via an SPI bus. The MCU control module is connected to the communication module via a serial interface. The communication module is connected to the cloud server via a network. The cloud server communicates with the mobile app and the remote monitoring host. The power supply module supplies power to the environmental information acquisition module 2, the MCU control module, and the execution module 3. The cloud server internally stores a Transformer prediction model, which includes an encoder module, an attention module, and an output fully connected module. Environmental data from the cloud server is input to the encoder module. The output of the encoder module is input to the attention module. The attention module extracts the correlation information between environmental data within a continuous time period. The output of the attention module is input to the output fully connected module. The output fully connected module outputs the prediction result of the environmental data for the next time period.
[0039] In this embodiment, the MCU control module is an STM32F103C8T6 microcontroller, the communication module is an IoT module, the temperature and humidity sensor is a DHT11 digital sensor, the illuminance sensor is a BH1750 illuminance sensor, the CO2 sensor is an RBY-CO2 gas sensor, the display module is a 0.96-inch 7-pin SPI bus LCD, the water supply unit is a DC motor water pump, the ventilation unit is a DC motor fan, and the power supply module is a 12V DC power supply, which is stepped down to 5V and 3.3V through an LDO chip to power the environmental information acquisition module 2, the MCU control module, and the execution module 3.
[0040] The flowchart of the IoT environment prediction and monitoring method in this embodiment is as follows: Figure 2 As shown, it includes the following steps:
[0041] S1. The environmental information acquisition module 2 in the environmental data acquisition and control terminal 1 collects environmental data in the plantation or greenhouse and sends it to the MCU control module; the environmental data includes temperature and humidity collected by the temperature and humidity sensor, illuminance collected by the illuminance sensor, and CO2 concentration collected by the CO2 sensor.
[0042] S2, the MCU control module sends the received environmental data to the cloud server periodically through the communication module; the MCU control module sends the received environmental data to the display module to display the environmental data in real time;
[0043] S3. The cloud server stores the received environmental data and inputs it into the encoder module of the trained Transformer prediction model. The output of the encoder module is input into the attention module, which extracts the correlation information between environmental data within a continuous time period. The output of the attention module is input into the output fully connected module, which outputs the prediction result of the environmental data for the next time period. The cloud server periodically sends the predicted environmental data for the next time period back to the MCU control module, with a return cycle of one hour. The cloud server sends the received environmental data and the predicted environmental data for the next time period to the mobile app and the remote monitoring host. Users can view the environmental data information received by the cloud server and the predicted environmental data for the next time period through the mobile app and the remote monitoring host.
[0044] The training process of the Transformer prediction model is as follows: The cloud server acquires the environmental data uploaded by the environmental data acquisition and control terminal 1, packages the environmental data into datasets according to time periods, uses the first 70% of the data as the training set, and the last 30% as the test set; the training set data is input into the encoder module, which performs linear transformation and position encoding on the training set data. The combined output calculation formula for the linear transformation and position encoding is as follows:
[0045] X IE =(X IN ·W0+b0)+P
[0046] In the above formula, X IN ∈i T×d The input training set data is a T x d matrix; X IE It is the combined output of linear transformation and positional encoding, X IE ∈i T×k Let be a T-row, k-column matrix; W0∈i d×k It is the first linear transformation matrix spanning all time intervals, and is a d-row, k-column matrix; b0∈i k Indicates the first bias; P∈i T×kThe positional encoding matrix is a T-row, k-column matrix; P and W0 are initially initialized randomly; the combined output of the linear transformation and positional encoding is fully connected and normalized before being input into the attention module, and the normalized output X is then fed into the attention module. FF for:
[0047] X FF =Norm(X) IE +ReLU(X IE ·W1+b1)·W1+b2)
[0048] In the formula, W1∈i d×k It is the second linear transformation matrix spanning all time intervals, and is a d-row, k-column matrix; b1∈i k Indicates the second bias; b2∈i k Indicates the third bias;
[0049] X FF Generate three input matrices K, V, Q for the attention module, where K ∈ i T×k ,V∈i T×k ,Q∈i T×k Each of the three input matrices K, V, and Q is a T-row, k-column matrix. Then, a softmax activation function is applied to the three input matrices K, V, and Q to obtain the connection matrix C of the attention module, where C ∈ i. T×k Let be a T-row, k-column matrix. The formula for calculating the connection matrix C of the attention module is:
[0050]
[0051] In the formula, h represents the number of multi-head attention heads used; in this embodiment, eight attention heads are used. After normalizing the connection matrix C of the attention module, the ReLU activation function is applied to output the predicted value of the fully connected layer. This refers to the predicted environmental data for the next time period, and then based on the predicted environmental data for the next time period... Calculate the loss function value MSE using the actual environmental data y for the corresponding time period; the formula for calculating the loss function value is:
[0052]
[0053] Where N is the number of samples, and y is the true value. This is a predicted value;
[0054] The system determines whether the loss function value has reached a preset value. In this embodiment, the preset loss function value is 0.01. If the loss function value is greater than the preset value, the parameters of the position encoding matrix P and the linear transformation matrix W are adjusted. If the loss function value is less than or equal to the preset value, the trained Transformer prediction model is obtained. The test set data is input into the trained Transformer prediction model, and the prediction performance of the trained Transformer prediction model is evaluated.
[0055] S4. The MCU control module controls the irrigation operation of the water supply unit and the ventilation operation of the ventilation unit according to the received predicted environmental data for the next time period and the environmental data for the corresponding time period collected by the environmental information acquisition module 2, based on the intelligent control strategy.
[0056] The intelligent control strategy includes a water supply control strategy and a ventilation control strategy. Specifically, the water supply control strategy works as follows: within each data transmission cycle of the cloud server, when the predicted humidity for the next time period is less than the preset humidity value of 15RH, and the humidity collected by the temperature and humidity sensor for the corresponding time period is also less than the preset humidity value of 15RH, the MCU control module controls the water supply unit to start every 15 minutes for 5 minutes each time. When the predicted humidity for the next time period is less than the preset humidity value of 15RH, but the humidity collected by the temperature and humidity sensor for the corresponding time period is greater than the preset humidity value of 15RH, the MCU control module controls the water supply unit to start every 15 minutes for 2 minutes each time. When both the predicted humidity for the next time period and the humidity collected by the temperature and humidity sensor for the corresponding time period are greater than the preset humidity value of 15RH, the MCU control module does not start the water supply unit. Ventilation control strategy: Within each data transmission cycle of the cloud server, when the CO2 concentration predicted by the cloud server for the next time period is greater than or less than 2000 ppm, and the CO2 concentration collected by the CO2 sensor for the corresponding time period is greater than the preset CO2 concentration value of 2000 ppm, the MCU control module controls the ventilation unit to start the first ventilation mode, continuously ventilating until the CO2 concentration collected by the CO2 sensor is less than the preset CO2 concentration value of 2000 ppm, at which point the MCU control module controls the ventilation unit to stop. When the predicted CO2 concentration for the next time period is greater than the preset CO2 concentration value of 2000 ppm, and the CO2 concentration collected by the CO2 sensor for the corresponding time period is less than the preset CO2 concentration value of 2000 ppm, the second ventilation mode is started. The MCU control module controls the ventilation unit to start once every 5 minutes, for 1 minute each time, until the predicted CO2 concentration is less than the preset CO2 concentration value of 2000 ppm. When both the predicted CO2 concentration for the next time period and the CO2 concentration collected by the CO2 sensor for the corresponding time period are less than the preset CO2 concentration value of 2000 ppm, the MCU control module does not start the ventilation unit.
[0057] The environmental data predicted by the cloud server and the environmental data collected by the environmental information collection module at the corresponding time in this embodiment are shown in Table 1.
[0058] Table 1 shows the environmental data predicted by the cloud server and the environmental data collected by the environmental information collection module at the corresponding time in this embodiment.
[0059]
[0060] According to the environmental data in Table 1, at 13:56:11, the humidity value collected by the temperature and humidity sensor and the humidity value predicted by the cloud server are both greater than 15RH, so the MCU control module did not start the DC motor water pump; the CO2 concentration collected by the CO2 sensor and the CO2 concentration predicted by the cloud server are both less than 2000ppm, so the MCU control module did not start the DC motor fan.
[0061] At 14:56:34, the humidity value collected by the temperature and humidity sensor and the humidity value predicted by the cloud server are both greater than 15RH, so the MCU control module does not start the DC motor water pump; the CO2 concentration collected by the CO2 sensor and the CO2 concentration predicted by the cloud server are both less than 2000ppm, so the MCU control module does not start the DC motor fan.
[0062] At 17:56:24, the humidity value collected by the temperature and humidity sensor is greater than 15RH, but the cloud server predicts that the humidity value is less than 15RH. The MCU control module controls the DC motor water pump to start once every 15 minutes, for 2 minutes each time. The CO2 concentration collected by the CO2 sensor is greater than 2000ppm, while the CO2 concentration predicted by the cloud server is less than 2000ppm. The MCU control module controls the DC motor fan to start the first ventilation mode and continues ventilation until the CO2 concentration collected by the CO2 sensor is less than the preset CO2 concentration value of 2000ppm.
[0063] At 18:56:50, after one hour of water supply, the humidity value collected by the temperature and humidity sensor and the humidity value predicted by the cloud server were both greater than 15RH. The MCU control module controlled the DC motor water pump to stop water supply. The CO2 concentration collected by the CO2 sensor was less than 2000ppm, but the CO2 concentration predicted by the cloud server was still greater than 2000ppm. The MCU control module controlled the DC motor fan to start the second ventilation mode. The DC motor fan started once every 5 minutes for 1 minute each time until the predicted CO2 concentration was less than the preset CO2 concentration value of 2000ppm.
[0064] This embodiment uses the Transformer prediction model to predict environmental data for the next time period. The predicted data does not rely on weather station monitoring and can be adjusted according to the actual situation. In addition, it combines the environmental information acquisition module to collect environmental data for the corresponding time period, realizing high-precision monitoring and high-accuracy prediction of environmental data. Irrigation is carried out based on the predicted environmental data, the collected environmental data and intelligent control strategies, thus saving water resources.
Claims
1. An Internet of Things (IoT) environmental prediction and monitoring system, characterized in that, It includes an environmental data acquisition and control terminal and a cloud server. The environmental data acquisition and control terminal includes an environmental information acquisition module, an MCU control module, an execution module, a communication module, and a power supply module. The MCU control module stores the intelligent control strategy of the execution module. The execution module includes a water supply unit. The output of the environmental information acquisition module is connected to the input of the MCU control module. The output of the MCU control module is connected to the input of the water supply unit. The MCU control module communicates with the cloud server through the communication module. The power supply module supplies power to the environmental information acquisition module, the MCU control module, and the execution module. The cloud server internally stores a Transformer prediction model, which includes an encoder module, an attention module, and an output fully connected module. Environmental data from the cloud server is input to the encoder module, and the encoder module's output is input to the attention module. The attention module extracts correlation information between environmental data within a continuous time period, and its output is input to the output fully connected module, which then outputs the prediction result for the environmental data in the next time period. The environmental information acquisition module includes temperature and humidity sensors, light intensity sensors, and CO2 sensors. The outputs of the temperature and humidity sensors, light intensity sensors, and CO2 sensors are all connected to the input of the MCU control module. The execution module also includes a ventilation unit, whose input is connected to the MCU... The output of the U control module is connected; the water supply unit uses a DC motor water pump, and the ventilation unit uses a DC motor fan; the intelligent control strategy includes a water supply control strategy and a ventilation control strategy. The water supply control strategy is as follows: within each data transmission cycle of the cloud server, the predicted humidity for the next time period is compared with the preset humidity value, and the humidity for the corresponding time period collected by the temperature and humidity sensor is compared with the preset humidity value. The MCU control module controls the start frequency of the water supply unit and the duration of each start based on the comparison results. The ventilation control strategy is as follows: within each data transmission cycle of the cloud server, the predicted CO2 concentration for the next time period is compared with the preset CO2 concentration value, and the CO2 concentration collected by the CO2 sensor is compared with the preset CO2 concentration value. The MCU control module controls the start frequency of the ventilation unit and the duration of each start based on the comparison results.
2. The Internet of Things (IoT) environment prediction and monitoring system according to claim 1, characterized in that, The environmental data acquisition and control terminal also includes a display module, the input of which is connected to the output of the MCU control module.
3. The Internet of Things (IoT) environment prediction and monitoring system according to claim 1, characterized in that, The IoT environment prediction and monitoring system also includes a mobile app and a remote monitoring host, both of which are connected to a cloud server.
4. The Internet of Things (IoT) environment prediction and monitoring system according to claim 1, characterized in that, The MCU control module is an STM32F103C8T6 microcontroller, and the communication module is an IoT module.
5. A prediction and monitoring method for the Internet of Things (IoT) environment prediction and monitoring system according to any one of claims 1-4, characterized in that, Includes the following steps: S1. The environmental information acquisition module in the environmental data acquisition and control terminal collects environmental data in the plantation or greenhouse and sends it to the MCU control module; the environmental data includes temperature and humidity collected by the temperature and humidity sensor, illuminance collected by the illuminance sensor, and CO2 concentration collected by the CO2 sensor. S2, the MCU control module sends the received environmental data to the cloud server periodically through the communication module; the MCU control module sends the received environmental data to the display module to display the environmental data in real time; S3. The cloud server stores the received environmental data and inputs it into the encoder module of the trained Transformer prediction model. The output of the encoder module is input into the attention module. The attention module extracts the correlation information between environmental data in continuous time periods. The output of the attention module is input into the output fully connected module. The output fully connected module outputs the prediction result of the environmental data for the next time period. The cloud server periodically sends the predicted environmental data for the next time period back to the MCU control module. The cloud server sends the received environmental data and the predicted environmental data for the next time period to the mobile app and the remote monitoring host. Users can view the environmental data received by the cloud server and the predicted environmental data for the next time period through the mobile app and the remote monitoring host. S4. The MCU control module controls the irrigation operation of the water supply unit and the ventilation operation of the ventilation unit based on the environmental data predicted for the next time period from the cloud server and the environmental data collected by the environmental information acquisition module for the corresponding time period, according to the intelligent control strategy. The intelligent control strategy includes a water supply control strategy and a ventilation control strategy. The water supply control strategy is as follows: in each feedback cycle of the cloud server, the predicted humidity for the next time period is compared with the preset humidity value, and the humidity collected by the temperature and humidity sensor for the corresponding time period is compared with the preset humidity value. Based on the comparison results, the MCU control module controls the start frequency of the water supply unit and the duration of each start. The ventilation control strategy is as follows: in each feedback cycle of the cloud server, the predicted CO2 concentration for the next time period is compared with the preset CO2 concentration value, and the CO2 concentration collected by the CO2 sensor is compared with the preset CO2 concentration value. Based on the comparison results, the MCU control module controls the start frequency of the ventilation unit and the duration of each start.
6. The prediction and monitoring method according to claim 5, characterized in that, The training process of the Transformer prediction model is as follows: The cloud server acquires environmental data uploaded by the environmental data acquisition and control terminal, packages the environmental data into datasets according to time periods, and divides them into training and test sets; the training set data is input into the encoder module, which performs linear transformation and position encoding on the training set data. The combined output calculation formula for the linear transformation and position encoding is as follows: In the above formula, The input training set data is a T-row, d-column matrix; It is the combined output of linear transformation and positional encoding. , is a T-row, k-column matrix; It is the first linear transformation matrix that spans all time intervals, and is a d-row, k-column matrix; Indicates the first bias; It is a positional encoding matrix, which is a T-row, k-column matrix; P and W0 are initialized with random values. The combined output of linear transformation and positional encoding is fully connected and normalized before being input into the attention module. The fully connected and normalized output X is then fed into the attention module. FF for: In the formula, It is the second linear transformation matrix that spans all time intervals, and is a d-row, k-column matrix; Indicates the second bias; Indicates the third bias; X FF The three input matrices K, V, and Q of the attention module are generated, where , , Each of the three input matrices K, V, and Q is a T-row, k-column matrix. Then, a softmax activation function is applied to these three input matrices to obtain the connection matrix C of the attention module. Let be a T-row, k-column matrix. The formula for calculating the connection matrix C of the attention module is: in the formula To utilize the number of multi-head attention, this embodiment uses 8 attention heads; after normalizing the connection matrix C of the attention module, the predicted value of the fully connected layer is output through the ReLU activation function. This refers to predicting the environmental data of the training set data in the next time period, and then using the predicted environmental data for the next time period... Calculate the loss function value using the actual environmental data y for the corresponding time period. The formula for calculating the loss function value is: Where N is the number of samples, and y is the true value. This is a predicted value; Determine whether the loss function value has reached the preset value. If the loss function value is greater than the preset value, adjust the parameters of the position encoding matrix P and the linear transformation matrix W. If the loss function value is less than or equal to the preset value, obtain the trained Transformer prediction model. Input the test set data into the trained Transformer prediction model and evaluate the prediction performance of the trained Transformer prediction model.
Citation Information
Patent Citations
Environmental monitoring method based on Transform time sequence prediction
CN114580710A
Intelligent agricultural production management service system
CN115442405A