Pesticide pollution treatment control method based on Internet of Things
By dynamically adjusting the process parameters of the agricultural wastewater treatment system using IoT sensors and intelligent algorithms, the problem of the system's inability to adjust in a timely manner has been solved, improving treatment efficiency and effectiveness and ensuring that the effluent quality meets standards.
Patent Information
- Application Number
- CN202511679444.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-07-01
- Publication Date
- 2026-02-24
AI Technical Summary
Existing agricultural wastewater treatment systems cannot adjust process parameters in a timely manner, resulting in reduced treatment efficiency and effectiveness, especially when rural wastewater discharge is irregular and subject to large instantaneous changes.
Wastewater quality data is collected by IoT sensors, pre-processed and analyzed over time. Long short-term memory neural network models are used to predict water quality changes. A multi-objective optimization model is constructed and solved using particle swarm optimization algorithm. Process parameters such as aeration rate, reagent dosage and sludge return ratio are dynamically adjusted.
It enables real-time dynamic adjustment of the agricultural wastewater treatment system, improving treatment efficiency and effectiveness, ensuring that the effluent quality meets standards, and reducing chemical waste.
Smart Images

Figure CN121559862A_ABST
Abstract
Description
[0001] This application is a divisional application of a patent application entitled "A Method and System for Agricultural Waste Treatment and Control Based on the Internet of Things", the original application was filed on July 1, 2025, and the application number is 202510897656.6. Technical Field
[0002] This invention relates to the field of agricultural wastewater treatment technology, and more specifically to an agricultural wastewater treatment control method based on the Internet of Things. Background Technology
[0003] In existing technologies, one method for controlling agricultural wastewater treatment involves deploying sensors and smart devices in wastewater treatment facilities to monitor key parameters such as influent water quality, aeration requirements, and equipment operating status in real time. The system automatically adjusts operations such as aeration rate, chemical dosage, and recirculation treatment according to a preset control strategy to ensure optimal wastewater treatment results. However, rural wastewater discharge is irregular and fluctuates rapidly, making it difficult for a single preset control strategy to accurately adapt to these changes. This results in the inability to adjust key process parameters such as aeration rate and chemical dosage in a timely manner, leading to reduced efficiency in agricultural wastewater treatment.
[0004] In summary, the inability to adjust process parameters in a timely manner during the existing agricultural wastewater treatment process leads to a decrease in the effectiveness and efficiency of agricultural wastewater treatment. Summary of the Invention
[0005] This invention provides an IoT-based control method for agricultural wastewater treatment, which enables the adjustment of treatment process parameters and improves the efficiency and effectiveness of agricultural wastewater treatment.
[0006] An IoT-based method for controlling agricultural wastewater treatment, the method comprising: Data acquisition involves collecting wastewater quality data from the wastewater treatment system at different time periods using IoT sensors. The data collected by the IoT sensors is then transmitted to the wastewater treatment monitoring platform via an IoT gateway. The wastewater quality data is preprocessed to obtain standard wastewater quality data. Time series data of water quality indicators are extracted from the standard wastewater quality data and smoothed using time series analysis methods to obtain smoothed time series data. The water quality indicators include chemical oxygen demand (COD), ammonia nitrogen, total phosphorus (TP), and total nitrogen (TN). Effluent water quality data is continuously collected using an online analyzer with a sampling period of 30 minutes. When the TN deviation exceeds a threshold, data is collected three times consecutively within 10 minutes for verification. The exponential smoothing coefficient for the time series analysis is selected based on the variation characteristics of different water quality indicators; a smoothing coefficient of 0.2 is used for TN to better reflect long-term trends. Based on the smoothed time series data, a trained long short-term memory neural network model is used to obtain predicted data for future time series of water quality indicators. In the prediction of ammonia nitrogen, the input layer of the long short-term memory neural network model adds temperature data as an auxiliary feature in addition to historical concentration data. A longer time step is used for the prediction of total phosphorus and total nitrogen. Based on the predicted data, pollutant emission concentration limits and sludge concentration limits are set as constraints, and an objective function for the optimization problem is constructed, thereby establishing a multi-objective optimization model. The multi-objective optimization model is solved using the particle swarm optimization algorithm to obtain the optimal combination of process parameters, including aeration rate, reagent dosage, and sludge return ratio. The optimal combination is converted into control commands and sent to the execution equipment of the wastewater treatment system to control the operating status of the execution equipment. The step of converting the optimal combination into control commands and sending them to the execution equipment of the wastewater treatment system to control the operating status of the execution equipment includes: The preset instruction conversion function is called to convert the optimal combination data into control instructions; the instruction conversion function converts the optimized parameters into equipment control instructions, wherein the operating frequency of the aerator is determined by the ratio of the actual required air volume to the rated air volume, and is expressed as a percentage; Based on the control command, determine the adjustment values of the operating parameters of the aerator, dosing pump, and sludge return pump; A real-time data acquisition module is used to obtain the current operating status data of the execution device; Compare the adjusted operating parameters with the current operating status data to determine if there is a deviation. If there is a deviation, the equipment control module will be invoked to issue adjustment commands to the aerator, dosing pump, and sludge return pump. After converting the optimal combination into control commands and issuing them to the execution equipment of the wastewater treatment system to control the operating status of the execution equipment, the method further includes: The actual concentrations of chemical oxygen demand, ammonia nitrogen, total phosphorus, and total nitrogen in the effluent from the wastewater treatment system are obtained using a real-time monitoring module. Call the preset model calculation module to obtain the predicted concentration values of chemical oxygen demand, ammonia nitrogen, total phosphorus, and total nitrogen; Calculate the deviation values of chemical oxygen demand, ammonia nitrogen, total phosphorus, and total nitrogen based on the actual concentration values and the predicted concentration values; Determine whether the deviation values of chemical oxygen demand, ammonia nitrogen, total phosphorus, and total nitrogen exceed the preset deviation threshold; If the deviation value exceeds the preset deviation threshold, the concentration values of chemical oxygen demand, ammonia nitrogen, total phosphorus, and total nitrogen will be collected again. Based on the newly collected water quality data, the optimal combination of process parameters is recalculated, and the control commands are updated until the deviation does not exceed the preset deviation threshold when executing the control commands. The commands are executed using a gradient adjustment method: when it is necessary to increase the operating frequency of the aerator, it is adjusted in five steps, each time increasing by 2%, with a three-minute interval between adjacent adjustments. In the control of the dosing system, each increase does not exceed 5% of the current value.
[0007] Preferably, the preprocessing of the wastewater quality data to obtain standard wastewater quality data includes: The wastewater quality data is subjected to wavelet decomposition to obtain high-frequency components, and it is determined whether the high-frequency components exceed a preset high-frequency threshold. When the high-frequency component exceeds the preset high-frequency threshold, filtering is performed to obtain denoised water quality data. The missing data points before and after the missing values in the denoised water quality data are obtained, and the missing data points are filled in using a linear interpolation method based on the numerical change trend of the missing data points to obtain complete wastewater quality data. The isolated forest algorithm is used to detect the complete wastewater quality data, obtain anomaly scores, and determine whether the anomaly scores exceed a preset anomaly score threshold. When the abnormal score exceeds the preset abnormal score threshold, correction processing is performed to obtain standard wastewater quality data.
[0008] Preferably, the time series data of water quality indicators extracted from the standard wastewater quality data are smoothed using time series analysis methods to obtain smoothed time series data. The water quality indicators include chemical oxygen demand (COD), ammonia nitrogen, total phosphorus, and total nitrogen, comprising: Time series data of water quality indicators are extracted from the standard wastewater water quality data, and the time series data are smoothed by exponential smoothing method to obtain smoothed time series data.
[0009] Preferably, the step of obtaining predicted data for future time series of water quality indicators based on smoothed time series data using a trained long short-term memory neural network model includes: Construct a long short-term memory neural network model, set the time step and the number of neurons, initialize the model parameters, and determine the network structure; Historical wastewater quality data was acquired and divided into training and testing sets. The long short-term memory neural network model is trained using the training set data to obtain the trained prediction model; The trained prediction model is validated using the test set data. If the prediction error exceeds the preset error threshold, the model parameters are adjusted and the model is retrained until the prediction error meets the requirements. Based on the trained prediction model, smoothed time series data are input to obtain predicted data for future time series of water quality indicators.
[0010] Preferably, the step of setting pollutant emission concentration limits and sludge concentration limits as constraints based on the predicted data, constructing an objective function for the optimization problem, and thus establishing a multi-objective optimization model includes: Based on the predicted data, pollutant emission concentration limits and sludge concentration limits are set as constraints. Based on the constraints, an objective function is constructed, with pollutant emission concentration and sludge concentration as the optimization objectives. The objective function is solved using a multi-objective optimization algorithm to obtain the optimal combination of pollutant emission concentration and sludge concentration. If the optimal combination satisfies the preset constraints, then the objective function at this time is used to establish a multi-objective optimization model; If the optimal combination does not meet the preset constraints, the constraints are adjusted and the solution is recalculated until the optimal combination meets the preset constraints.
[0011] Preferably, the multi-objective optimization model is solved using a particle swarm optimization algorithm to obtain the optimal combination of process parameters; wherein, the process parameters include aeration rate, reagent dosage, and sludge return ratio, including: The particle swarm optimization algorithm is used to pre-establish the particle encoding method, determine the initial range of particle position and velocity, and generate the initial particle swarm. Among them, particle coding combines the aeration rate, reagent dosage and sludge return ratio to be optimized to represent the position of the particle, while the particle velocity represents the direction and magnitude of parameter changes. Based on the objective function and constraints, the fitness value of each particle is calculated, and the particle position is determined based on the fitness value to see if it meets the preset optimization objective. The constraints include: chemical oxygen demand not exceeding 50 mg / L, ammonia nitrogen not exceeding 5 mg / L, total phosphorus not exceeding 0.5 mg / L, and the concentration of suspended solids in the mixed solution controlled between 3,000 and 5,000 mg / L. If the particle position satisfies the preset optimization objective, the current optimal solution is recorded; if the particle position does not satisfy the preset optimization objective, the particle velocity and position are updated, and the fitness value is recalculated until the preset optimization objective is satisfied. By iteratively updating the particle swarm, the optimal combination of process parameters is obtained, and it is determined whether the requirements of the multi-objective optimization model are met. If the optimal combination satisfies the requirements of the multi-objective optimization model, the optimal solution is output; if the optimal combination does not satisfy the requirements of the multi-objective optimization model, the particle swarm initialization strategy is adjusted, and the optimization calculation is repeated until the requirements are met.
[0012] Preferably, the particle swarm optimization uses real number encoding, the upper limit of particle velocity is set to 20% of the corresponding variable range, and an inertial weight is introduced that decreases with the number of iterations to balance global and local search capabilities.
[0013] Preferably, after converting the optimal combination into control commands and issuing them to the execution devices of the wastewater treatment system to control the operating status of the execution devices, the method further includes: The actual concentrations of chemical oxygen demand, ammonia nitrogen, total phosphorus, and total nitrogen in the effluent from the wastewater treatment system are obtained using a real-time monitoring module. Call the preset model calculation module to obtain the predicted concentration values of chemical oxygen demand, ammonia nitrogen, total phosphorus, and total nitrogen; Calculate the deviation values of chemical oxygen demand, ammonia nitrogen, total phosphorus, and total nitrogen based on the actual concentration values and the predicted concentration values; Determine whether the deviation values of chemical oxygen demand, ammonia nitrogen, total phosphorus, and total nitrogen exceed the preset deviation threshold; If the deviation value exceeds the preset deviation threshold, the concentration values of chemical oxygen demand, ammonia nitrogen, total phosphorus, and total nitrogen will be collected again. Based on the newly collected water quality data, the optimal combination of process parameters is re-solved, and the control commands are updated until the deviation does not exceed the preset deviation threshold when the control commands are executed. When a decrease in total nitrogen removal efficiency is detected, first increase the internal reflux ratio, while fine-tuning the aeration rate, and update the control commands in a gradual manner until the deviation falls back to the threshold range.
[0014] Preferably, the initial value of the decrease is set to 0.9, and the final value is 0.4.
[0015] Preferably, the IoT sensors are deployed at key locations including the water inlet, the biological treatment tank, and the effluent from the secondary sedimentation tank. Compared with the prior art, the present invention has the following beneficial effects: (1) The present invention collects wastewater quality data through IoT sensors and preprocesses it to ensure the accuracy of subsequent analysis and prediction.
[0016] (2) The present invention smooths time series data through time series analysis and uses a long short-term memory neural network model to predict future water quality changes based on the smoothed time series data. This helps to adjust the treatment process parameters in advance to cope with changes in water quality.
[0017] (3) Based on the water quality index prediction results, the present invention establishes a multi-objective optimization model and uses the particle swarm optimization algorithm to solve it, which helps to find the optimal treatment process parameters and improve treatment efficiency.
[0018] (4) While the equipment is running according to the optimized process parameters, the present invention also monitors the wastewater quality data in real time, thereby making real-time dynamic adjustments to the treatment process parameters, which improves the efficiency and effect of agricultural wastewater treatment.
[0019] In summary, this invention can adjust the treatment process parameters based on water quality index data, thereby updating the optimal control instructions and improving the efficiency and effectiveness of agricultural wastewater treatment. Attached Figure Description
[0020] Figure 1 This is a flowchart of an IoT-based agricultural wastewater treatment and control method according to the present invention.
[0021] Figure 2 This is a schematic diagram of the structure of an agricultural wastewater treatment control system based on the Internet of Things according to the present invention. Detailed Implementation
[0022] The technical solution of the present invention will be clearly and completely described below with reference to the embodiments. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without creative effort are within the scope of protection of the present invention.
[0023] Reference Figure 1 This embodiment presents an IoT-based method for controlling agricultural wastewater treatment, comprising the following steps: S1, acquire wastewater quality data for different time periods; S2, preprocess the wastewater quality data to obtain standard wastewater quality data; S3, extract time series data of water quality indicators from the standard wastewater water quality data, and smooth them using time series analysis methods to obtain smoothed time series data; wherein, the water quality indicators include chemical oxygen demand, ammonia nitrogen, total phosphorus, and total nitrogen; S4. Based on the smoothed time series data, the predicted data of future time series of water quality indicators are obtained through a trained long short-term memory neural network model. S5. Based on the predicted data, pollutant emission concentration limits and sludge concentration limits are set as constraints, and an objective function for the optimization problem is constructed to establish a multi-objective optimization model. S6. The multi-objective optimization model is solved using the particle swarm optimization algorithm to obtain the optimal combination of process parameters; wherein, the process parameters include aeration rate, reagent dosage and sludge return ratio; S7, the optimal combination is converted into control commands and sent to the execution equipment of the sewage treatment system to control the operating status of the execution equipment.
[0024] In step S1, wastewater quality data for different time periods are obtained.
[0025] Among them, wastewater quality data of the wastewater treatment system at different time periods are collected through IoT sensors. The wastewater quality data reflects the characteristics of pollutant content, physical properties, and chemical properties in the wastewater. Common physical property indicators include temperature and turbidity, while common chemical property indicators include chemical oxygen demand, ammonia nitrogen, total phosphorus, and total nitrogen.
[0026] For example, wastewater treatment system water quality data monitoring achieves intelligent data acquisition through IoT sensors. The chemical oxygen demand (COD) sensor uses an optical measurement principle, determining the organic matter content in water through the absorption of light at a specific wavelength, enabling real-time monitoring of changes in organic matter concentration in wastewater. The ammonia nitrogen sensor uses an ion-selective electrode method, detecting the concentration by measuring the potential difference generated by ammonia nitrogen ions. In the denitrification process, by controlling the aeration rate and reflux ratio, the influent ammonia nitrogen is reduced from 30 mg / L to below 5 mg / L. The sensor can adjust process parameters promptly based on water quality changes to ensure effective denitrification. Total phosphorus monitoring uses a colorimetric principle, utilizing the phosphomolybdic blue colorimetric reaction for online detection. In the phosphorus removal process, phosphorus removal agents are added to reduce total phosphorus from 4 mg / L to 0.5 mg / L. Sensor data guides the dosage of these agents, ensuring effluent meets standards while avoiding overdosing. The total nitrogen sensor uses ultraviolet spectrophotometry to monitor the denitrification effect in real time. By adjusting the operating times of the anaerobic, anoxic, and aerobic stages, total nitrogen was reduced from 40 mg / L to 15 mg / L. Sensor data reflects the denitrification effect, allowing for timely adjustments to process operating parameters. The data collected by these sensors is transmitted to a wastewater treatment monitoring platform via an IoT gateway, enabling real-time monitoring and remote control. The platform can automatically adjust process parameters, such as aeration rate, reflux ratio, and reagent dosage, based on water quality trends. Sensors are deployed at key nodes including the inlet, biological treatment tank, and secondary sedimentation tank effluent, forming a complete data monitoring network. By comparing the influent and effluent indicators of different process units, treatment effectiveness can be evaluated and operational plans optimized. The system can also analyze historical data, summarize water quality change patterns, and provide a basis for process improvement. This intelligent monitoring system significantly improves the automation level and operational efficiency of wastewater treatment.
[0027] In step S2, the wastewater quality data is preprocessed to obtain standard wastewater quality data, including: The wastewater quality data is subjected to wavelet decomposition to obtain high-frequency components, and it is determined whether the high-frequency components exceed a preset high-frequency threshold. When the high-frequency component exceeds the preset high-frequency threshold, filtering is performed to obtain denoised water quality data. The missing data points before and after the missing values in the denoised water quality data are obtained, and the missing data points are filled in using a linear interpolation method based on the numerical change trend of the missing data points to obtain complete wastewater quality data. The isolated forest algorithm is used to detect the complete wastewater quality data, obtain anomaly scores, and determine whether the anomaly scores exceed a preset anomaly score threshold. When the abnormal score exceeds the preset abnormal score threshold, correction processing is performed to obtain standard wastewater quality data.
[0028] Wavelet decomposition is a time-frequency analysis method that decomposes wastewater quality data into sub-signals of different frequencies. First, wavelet decomposition is applied to the collected wastewater quality data to separate it into different frequency components, including low-frequency and high-frequency components. Low-frequency components typically contain the main trends in the data, while high-frequency components contain rapidly changing parts caused by noise. Next, a high-frequency threshold is set to distinguish between normal fluctuations and noise. If the analysis results show that the intensity of high-frequency components exceeds this preset threshold, these high-frequency components are considered to be primarily noise. Finally, these high-frequency components exceeding the threshold are filtered, for example, by setting a threshold to zero for high-frequency coefficients exceeding the threshold, or by applying other filtering techniques to weaken the influence of these components.
[0029] In practical applications, when performing wavelet decomposition on chemical oxygen demand (COD) data for wastewater, a high-frequency threshold of 5 mg / L can be set. When the high-frequency component exceeds this threshold, abnormal fluctuations are removed through filtering. For example, if the COD concentration is 200 mg / L over a certain period, wavelet decomposition yields a high-frequency component of 10 mg / L, which exceeds the high-frequency component threshold. This high-frequency component exceeding the threshold will be set to zero or weakened, thus smoothing the data.
[0030] Linear interpolation is a practical method for repairing missing data. First, the locations of missing values in the wastewater quality data are identified, and then data points before and after these missing values are obtained. By analyzing the values of these before and after data points, the trend of data change is determined. Next, the linear interpolation method is applied. This method assumes that the data changes linearly between two known points, thus calculating the value that should exist at the location of the missing value. Using linear interpolation, the missing data is filled in, making the data curve smoother and more continuous. The formula for linear interpolation is as follows: In the formula, This represents the interpolation result at time t. and Let t1 and t2 represent the values of two known data points before and after the missing data, respectively, and t1 and t2 represent the corresponding times. For example, suppose there is a set of wastewater chemical oxygen demand (COD) data arranged in chronological order, where data for a certain time point is missing. The known data points are as follows: at time point t1 = 1 hour, the COD value is 120 mg / L; at time point t3 = 3 hours, the COD value is 160 mg / L. Using linear interpolation, we can calculate that at t2 = 2 hours, the COD value is 140 mg / L. The Isolation Forest algorithm identifies outliers by calculating the degree of anomaly of the data points. When processing wastewater quality data, the Isolation Forest algorithm is used to detect outliers. First, an anomaly score is obtained for each data item. The anomaly score is determined by calculating the average path length of the data point across all trees. In an Isolation Forest, the construction process of each tree can be viewed as gradually separating data points through random partitioning in a multi-dimensional space. The path length h(x) refers to the number of partitions required to isolate data point x from the root node.
[0031] The formula for calculating the anomaly score is as follows: In the formula, Indicates abnormal scores. This represents the average path length of data point x. This represents the average path length correction factor when the data size is n.
[0032] It should be noted that a score closer to 1 indicates a higher likelihood of an outlier, while a score closer to 0 indicates a higher likelihood of a normal point. The Isolation Forest algorithm identifies outliers in the data by constructing isolation trees through randomly selected features and split values. Next, it determines whether these outlier scores exceed a preset outlier score threshold. When the outlier score exceeds the preset threshold, it indicates that these data items may be outliers; for example, the preset outlier score threshold can be set to 0.8. At this point, correction processing is performed, such as replacing these outliers with the mean, median, or model-based methods, to obtain standard wastewater quality data. When the outlier score does not exceed the preset outlier score threshold, it indicates that these data items are normal, and they are directly output as standard water quality data. This process helps improve the overall quality and reliability of the dataset, providing a more accurate foundation for subsequent data analysis and model building.
[0033] In step S3, time series data of water quality indicators are extracted from the standard wastewater quality data, and smoothed using time series analysis methods to obtain smoothed time series data; wherein, the water quality indicators include chemical oxygen demand, ammonia nitrogen, total phosphorus, and total nitrogen, including: Time series data of water quality indicators are extracted from the standard wastewater water quality data, and the time series data are smoothed by exponential smoothing method to obtain smoothed time series data.
[0034] It should be noted that exponential smoothing is a commonly used time series data processing technique that smooths data fluctuations by assigning different weights to data from different periods. In wastewater treatment, this method can effectively eliminate random fluctuations in water quality index data and highlight long-term trends.
[0035] Taking chemical oxygen demand (COD) as an example, when extracting time series data from pretreated wastewater quality data, the first step is to determine an appropriate time interval. In practical applications, sampling can be done hourly to construct continuous time series data. The extracted data includes specific COD values at different time points, reflecting the changes in organic matter content during wastewater treatment. The smoothing coefficient needs to be adjusted based on the specific circumstances. A larger smoothing coefficient will make the smoothed result closer to the actual observed value, while a smaller smoothing coefficient will produce a smoother trend line. For example, when processing COD data, a smoothing coefficient of 0.3 can better balance the sensitivity and stability of the data. The original data shows that COD fluctuates between 200 and 400 mg / L within a day; after exponential smoothing, the overall trend is more clearly displayed.
[0036] The processing of ammonia nitrogen levels is another typical example. During the processing, the raw data may fluctuate due to equipment errors or environmental factors. By extracting data from different time points to form a time series, applying exponential smoothing can effectively reduce the impact of these fluctuations. When the smoothing coefficient is set to 0.4, the important characteristics of the data are preserved while eliminating short-term fluctuations. The processed data more clearly reflects the changing patterns of ammonia nitrogen concentration, facilitating timely adjustments to process parameters.
[0037] The treatment of total phosphorus demonstrates the value of exponential smoothing at different time scales. Considering that the total phosphorus concentration changes relatively slowly, a smaller smoothing coefficient, such as 0.2, can be used to better reflect long-term trends.
[0038] In step S4, based on the smoothed time series data, a trained long short-term memory neural network model is used to obtain predicted data for future time series of water quality indicators, including: Construct a long short-term memory neural network model, set the time step and the number of neurons, initialize the model parameters, and determine the network structure; Historical wastewater quality data was acquired and divided into training and testing sets. The long short-term memory neural network model is trained using the training set data to obtain the trained prediction model; The trained prediction model is validated using the test set data. If the prediction error exceeds the preset error threshold, the model parameters are adjusted and the model is retrained until the prediction error meets the requirements. Based on the trained prediction model, smoothed time series data are input to obtain predicted data for future time series of water quality indicators.
[0039] It should be noted that the application of Long Short-Term Memory (LSTM) neural network models in water quality prediction first requires a well-structured network. Taking chemical oxygen demand (COD) prediction as an example, the model can be configured with a three-layer network structure: the input layer receives historical data from the previous seven days, the hidden layer contains 64 neurons, and the output layer predicts the values for the next three days. Considering the periodic changes in wastewater quality, a time step of one day is appropriate. Regarding data partitioning, two years of water quality monitoring data can be divided into training and testing sets in a 7:3 ratio. Taking actual operational data from a certain agricultural wastewater treatment plant as an example, historical COD data shows a range of variation between 200 and 400 mg / L. To ensure effective model training, the data needs to be normalized. The training set contains 500 consecutive sample points, and the testing set contains 200 sample points. During model training, the initial learning rate is set to 0.01, the batch size is set to 16, and the number of training epochs is 200.
[0040] For example, when the prediction error threshold is set to 10%, the prediction error begins to stabilize below the threshold after approximately 150 training rounds. If the prediction error exceeds the threshold, model performance can be optimized by adjusting the number of neurons or changing the learning rate. The prediction model for ammonia nitrogen follows a similar principle. Considering that ammonia nitrogen concentration is significantly affected by temperature, temperature data can be added as an auxiliary feature to the model's input layer in addition to historical concentration data. It is worth noting that this multi-feature input method can improve the model's prediction accuracy. For example, if ammonia nitrogen concentration fluctuates between 20 and 40 mg / L, the model can capture this variation pattern well after training. Since total phosphorus and total nitrogen change relatively slowly, the prediction model can use a longer time step, such as three days. During the model validation phase, root mean square error and mean absolute error can be used to comprehensively evaluate model performance. When the prediction error is controlled within 8%, the model's prediction results can reflect the changing trends of these two indicators well. Based on the trained model, inputting the most recent water quality data can predict future water quality trends. The prediction results can be presented as a graph, including the predicted values and confidence intervals for each indicator. This visualization method intuitively shows the changing trends of water quality indicators, which helps to detect potential water quality anomalies in a timely manner.
[0041] In step S5, based on the predicted data, pollutant emission concentration limits and sludge concentration limits are set as constraints, and an objective function for the optimization problem is constructed, thereby establishing a multi-objective optimization model, including: Based on the predicted data, pollutant emission concentration limits and sludge concentration limits are set as constraints. Based on the constraints, an objective function is constructed, with pollutant emission concentration and sludge concentration as the optimization objectives. The objective function is solved using a multi-objective optimization algorithm to obtain the optimal combination of pollutant emission concentration and sludge concentration. If the optimal combination satisfies the preset constraints, then the objective function at this time is used to establish a multi-objective optimization model; If the optimal combination does not meet the preset constraints, the constraints are adjusted and the solution is recalculated until the optimal combination meets the preset constraints.
[0042] Multi-objective optimization of wastewater treatment systems requires the reasonable setting of constraints and objective functions. For major pollutants such as chemical oxygen demand (COD), ammonia nitrogen, and total phosphorus (TP), emission limits can be set based on emission standards and actual operating conditions. Typical constraint settings include COD not exceeding 50 mg / L, ammonia nitrogen not exceeding 5 mg / L, and TP not exceeding 0.5 mg / L. Controlling sludge concentration is crucial for stable system operation; generally, the mixed liquor suspended solids concentration is controlled between 3,000 and 5,000 mg / L. The construction of the objective function needs to consider both pollutant emission concentration and sludge concentration. Taking a specific wastewater treatment requirement as an example, the effluent quality target can be set as minimizing the deviation of the major pollutant concentration from the emission standard, while the sludge concentration target can be set as maintaining it within the optimal process control range. These two objectives are somewhat competitive, as a higher sludge concentration is beneficial for improving treatment efficiency but also increases the sludge disposal burden. In multi-objective optimization problems, a non-dominated sorting genetic algorithm can be used. This algorithm evolves the population through genetic operations such as selection, crossover, and mutation, while introducing crowding calculations to maintain solution diversity and prevent premature convergence to local optima. This algorithm is particularly suitable for handling optimization problems with conflicting objectives, effectively finding a set of balanced solutions. It can quickly search for the optimal solution set while maintaining population diversity.
[0043] Taking actual operation data from a wastewater treatment plant as an example, the initial population was set to 200 individuals, with 500 generations. Through crossover and mutation operations, the algorithm converged to a good solution set after approximately 300 generations. The selection of the optimal combination requires comprehensive consideration of multiple aspects. If the obtained optimal solution satisfies the following conditions: chemical oxygen demand (COD) less than 40 mg / L, ammonia nitrogen less than 4 mg / L, and total phosphorus less than 0.4 mg / L (i.e., meets the pollutant discharge concentration limits), and the sludge concentration is maintained at around 4,000 mg / L, then the solution can be considered feasible. If some indicators exceed the constraints, the constraints need to be appropriately relaxed for re-optimization. For example, the COD limit can be adjusted to 45 mg / L, or the sludge concentration range can be expanded to 3,500 to 4,500 mg / L. In practical applications, the implementation of the optimization results also needs to consider the feasibility of process adjustments. Taking a treatment capacity of 50,000 tons per day as an example, the optimization model suggests increasing the sludge concentration from the original 3,500 mg / L to 4,000 mg / L, while appropriately extending the aeration time. This adjustment scheme ensures that the effluent meets standards while reducing energy consumption. Monitoring revealed that the adjusted operation remained stable, and all indicators were superior to the original scheme. This demonstrates the practical applicability of the multi-objective optimization model.
[0044] In step S6, the multi-objective optimization model is solved using the particle swarm optimization algorithm to obtain the optimal combination of process parameters; wherein, the process parameters include aeration rate, reagent dosage, and sludge return ratio, including: The particle swarm optimization algorithm is used to pre-establish the particle encoding method, determine the initial range of particle position and velocity, and generate the initial particle swarm. Among them, particle coding combines the aeration rate, reagent dosage and sludge return ratio to be optimized to represent the position of the particle, while the particle velocity represents the direction and magnitude of parameter changes. Based on the objective function and constraints, calculate the fitness value of each particle, and determine whether the particle's position satisfies the preset optimization objective based on the fitness value; If the particle position satisfies the preset optimization objective, the current optimal solution is recorded; if the particle position does not satisfy the preset optimization objective, the particle velocity and position are updated, and the fitness value is recalculated until the preset optimization objective is satisfied. By iteratively updating the particle swarm, the optimal combination of process parameters is obtained, and it is determined whether the requirements of the multi-objective optimization model are met. If the optimal combination satisfies the requirements of the multi-objective optimization model, the optimal solution is output; if the optimal combination does not satisfy the requirements of the multi-objective optimization model, the particle swarm initialization strategy is adjusted, and the optimization calculation is repeated until the requirements are met.
[0045] It should be noted that particle encoding uses real-number encoding, treating aeration rate, reagent dosage, and sludge return ratio as variables to be optimized, with each particle representing a potential solution. The application of particle swarm optimization (PSO) in wastewater treatment systems requires scientifically and rationally setting parameters and initial conditions. Taking a specific wastewater treatment scenario as an example, the aeration rate is set between 100 and 300 cubic meters per hour, the reagent dosage between 0.5 and 2 grams per cubic meter, and the sludge return ratio between 30% and 80%. In the initialization of particle position and velocity, to ensure the uniformity of the search space, a random uniform distribution is used to generate the initial particle swarm. For a wastewater treatment system with a capacity of 100,000 tons per day, the initial particle swarm size is set to 50, with a maximum of 200 iterations. The velocity upper limit for each particle is set to 20% of the corresponding variable range, thus maintaining good search capability while ensuring convergence.
[0046] The fitness value calculation needs to consider both pollutant emission concentration and sludge concentration. It is calculated by weighting pollutant emission concentration and sludge / agricultural pollution levels; the weights are used to balance the contribution to the objective function and can be adjusted as needed. Pollutant emission concentration evaluation indicators include chemical oxygen demand (COD), ammonia nitrogen, and total phosphorus concentrations. Based on the obtained fitness value, it is determined whether the particle's position meets the preset optimization objective, i.e., the obtained fitness value is compared with a preset fitness threshold. For example, the fitness threshold can be set to 100. When the obtained fitness value does not exceed the preset fitness threshold, the particle's position is considered to meet the optimization objective. If the particle's position meets the optimization objective, it is recorded as the current optimal solution. If the particle's position does not meet the preset optimization objective, the particle velocity and position are updated, and the fitness value is recalculated until the preset optimization objective is met. During particle position updates, an inertia weight is introduced to balance global and local search capabilities. The inertia weight decreases with each iteration, starting at 0.9 and ending at 0.4. This dynamic adjustment strategy gives the algorithm strong global search capabilities initially, while focusing more on refined local searches later. Through multiple iterations, the algorithm gradually approaches the optimal solution that satisfies the requirements of the multi-objective optimization model; satisfying the multi-objective model requires meeting not only the optimization objective but also the constraints. If the updated solution does not meet the requirements of the multi-objective optimization model, the particle swarm initialization strategy needs to be adjusted (e.g., resetting the initial position range, adjusting weights, etc.), and the optimization calculation needs to be performed again.
[0047] A clear correlation exists between aeration rate and sludge return ratio. A higher sludge return ratio is beneficial for improving biological treatment efficiency, but requires a corresponding increase in aeration rate to maintain sufficient dissolved oxygen levels. It should be noted that the system operates relatively stably when the sludge return ratio is controlled between 50% and 60%. The optimal aeration rate at this point is approximately 200 cubic meters per hour, and the chemical phosphorus removal agent dosage is 1.2 grams per cubic meter. During operation, the optimized system performed well, with all effluent indicators consistently meeting standards. The obtained combination of aeration rate, agent dosage, and sludge return ratio satisfies the requirements of the multi-objective optimization model, indicating that the particle swarm optimization algorithm can effectively solve the multi-objective optimization problem of wastewater treatment systems.
[0048] In step S7, the optimal combination is converted into control commands and sent to the execution equipment of the wastewater treatment system to control the operating status of the execution equipment, including: Call the preset instruction conversion function to convert the optimal combination of data into control instructions; Based on the control command, determine the adjustment values of the operating parameters of the aerator, dosing pump, and sludge return pump; A real-time data acquisition module is used to obtain the current operating status data of the execution device; Compare the adjusted operating parameters with the current operating status data to determine if there is a deviation. If a deviation exists, the equipment control module is invoked to issue adjustment commands to the aerator, dosing pump, and sludge return pump.
[0049] In the wastewater treatment system, the command conversion function transforms the parameters obtained from the optimization algorithm into specific equipment control commands. For example, if the actual required aeration volume is 200 cubic meters per hour, the system needs to convert this into an operating frequency command for the aerator. Assuming the rated aeration volume of the aerator is 500 cubic meters per hour, the corresponding operating frequency should be set to 40%. The operating frequency is determined by the ratio of the actual required air volume to the rated air volume, expressed as a percentage. Similarly, if the chemical phosphorus removal agent dosage is 1.2 grams per cubic meter and the rated flow rate of the dosing pump is 5 liters per hour, the system will calculate the operating frequency of the dosing pump to be 35%. When the sludge return ratio is set to 55%, the system needs to combine this with the current influent flow rate and convert it into the operating frequency of the sludge return pump.
[0050] The establishment of control commands needs to consider the operating characteristics and safety limits of the equipment. Taking an aeration system as an example, when the dissolved oxygen concentration measured by the online dissolved oxygen meter is 2 mg / L, the system will calculate the required adjustment of the aerator's operating frequency based on the preset dissolved oxygen control curve. The chemical dosing system needs to dynamically adjust the dosage according to changes in influent water quality indicators. For example, when the total phosphorus concentration in the influent increases, the system automatically increases the dosage. The equipment control module executes commands using a gradient adjustment method. For instance, when it is necessary to increase the aerator's operating frequency from 40% to 50%, the control system will adjust it gradually in five steps, increasing by 2% each time, with a three-minute interval between each adjustment to avoid drastic system fluctuations. In the chemical dosing system control, if high total phosphorus levels are detected in the effluent, the system will gradually increase the dosage, with each increase not exceeding 5% of the current value.
[0051] Determining deviations in operating parameters requires considering measurement errors and system response time. A wastewater treatment practice indicates that the permissible fluctuation range for dissolved oxygen is ±15% of the target value; exceeding this range triggers an adjustment command. Adjusting the sludge return ratio requires considering the changing trend of sludge concentration. When the sludge concentration in the sedimentation tank continues to rise, the system will appropriately increase the return ratio, with each adjustment controlled within 5% to ensure the stable operation of the biological system.
[0052] After step S7, the method further includes: The actual concentrations of chemical oxygen demand, ammonia nitrogen, total phosphorus, and total nitrogen in the effluent from the wastewater treatment system are obtained using a real-time monitoring module. Call the preset model calculation module to obtain the predicted concentration values of chemical oxygen demand, ammonia nitrogen, total phosphorus, and total nitrogen; Calculate the deviation values of chemical oxygen demand, ammonia nitrogen, total phosphorus, and total nitrogen based on the actual concentration values and the predicted concentration values; Determine whether the deviation values of chemical oxygen demand, ammonia nitrogen, total phosphorus, and total nitrogen exceed the preset deviation threshold; if the deviation value exceeds the preset deviation threshold, re-collect the concentration values of chemical oxygen demand, ammonia nitrogen, total phosphorus, and total nitrogen. Based on the newly collected water quality data, the optimal combination of process parameters is recalculated, and the control commands are updated until the deviation does not exceed the preset deviation threshold when the control commands are executed.
[0053] It should be noted that the real-time monitoring module is a key component of the wastewater treatment system, continuously collecting effluent water quality data through online analyzers. These online analyzers collect data every thirty minutes to ensure the real-time nature of the monitoring data. Deviation calculation is performed by comparing the measured values with the predicted values. The warning thresholds set for a certain wastewater treatment system are: chemical oxygen demand (COD) deviation not exceeding 15%, ammonia nitrogen deviation not exceeding 20%, total phosphorus deviation not exceeding 10%, and total nitrogen deviation not exceeding 15%. When the measured effluent COD is 50 mg / L, while the predicted value is 40 mg / L, the deviation rate is 25%, exceeding the threshold and triggering an warning.
[0054] Threshold determination needs to consider the importance and fluctuation characteristics of water quality indicators. Chemical oxygen demand (COD) and ammonia nitrogen (AM) are key performance indicators, and their threshold settings are relatively strict. In practice, it has been found that when AM deviations exceed the threshold, it is often related to abnormal operation of the aeration system. For example, when the measured AM value is 3 mg / L and the predicted value is 2 mg / L, the system automatically increases the aeration rate. The data verification mechanism verifies abnormal data through repeated sampling. When total phosphorus deviations exceed the threshold, the system collects data three times consecutively within ten minutes. If all three data points show excessive deviations, it indicates an abnormal treatment effect, requiring timely adjustment of process parameters. Once an anomaly is detected, the system immediately initiates optimization calculations and generates new control commands.
[0055] The control commands are updated gradually to avoid drastic parameter fluctuations. When a decrease in total nitrogen removal efficiency is detected, the system first increases the internal reflux ratio while fine-tuning the aeration rate, continuously monitoring changes in effluent parameters. Practice shows that this method maintains stable system operation while ensuring treatment effectiveness. The complete feedback adjustment process typically takes six to eight hours, during which the system continuously monitors various indicators until the deviation falls back within the threshold range.
[0056] To facilitate understanding of the present invention, some preferred embodiments of the present invention will be described in further detail below.
[0057] In this embodiment, a rural wastewater treatment system needs to optimize aeration rate, reagent dosage, and sludge return ratio to ensure effluent quality meets standards while improving treatment efficiency. The working process is as follows: Step 1: Obtain wastewater quality data for different time periods; Step 2: Preprocess the wastewater quality data to obtain standard wastewater quality data; Step 3: Extract time series data of water quality indicators from the standard wastewater quality data, and smooth them using time series analysis methods to obtain smoothed time series data; wherein, the water quality indicators include chemical oxygen demand, ammonia nitrogen, total phosphorus, and total nitrogen; Step 4: Based on the smoothed time series data, obtain the predicted data for future time series of water quality indicators through the trained long short-term memory neural network model; Step 5: Based on the predicted data, set pollutant emission concentration limits and sludge concentration limits as constraints, construct the objective function of the optimization problem, and thus establish a multi-objective optimization model; Step 6: Solve the multi-objective optimization model using the particle swarm optimization algorithm to obtain the optimal combination of process parameters; wherein, the process parameters include aeration rate, reagent dosage and sludge return ratio; Step 7: Convert the optimal combination into control commands and send them to the execution equipment of the sewage treatment system to control the operating status of the execution equipment.
[0058] Reference Figure 2 This invention provides an IoT-based agricultural wastewater treatment control system, which mainly includes: The data acquisition module is used to acquire wastewater quality data for different time periods; The data preprocessing module is used to preprocess the wastewater quality data to obtain standard wastewater quality data; The time series analysis module is used to extract time series data of water quality indicators from the standard wastewater quality data, and to smooth the data using time series analysis methods to obtain smoothed time series data; wherein, the water quality indicators include chemical oxygen demand, ammonia nitrogen, total phosphorus, and total nitrogen; The prediction module is used to obtain predicted data for future time series of water quality indicators based on smoothed time series data and a trained long short-term memory neural network model. The model building module is used to set pollutant emission concentration limits and sludge concentration limits as constraints based on the predicted data, construct the objective function of the optimization problem, and thus establish a multi-objective optimization model. The model solving module is used to solve the multi-objective optimization model using the particle swarm optimization algorithm to obtain the optimal combination of process parameters, including aeration rate, reagent dosage, and sludge return ratio. The instruction issuing module is used to convert the optimal combination into control instructions and issue them to the execution equipment of the sewage treatment system to control the operating status of the execution equipment.
[0059] It should be noted that the IoT-based agricultural wastewater treatment control system provided in this embodiment of the invention is used to execute all process steps of the IoT-based agricultural wastewater treatment control method described in the above embodiment. The working principles and beneficial effects of the two are one-to-one, so they will not be described again.
[0060] This invention also provides an electronic device. The electronic device includes a processor, a memory, and a computer program stored in the memory and executable on the processor, such as an IoT-based agricultural wastewater treatment control program. When the processor executes the computer program, it implements the steps described in the various IoT-based agricultural wastewater treatment control system method embodiments above, for example... Figure 1 Step S1 is shown. Alternatively, when the processor executes the computer program, it implements the functions of each module / unit in the above-described device embodiments, such as the model solving module.
[0061] For example, the computer program may be divided into one or more modules / units, which are stored in the memory and executed by the processor to complete the present invention. The one or more modules / units may be a series of computer program instruction segments capable of performing a specific function, which describe the execution process of the computer program in the electronic device.
[0062] The electronic device may be a desktop computer, laptop, handheld computer, or smart tablet, etc. The electronic device may include, but is not limited to, a processor and memory. Those skilled in the art will understand that the above components are merely examples of electronic devices and do not constitute a limitation on the electronic device. It may include more or fewer components than described above, or combine certain components, or different components. For example, the electronic device may also include input / output devices, network access devices, buses, etc.
[0063] The processor can be a Central Processing Unit (CPU), or other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor can be a microprocessor or any conventional processor. The processor is the control center of the electronic device, connecting all parts of the electronic device via various interfaces and lines.
[0064] The memory can be used to store the computer programs and / or modules. The processor implements various functions of the electronic device by running or executing the computer programs and / or modules stored in the memory and by calling data stored in the memory. The memory may mainly include a program storage area and a data storage area. The program storage area may store the operating system, at least one application program required for a function (such as sound playback function, image playback function, etc.), etc.; the data storage area may store data created according to the use of the mobile phone (such as audio data, phonebook, etc.). In addition, the memory may include high-speed random access memory, and may also include non-volatile memory, such as hard disk, memory, plug-in hard disk, smart media card (SMC), secure digital (SD) card, flash card, at least one disk storage device, flash memory device, or other volatile solid-state storage device.
[0065] Wherein, if the modules / units integrated in the electronic device are implemented as software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, all or part of the processes in the methods of the above embodiments of the present invention can also be implemented by a computer program instructing related hardware. The computer program can be stored in a computer-readable storage medium, and when executed by a processor, it can implement the steps of the various method embodiments described above. The computer program includes computer program code, which can be in the form of source code, object code, executable files, or certain intermediate forms. The computer-readable medium can include: any entity or device capable of carrying the computer program code, recording media, USB flash drives, portable hard drives, magnetic disks, optical disks, computer memory, read-only memory (ROM), random access memory (RAM), electrical carrier signals, telecommunication signals, and software distribution media, etc. It should be noted that the content included in the computer-readable medium can be appropriately added or removed according to the requirements of legislation and patent practice in the jurisdiction. For example, in some jurisdictions, according to legislation and patent practice, computer-readable media do not include electrical carrier signals and telecommunication signals.
[0066] It should be noted that the device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. Furthermore, in the accompanying drawings of the device embodiments provided by this invention, the connection relationship between modules indicates that they have a communication connection, which can be specifically implemented as one or more communication buses or signal lines. Those skilled in the art can understand and implement this without any creative effort. The above description discloses only preferred embodiments of the present invention and should not be construed as limiting the scope of the invention. Those skilled in the art will understand that implementing all or part of the processes of the above embodiments and making equivalent changes in accordance with the claims of the present invention are still within the scope of the invention.
Claims
1. A method for controlling agricultural wastewater treatment based on the Internet of Things, characterized in that, The method includes: Data acquisition involves collecting wastewater quality data from the wastewater treatment system at different time periods using IoT sensors. The data collected by the IoT sensors is then transmitted to the wastewater treatment monitoring platform via an IoT gateway. The wastewater quality data is preprocessed to obtain standard wastewater quality data. Time series data of water quality indicators are extracted from the standard wastewater quality data and smoothed using time series analysis methods to obtain smoothed time series data. The water quality indicators include chemical oxygen demand (COD), ammonia nitrogen, total phosphorus (TP), and total nitrogen (TN). Effluent water quality data is continuously collected using an online analyzer with a sampling period of 30 minutes. When the TN deviation exceeds a threshold, data is collected three times consecutively within 10 minutes for verification. The exponential smoothing coefficient for the time series analysis is selected based on the variation characteristics of different water quality indicators; a smoothing coefficient of 0.2 is used for TN to better reflect long-term trends. Based on the smoothed time series data, a trained long short-term memory neural network model is used to obtain predicted data for future time series of water quality indicators. In the prediction of ammonia nitrogen, the input layer of the long short-term memory neural network model adds temperature data as an auxiliary feature in addition to historical concentration data. A longer time step is used for the prediction of total phosphorus and total nitrogen. Based on the predicted data, pollutant emission concentration limits and sludge concentration limits are set as constraints, and an objective function for the optimization problem is constructed, thereby establishing a multi-objective optimization model. The multi-objective optimization model is solved using the particle swarm optimization algorithm to obtain the optimal combination of process parameters, including aeration rate, reagent dosage, and sludge return ratio. The optimal combination is converted into control commands and sent to the execution equipment of the wastewater treatment system to control the operating status of the execution equipment. The step of converting the optimal combination into control commands and sending them to the execution equipment of the wastewater treatment system to control the operating status of the execution equipment includes: The preset instruction conversion function is called to convert the optimal combination data into control instructions; the instruction conversion function converts the optimized parameters into equipment control instructions, wherein the operating frequency of the aerator is determined by the ratio of the actual required air volume to the rated air volume, and is expressed as a percentage; Based on the control command, determine the adjustment values of the operating parameters of the aerator, dosing pump, and sludge return pump; A real-time data acquisition module is used to obtain the current operating status data of the execution device; Compare the adjusted operating parameters with the current operating status data to determine if there is a deviation. If there is a deviation, the equipment control module will be invoked to issue adjustment commands to the aerator, dosing pump, and sludge return pump. After converting the optimal combination into control commands and issuing them to the execution equipment of the wastewater treatment system to control the operating status of the execution equipment, the method further includes: The actual concentrations of chemical oxygen demand, ammonia nitrogen, total phosphorus, and total nitrogen in the effluent from the wastewater treatment system are obtained using a real-time monitoring module. Call the preset model calculation module to obtain the predicted concentration values of chemical oxygen demand, ammonia nitrogen, total phosphorus, and total nitrogen; Calculate the deviation values of chemical oxygen demand, ammonia nitrogen, total phosphorus, and total nitrogen based on the actual concentration values and the predicted concentration values; Determine whether the deviation values of chemical oxygen demand, ammonia nitrogen, total phosphorus, and total nitrogen exceed the preset deviation threshold; If the deviation value exceeds the preset deviation threshold, the concentration values of chemical oxygen demand, ammonia nitrogen, total phosphorus, and total nitrogen will be collected again. Based on the newly collected water quality data, the optimal combination of process parameters is recalculated, and the control commands are updated until the deviation does not exceed the preset deviation threshold when executing the control commands. The commands are executed using a gradient adjustment method: when it is necessary to increase the operating frequency of the aerator, it is adjusted in five steps, each time increasing by 2%, with a three-minute interval between adjacent adjustments. In the control of the dosing system, each increase does not exceed 5% of the current value.
2. The method for controlling agricultural wastewater treatment based on the Internet of Things according to claim 1, characterized in that, The preprocessing of the wastewater quality data to obtain standard wastewater quality data includes: The wastewater quality data is subjected to wavelet decomposition to obtain high-frequency components, and it is determined whether the high-frequency components exceed a preset high-frequency threshold. When the high-frequency component exceeds the preset high-frequency threshold, filtering is performed to obtain denoised water quality data. The missing data points before and after the missing values in the denoised water quality data are obtained, and the missing data points are filled in using a linear interpolation method based on the numerical change trend of the missing data points to obtain complete wastewater quality data. The isolated forest algorithm is used to detect the complete wastewater quality data, obtain anomaly scores, and determine whether the anomaly scores exceed a preset anomaly score threshold. When the abnormal score exceeds the preset abnormal score threshold, correction processing is performed to obtain standard wastewater quality data.
3. The method for controlling agricultural wastewater treatment based on the Internet of Things according to claim 1, characterized in that, The time series data of water quality indicators extracted from the standard wastewater quality data are smoothed using time series analysis methods to obtain smoothed time series data. The water quality indicators include chemical oxygen demand (COD), ammonia nitrogen, total phosphorus, and total nitrogen, and include: Time series data of water quality indicators are extracted from the standard wastewater water quality data, and the time series data are smoothed by exponential smoothing method to obtain smoothed time series data.
4. The method for controlling agricultural wastewater treatment based on the Internet of Things according to claim 1, characterized in that, The step of obtaining predicted data for future time series of water quality indicators based on smoothed time series data and a trained long short-term memory neural network model includes: Construct a long short-term memory neural network model, set the time step and the number of neurons, initialize the model parameters, and determine the network structure; Historical wastewater quality data was acquired and divided into training and testing sets. The long short-term memory neural network model is trained using the training set data to obtain the trained prediction model; The trained prediction model is validated using the test set data. If the prediction error exceeds the preset error threshold, the model parameters are adjusted and the model is retrained until the prediction error meets the requirements. Based on the trained prediction model, smoothed time series data are input to obtain predicted data for future time series of water quality indicators.
5. The method for controlling agricultural wastewater treatment based on the Internet of Things according to claim 1, characterized in that, Based on the predicted data, pollutant emission concentration limits and sludge concentration limits are set as constraints to construct an objective function for the optimization problem, thereby establishing a multi-objective optimization model, including: Based on the predicted data, pollutant emission concentration limits and sludge concentration limits are set as constraints. Based on the constraints, an objective function is constructed, with pollutant emission concentration and sludge concentration as the optimization objectives. The objective function is solved using a multi-objective optimization algorithm to obtain the optimal combination of pollutant emission concentration and sludge concentration. If the optimal combination satisfies the preset constraints, then the objective function at this time is used to establish a multi-objective optimization model; If the optimal combination does not meet the preset constraints, the constraints are adjusted and the solution is recalculated until the optimal combination meets the preset constraints.
6. The method for controlling agricultural wastewater treatment based on the Internet of Things according to claim 1, characterized in that, The multi-objective optimization model is solved using a particle swarm optimization algorithm to obtain the optimal combination of process parameters; wherein the process parameters include aeration rate, reagent dosage, and sludge return ratio, including: The particle swarm optimization algorithm is used to pre-establish the particle encoding method, determine the initial range of particle position and velocity, and generate the initial particle swarm. Among them, particle coding combines the aeration rate, reagent dosage and sludge return ratio to be optimized to represent the position of the particle, while the particle velocity represents the direction and magnitude of parameter changes. Based on the objective function and constraints, the fitness value of each particle is calculated, and the particle position is determined based on the fitness value to see if it meets the preset optimization objective. The constraints include: chemical oxygen demand not exceeding 50 mg / L, ammonia nitrogen not exceeding 5 mg / L, total phosphorus not exceeding 0.5 mg / L, and the concentration of suspended solids in the mixed solution controlled between 3,000 and 5,000 mg / L. If the particle position satisfies the preset optimization objective, the current optimal solution is recorded; if the particle position does not satisfy the preset optimization objective, the particle velocity and position are updated, and the fitness value is recalculated until the preset optimization objective is satisfied. By iteratively updating the particle swarm, the optimal combination of process parameters is obtained, and it is determined whether the requirements of the multi-objective optimization model are met. If the optimal combination satisfies the requirements of the multi-objective optimization model, the optimal solution is output; if the optimal combination does not satisfy the requirements of the multi-objective optimization model, the particle swarm initialization strategy is adjusted, and the optimization calculation is repeated until the requirements are met.
7. The method for controlling agricultural wastewater treatment based on the Internet of Things according to claim 1, characterized in that, The particle swarm optimization uses real number encoding, sets the upper limit of particle velocity to 20% of the corresponding variable range, and introduces an inertial weight that decreases with the number of iterations to balance global and local search capabilities.
8. The method for controlling agricultural wastewater treatment based on the Internet of Things according to claim 1, characterized in that, After converting the optimal combination into control commands and issuing them to the execution equipment of the wastewater treatment system to control the operating status of the execution equipment, the method further includes: The actual concentrations of chemical oxygen demand, ammonia nitrogen, total phosphorus, and total nitrogen in the effluent from the wastewater treatment system are obtained using a real-time monitoring module. Call the preset model calculation module to obtain the predicted concentration values of chemical oxygen demand, ammonia nitrogen, total phosphorus, and total nitrogen; Calculate the deviation values of chemical oxygen demand, ammonia nitrogen, total phosphorus, and total nitrogen based on the actual concentration values and the predicted concentration values; Determine whether the deviation values of chemical oxygen demand, ammonia nitrogen, total phosphorus, and total nitrogen exceed the preset deviation threshold; If the deviation value exceeds the preset deviation threshold, the concentration values of chemical oxygen demand, ammonia nitrogen, total phosphorus, and total nitrogen will be collected again. Based on the newly collected water quality data, the optimal combination of process parameters is re-solved, and the control commands are updated until the deviation does not exceed the preset deviation threshold when the control commands are executed. When a decrease in total nitrogen removal efficiency is detected, first increase the internal reflux ratio, while fine-tuning the aeration rate, and update the control command in a gradual manner until the deviation falls back to the threshold range.
9. The method for controlling agricultural wastewater treatment based on the Internet of Things according to claim 7, characterized in that, The initial value for the decreasing sequence is set to 0.9, and the final value is 0.
4.
10. The method for controlling agricultural wastewater treatment based on the Internet of Things according to claim 7, characterized in that, The locations of IoT sensors include key nodes such as the water inlet, biological treatment tank, and secondary sedimentation tank effluent.