Temperature compensation method and device of soil moisture sensor
By constructing a lightweight intelligent compensation model based on historical sensor data, the accuracy problem of temperature calibration of soil moisture sensors in the field environment was solved, achieving high-precision soil moisture measurement and reducing operation and maintenance costs.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- INTELLIGENT EQUIPMENT RESEARCH CENTER BEIJING ACADEMY OF AGRICULTURE AND FORESTRY SCIENCES
- Filing Date
- 2025-12-22
- Publication Date
- 2026-05-12
AI Technical Summary
Existing temperature calibration methods for soil moisture sensors rely on laboratory sample preparation, resulting in a large workload, poor adaptability to individual sensor differences, and an inability to cope with the decrease in calibration accuracy caused by device aging, making it impossible to achieve accurate measurements in the field.
By acquiring historical soil moisture and temperature data from sensors, a lightweight intelligent compensation model is constructed, and online dynamic temperature correction is performed at the edge to adaptively optimize the temperature compensation of the sensors.
It improves the accuracy of soil moisture measurement, reduces operation and maintenance costs, adapts to the effects of individual sensor differences and device aging, and achieves high-precision measurement in the field environment.
Smart Images

Figure CN122017188A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of agricultural Internet of Things (IoT) environmental monitoring technology, and in particular to a method and apparatus for temperature compensation of a soil moisture sensor. Background Technology
[0002] Against the backdrop of global warming, the frequency and intensity of droughts are increasing. Drought disasters, leading to water scarcity, food crises, and ecological degradation (such as desertification), directly threaten food security and socio-economic development. Effective soil moisture monitoring, timely understanding of drought conditions, and proactive real-time regional water resource allocation can effectively prevent droughts and enable scientific irrigation based on changes in soil moisture, thereby reducing the impact of drought on agricultural production.
[0003] Automatic soil moisture monitoring technology has gradually replaced traditional manual sampling methods and become the main development direction due to its advantages such as high measurement timeliness, low labor costs, and continuous data acquisition. Soil moisture measurement methods include tensiometer methods, neutron methods, and dielectric methods. Because tensiometer measurement results are difficult to integrate into information networks, and neutron methods pose radioactive contamination issues, dielectric methods are currently the most commonly used method for measuring soil moisture. Dielectric methods utilize the differences in dielectric constants of soils with different moisture contents, and use the differences in the conduction of electrical signals in media with different dielectric constants to invert soil moisture content. Commonly used soil moisture sensors include time-domain reflectometry (TDR), frequency-domain reflectometry (FDR), and standing wave ratio (SWR) sensors. These types of sensors can achieve long-term in-situ monitoring of soil moisture. FDR is increasingly widely used in soil moisture measurement due to its low cost and simple circuitry; the widely used tubular multi-profile soil moisture sensor is designed using FDR.
[0004] Temperature significantly affects the measurement results of FDR sensors. The core reason is that temperature alters the dielectric properties of the soil and the sensor's own circuit parameters, ultimately leading to deviations in the calculated soil moisture content. The FDR sensor works by emitting electromagnetic waves of a specific frequency and inferring moisture content based on the soil's reflection and absorption characteristics (i.e., dielectric constant). Temperature primarily affects the soil in three ways: 1. It alters the soil dielectric constant. The soil dielectric constant increases with temperature, and the degree of change varies depending on the soil texture (e.g., clay, sand). This can cause the sensor to mistakenly interpret temperature-induced changes in the dielectric constant as changes in soil moisture content, resulting in an inflated moisture content reading at higher temperatures. 2. It interferes with the sensor's circuit performance. The capacitors, resistors, and other electronic components inside the sensor are sensitive to temperature. Temperature fluctuations cause component parameter drift, leading to deviations in the frequency and signal strength of the emitted electromagnetic waves, directly affecting signal detection accuracy, especially at low temperatures (below 5°C) or high temperatures (above 35°C). 3. It affects the soil's physicochemical state. Increased temperature accelerates the evaporation and migration of soil moisture, altering the actual moisture content distribution in localized soils. It can also affect the dissolution of soil salts and ion activity, and the salts themselves can interfere with dielectric constant measurements, further amplifying the indirect impact of temperature on the results. This effect varies depending on the environment: in a constant-temperature laboratory setting, temperature interference can be minimized through calibration; however, in natural outdoor environments, diurnal temperature variations and seasonal temperature changes can cause measurement errors of 5%-15% in uncompensated FDR sensors, sometimes even exceeding the normal measurement range, failing to accurately reflect the true soil moisture content.
[0005] Existing FDR sensor temperature deviation calibration methods mostly employ laboratory sample preparation and calibration. This method involves preparing soil samples with different soil moisture content, embedding the sensor in the soil sample, and placing it in a high and low temperature test chamber. By changing the temperature of the test chamber, the soil sample temperature is changed, and the sensor's measurement values at different temperatures under different soil moisture contents are recorded to construct a regression equation and achieve temperature deviation calibration.
[0006] With the development of artificial intelligence technology, more and more sensor benchmarks are being implemented using intelligent data analysis methods. For example, one existing weighing sensor calibration method based on an ELM neural network uses collected data for training, corrects relevant parameters of the ELM model, and introduces sparse regularization to improve the ELM neural network. Then, it initializes relevant parameters of the Grey Wolf Optimization Algorithm, introduces fractal Brownian motion to improve the Grey Wolf Optimization Algorithm, and finally obtains an ELM model for weighing sensor calibration to calibrate the weighing sensor's output. Another automated sensor calibration method first establishes a temperature-calibration parameter mapping table. Then, based on the sensor's real-time temperature, it dynamically calls the corresponding compensation parameters from the temperature-calibration parameter mapping table and writes the compensation parameters into the sensor, achieving dynamic temperature compensation and solving the problem of temperature compensation differences at different temperature levels.
[0007] The aforementioned methods rely on calibration experiments in the laboratory. Since changes in soil moisture and temperature jointly affect the sensor's measurement accuracy, a large number of soil samples with varying gradients are required for testing, resulting in a significant workload. Furthermore, because the effect of temperature on soil moisture sensors is highly coupled with the sensor's circuit characteristics, there are substantial differences between sensors. Therefore, the calibration models constructed in the laboratory have limited applicability to other sensors, offering limited improvement in measurement accuracy. Additionally, as field installation time increases and sensor electronics age, the effect of temperature on the sensor changes, leading to a decline in temperature calibration accuracy. Therefore, there is an urgent need for dynamically optimized temperature calibration methods tailored to individual sensors to improve the measurement accuracy of soil moisture sensors.
[0008] Existing data-driven sensor calibration methods do not have a specific approach for soil moisture sensors. Since soil moisture sensors are installed in harsh field soil environments for extended periods, and the temperature-related changes in data have certain specific mechanisms, it is urgent to address how to develop a dedicated method model for temperature calibration of soil moisture sensors to enable automatic soil moisture monitoring. Summary of the Invention
[0009] This invention provides a temperature compensation method and apparatus for a soil moisture sensor, which addresses the shortcomings of existing technologies, such as the large workload caused by relying on laboratory sample preparation and calibration, poor adaptability to individual sensor differences, and inability to cope with the decrease in calibration accuracy caused by device aging. It realizes the adaptive construction of a lightweight intelligent compensation model using the sensor's in-situ historical monitoring data, and performs online dynamic correction of temperature interference at the edge, thereby significantly improving the accuracy of soil moisture measurement and reducing operation and maintenance costs.
[0010] This invention provides a temperature compensation method for a soil moisture sensor, comprising: Acquire the first historical soil moisture data and the first historical soil temperature data collected by the target soil moisture sensor to be temperature compensated, wherein the first historical soil moisture data and the first historical soil temperature data are data synchronously collected within a first preset time period before the current moment; Acquire the current soil moisture data collected by the target soil moisture sensor at the current moment; The first historical soil moisture data, the first historical soil temperature data, and the current soil moisture data are input into the temperature correction model. The temperature correction model is used to perform temperature compensation processing on the current soil moisture data to obtain the temperature-corrected target soil moisture data. The temperature correction model is trained through the following steps: Acquire second historical soil moisture data and second historical soil temperature data with the same timestamps recorded by the soil moisture sensor. The initial model is trained using the second historical soil moisture data and the second historical soil temperature data. When the training results meet the multidimensional criteria, the model training is considered complete, and a temperature correction model is obtained.
[0011] In one possible implementation, the method further includes: The second historical soil moisture data and the second historical soil temperature data with the same timestamp are divided into multiple training samples according to a fixed time window. Each training sample contains pairs of second historical soil temperature and humidity data that are synchronously recorded hourly within a continuous time period, thus obtaining a time-dependent training dataset. Construct an initial model based on the time-series decomposition method; The second historical soil temperature data and its corresponding time-series derived features in the training dataset are used as input variables, and the second historical soil moisture data is used as the target to be corrected. The nonlinear mapping relationship between the temperature disturbance component and the soil moisture measurement deviation is learned through the initial model. The initial model is trained by iteratively optimizing the objective function of the initial model.
[0012] In one possible implementation, the method further includes: When the objective function converges and satisfies the preset multidimensional criteria, the trained temperature correction model is obtained. The objective function contains multiple adversarial constraint terms, and the multidimensional criteria include multiple evaluation criteria for the model output results.
[0013] In one possible implementation, the method further includes: Acquire historical time-series data recorded by a soil moisture sensor over at least one complete rainfall cycle, the historical time-series data including synchronously acquired historical soil moisture data sequences and historical soil temperature data sequences; The data filtering model identifies and removes abrupt data segments in the historical soil moisture data sequence caused by external factors, while retaining effective data segments where soil moisture shows a natural and gradual trend. External factors include rainfall and / or irrigation. Based on the valid data segments, determine the second historical soil moisture data and the second historical soil temperature data with the same timestamp.
[0014] In one possible implementation, the method further includes: The historical soil moisture data sequence is divided into a first time scale and a second time scale, and then input into a first bidirectional gated cyclic unit network and a second bidirectional gated cyclic unit network that run in parallel, respectively. The first time scale is smaller than the second time scale. The prediction outputs of the first bidirectional gated recurrent unit network and the second bidirectional gated recurrent unit network are combined using Gaussian weighting to obtain the combined prediction value. When the error between the combined predicted value and the actual measured value at a certain moment is greater than or equal to the error threshold, the historical soil moisture data at that moment is determined to be external factor interference data and is removed, while the effective data segment showing a natural and gradual change trend of soil moisture is retained.
[0015] In one possible implementation, the method further includes: After the target soil moisture sensor collects the latest data over a period of time, the parameters of the temperature correction model are fine-tuned using the latest data.
[0016] The present invention also provides a temperature compensation device for a soil moisture sensor, comprising the following modules: The data acquisition module is used to acquire the first historical soil moisture data and the first historical soil temperature data collected by the target soil moisture sensor to be temperature compensated, wherein the first historical soil moisture data and the first historical soil temperature data are data synchronously collected within a first preset time period before the current moment. The data acquisition module is used to acquire the current soil moisture data collected by the target soil moisture sensor at the current moment; The data correction module is used to input the first historical soil moisture data, the first historical soil temperature data and the current soil moisture data into the temperature correction model, and to perform temperature compensation processing on the current soil moisture data through the temperature correction model to obtain the temperature-corrected target soil moisture data. The model training module is used to acquire second historical soil moisture data and second historical soil temperature data with the same timestamps recorded by the soil moisture sensor; the initial model is trained using the second historical soil moisture data and the second historical soil temperature data; when the training results meet the multidimensional criteria, the model training is determined to be complete, and a temperature correction model is obtained.
[0017] The present invention also provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the temperature compensation method for the soil moisture sensor as described above.
[0018] The present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the temperature compensation method for a soil moisture sensor as described above.
[0019] The present invention also provides a computer program product, including a computer program that, when executed by a processor, implements the temperature compensation method for a soil moisture sensor as described above.
[0020] The soil moisture sensor temperature compensation method and apparatus provided by this invention acquires first historical soil moisture data and first historical soil temperature data collected by the target soil moisture sensor to be temperature compensated, wherein the first historical soil moisture data and first historical soil temperature data are data synchronously collected within a first preset time period before the current moment; acquires the current soil moisture data collected by the target soil moisture sensor at the current moment; inputs the first historical soil moisture data, the first historical soil temperature data and the current soil moisture data into a temperature correction model, and performs temperature compensation processing on the current soil moisture data through the temperature correction model to obtain temperature-corrected target soil moisture data; wherein the temperature correction model is trained through the following steps: acquiring second historical soil moisture data and second historical soil temperature data with the same timestamp recorded by the sample soil moisture sensor; training the initial model with the second historical soil moisture data and the second historical soil temperature data; when the training result meets the multidimensional criteria, the model training is determined to be complete, and the temperature correction model is obtained. Compared to existing technologies that rely on laboratory sample preparation and calibration, resulting in high workload, poor adaptability to individual sensor differences, and inability to cope with calibration accuracy decay caused by device aging, this solution utilizes in-situ historical monitoring data from sensors to adaptively construct a lightweight intelligent compensation model. This model performs online dynamic correction of temperature interference at the edge, thereby improving the accuracy of soil moisture measurement and reducing operation and maintenance costs. Attached Figure Description
[0021] To more clearly illustrate the technical solutions in this invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of this invention. For those skilled in the art, other drawings can be obtained from these drawings without creative effort.
[0022] Figure 1 This is a schematic flowchart of the temperature compensation method for the soil moisture sensor provided by the present invention.
[0023] Figure 2 This is a schematic flowchart of the temperature correction model training method provided by the present invention.
[0024] Figure 3 This is a schematic diagram of the Stacked-Bi-GRU network provided by the present invention.
[0025] Figure 4 This is a schematic diagram of the temperature compensation device for the soil moisture sensor provided by the present invention.
[0026] Figure 5 This is a schematic diagram of the structure of the electronic device provided by the present invention. Detailed Implementation
[0027] To make the objectives, technical solutions, and advantages of this invention clearer, the technical solutions of this invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of this invention. All other embodiments obtained by those skilled in the art based on the embodiments of this invention without creative effort are within the scope of protection of this invention.
[0028] To facilitate understanding of the embodiments of the present invention, further explanations and descriptions will be provided below with reference to the accompanying drawings and specific embodiments. These embodiments do not constitute a limitation on the embodiments of the present invention.
[0029] Figure 1 This is a schematic flowchart of the temperature compensation method for the soil moisture sensor provided by the present invention, as shown below. Figure 1 As shown, the method includes the following: S11. Obtain the first historical soil moisture data and the first historical soil temperature data collected by the target soil moisture sensor to be temperature compensated.
[0030] This invention constructs an intelligent temperature compensation model for a soil moisture sensor based on long-term monitoring and recording of soil moisture and temperature data. By inputting the latest time-series monitoring dataset into the model, the measurement data is corrected online by running the temperature compensation model using the latest monitoring dataset. Furthermore, the parameters in the compensation model are optimized in real time to achieve temperature compensation that continuously improves with the sensor's operating conditions, thereby enhancing the accuracy of soil moisture measurement.
[0031] Specifically, firstly, historical soil temperature and humidity data recorded by the target soil moisture sensor to be temperature compensated are acquired, and the data is filtered to remove data with drastic changes in soil moisture, retaining slowly varying data unaffected by external factors such as rainfall and irrigation, and only retaining effective slowly varying data segments where soil moisture shows a slow decreasing trend (e.g., change rate <0.5% / h), thus obtaining the first historical soil moisture data and the first historical soil temperature data. The first historical soil moisture data and the first historical soil temperature data are hourly data collected synchronously within a first preset time period (e.g., 7 days) prior to the current moment.
[0032] S12. Obtain the current soil moisture data collected by the target soil moisture sensor at the current moment.
[0033] The current soil moisture data is the original dielectric constant conversion value output by the target soil moisture sensor. This measurement value includes artificially high or low values caused by temperature interference.
[0034] S13. Input the first historical soil moisture data, the first historical soil temperature data and the current soil moisture data into the temperature correction model, and perform temperature compensation processing on the current soil moisture data through the temperature correction model to obtain the temperature-corrected target soil moisture data.
[0035] The temperature correction model in this embodiment is a lightweight tree ensemble model built based on the XGBoost algorithm, deployed in the embedded microcontroller of the target soil moisture sensor. A single inference iteration takes less than 1 second, and the model parameters are less than 100KB. Temperature compensation is achieved by removing the rapidly changing interference components caused by temperature, ensuring that the absolute value of the correlation coefficient between the corrected target soil moisture data and temperature is less than 0.1. The training method for this temperature correction model will not be detailed here.
[0036] The soil moisture sensor temperature compensation method of this invention does not require laboratory testing; in-situ temperature compensation can be achieved using historical data recorded by the sensor. It employs a computationally small artificial intelligence model, which facilitates portability to the sensor. Running the model on the sensor reduces service load, allowing the sensor to directly upload the corrected soil moisture results.
[0037] The soil moisture sensor temperature compensation method provided by this invention acquires first historical soil moisture data and first historical soil temperature data collected by the target soil moisture sensor to be temperature compensated, wherein the first historical soil moisture data and first historical soil temperature data are data synchronously collected within a first preset time period before the current moment; acquires the current soil moisture data collected by the target soil moisture sensor at the current moment; inputs the first historical soil moisture data, the first historical soil temperature data, and the current soil moisture data into a temperature correction model, and performs temperature compensation processing on the current soil moisture data through the temperature correction model to obtain the temperature-corrected target soil moisture data. Compared with the shortcomings of existing technologies that rely on laboratory sample preparation and calibration, resulting in large workload, poor adaptability to individual sensor differences, and inability to cope with the calibration accuracy decay caused by device aging, this method uses in-situ historical monitoring data of the sensor to adaptively construct a lightweight intelligent compensation model, and performs online dynamic correction of temperature interference at the edge, thereby improving the accuracy of soil moisture measurement and reducing operation and maintenance costs.
[0038] Figure 2 This is a flowchart illustrating the temperature correction model training method provided by the present invention, as shown below. Figure 2 As shown, the method includes the following: S21. Obtain historical time-series data recorded by the soil moisture sensor in the sample over at least one complete rainfall cycle.
[0039] Soil moisture is typically a slow-moving variable; without external factors such as rainfall or irrigation, it changes slowly, exhibiting a gradual, decreasing trend. Soil temperature, on the other hand, is a fast-moving variable, fluctuating dramatically daily in response to changes in air temperature. Because sensor measurements are affected by soil temperature, soil moisture measurements will fluctuate with temperature changes.
[0040] In this embodiment of the invention, firstly, historical soil moisture data sequences and historical soil temperature data sequences are collected synchronously. The sampling frequency can be once per hour, and the data timestamps are strictly aligned.
[0041] S22. Identify and remove abrupt data segments in the historical soil moisture data sequence caused by external factors through a data filtering model, and retain effective data segments in which soil moisture shows a natural and gradual trend.
[0042] S23. Based on the valid data segment, determine the second historical soil moisture data and the second historical soil temperature data with the same timestamp.
[0043] Furthermore, historical data is filtered, and data that has undergone drastic changes in soil moisture due to external factors, including rainfall and / or irrigation, is identified and removed using a data filtering model. The fluctuations in the remaining data are strongly correlated with changes in soil temperature. This data is used to construct a training dataset to train the intelligent data analysis model.
[0044] The historical data filtering method described in this invention embodiment can be a Stacked-Bi-GRU. This method is based on a lightweight time-series data intelligent recognition gated recurrent unit (GRU). Since the impact of rainfall on soil moisture changes is characterized by a rapid increase in soil moisture during rainfall and a slow decrease after rainfall, a bidirectional gated recurrent unit (Bi-GRU) is used to more effectively identify abrupt changes in soil moisture. Due to the varying duration of rainfall, a single-scale Bi-GRU cannot simultaneously identify both long-duration and short-duration rainfall. Therefore, a stacking mechanism is introduced to construct a Stacked-Bi-GRU (stacked bidirectional GRU network), as shown below. Figure 3 As shown, the Stacked-Bi-GRU model consists of multiple Bi-GRU networks. Each Bi-GRU network uses a different time scale to predict the current value. The prediction results are combined in a weighted average manner to obtain the combined prediction result of the current value. The error between the combined prediction result and the actual value is calculated. When the error increases significantly, it is considered to be a period of rainfall, and the data is removed from the final dataset.
[0045] In a Stacked-Bi-GRU model with two time scales stacked vertically, such as Figure 3 Historical soil moisture data is segmented into two vectors, X and X', at two different scales and input into Bi-GRU networks 1 and 2, respectively. The scale can be selected from several hours to several days (5-6 hours to 5-7 days) depending on the changes in soil moisture after rainfall. The calculation process of the Bi-GRU network can be represented by Equation 1: (1) in, Output the value at time t. and Forward at time t and reverse Output the corresponding parameter weights. This represents the bias variable at time t. Forward at time t-1 The output, Reverse at time t-1 The output.
[0046] After obtaining the output of the Bi-GRU, the calculation results ht-1, ht, and ht+1 at times t-1, t, and t+1 are weighted to obtain the soil moisture prediction result using the X data. Soil moisture is predicted using time X' in the same way, and the prediction results at the two scales are weighted to obtain the final soil moisture prediction result. The prediction results of multiple parallel Bi-GRU networks can be weighted using a Gaussian weighting method, as shown in Equation 2.
[0047] (2) in, For the final prediction result, For the prediction result of the i-th Bi-GRU network, The weights are obtained by Gaussian calculation using the Gaussian function (Equation 3).
[0048] (3) in, σ(sigma) is the data scale used for prediction, and σ is the bandwidth parameter in the normal distribution.
[0049] The predicted results are compared with the actual measured values to identify the error. When the error exceeds a certain value (e.g., 10%), it is considered to be a change caused by external disturbances such as rainfall, and the data is removed from the dataset.
[0050] S24. Divide the second historical soil moisture data and the second historical soil temperature data with the same timestamp into multiple training samples according to a fixed time window. Each training sample contains pairs of second historical soil temperature and humidity data that are synchronously recorded hourly within a continuous time period to obtain a time-dependent training dataset.
[0051] After filtering historical monitoring data, the data is divided into time series to construct soil temperature and soil moisture datasets for training the temperature correction model. In order to retain as much relevant information about the temperature on soil moisture measurement results as possible, while reducing the computational load of the model, this embodiment of the invention uses one day's data as a data vector, as shown in Equation 4.
[0052] (4) in, For the i-th data vector, The soil moisture measurement value at time 1. The soil temperature measurement is shown at time 1.
[0053] S25. Construct an initial model based on the time-series decomposition method.
[0054] The core of the soil moisture sensor temperature compensation model constructed in this invention is to separate the slow-changing trend (slow decrease in soil moisture) and the fast-changing interference (the effect of temperature on the sensor) from the soil moisture monitoring data. Therefore, intelligent algorithm models such as VMD (Variational Mode Decomposition) and STL (Seasonal Trend Decomposition) based on time-series decomposition methods, or model gradient boosting trees (XGBoost / LightGBM) and Kalman filters based on regression / filtering can be used.
[0055] S26. Using the second historical soil temperature data and corresponding time-series derived features in the training dataset as input variables, and the second historical soil moisture data as the target to be corrected, the nonlinear mapping relationship between the temperature disturbance component and the soil moisture measurement deviation is learned through the initial model.
[0056] S27. Train the initial model by iteratively optimizing the objective function of the initial model.
[0057] The model takes as input a continuous time-series historical soil moisture and soil temperature monitoring dataset and outputs as a soil moisture time-series sequence after removing the influence of temperature.
[0058] The time-series derived features include: the current soil temperature measurement, the rate of temperature change from the previous 1 hour to 24 hours, the difference between the maximum and minimum temperatures in the previous 24 hours, and the deviation of the current soil temperature from the historical temperature for the same period.
[0059] S28. When the objective function converges and satisfies the preset multidimensional criteria, the trained temperature correction model is obtained.
[0060] The objective function includes three adversarial constraints: minimizing the residual between the corrected output and the original measurement, minimizing the temporal second difference of the corrected output to preserve the slow variation characteristics of soil moisture, and minimizing the Pearson correlation coefficient between the corrected output and the input temperature to decouple temperature interference. The trained temperature correction model is obtained when the objective function converges and meets the preset multidimensional performance criteria. These multidimensional criteria include evaluation standards for multiple model output results: on the independent validation set, the root mean square error of the corrected output is less than 3%; the absolute value of the Pearson correlation coefficient between the corrected output and soil temperature is less than 0.1; and the mean of the temporal second difference of the corrected output is less than 0.1% / h. 2 The total number of model parameters is less than 100KB and the time taken for a single inference is less than 1 second.
[0061] Taking the construction of a temperature correction model using the XGBoost algorithm as an example. XGBoost is a machine learning algorithm implemented with gradient boosting technology. Its base classifier is a Classification and Regression Tree (CART). XGBoost combines multiple CARTs, making it a tree ensemble model. The XGBoost model is built by iteratively adding trees. The predicted value of the i-th sample at the t-th iteration can be expressed as:
[0062] Iteratively adding trees to minimize the objective function, which can be expressed as:
[0063] In the formula, For loss function, This indicates the model complexity.
[0064] To quickly optimize the objective, a second-order Taylor expansion is used on equation (6), as shown in equation (7).
[0065] in, , These are the first and second derivatives of the loss function term, respectively. (Adding the...) When planting trees, in front The trees have completed the training, that is... If it is a constant term, removing this term yields the first term. The simplified objective function of the step is shown in equation (8).
[0066] definition Let j be the sample set of leaf node j. This is achieved by expanding the regularization term. Equation (9) can be written as:
[0067] in, Let be the weight of leaf node j.
[0068] Ultimately, the objective function is optimized, and the optimal solution can be expressed as:
[0069] Leaf node splitting is based on the model's input variables. The importance score of an input variable is calculated by the number of times it is applied to leaf node splitting. The importance score reflects the correlation between the input variable and the model output.
[0070] S29. After the target soil moisture sensor collects the latest data over a period of time, the temperature correction model is fine-tuned using the latest data.
[0071] After the above steps, a temperature correction model is obtained for data filtering and temperature correction. The temperature correction model is then transferred to the acquisition unit of the soil moisture sensor. Through the calculation of the model, temperature correction data of soil moisture can be obtained.
[0072] The implementation process of the soil moisture and temperature correction method on the sensor is as follows: First, the sensor records the raw soil moisture and soil temperature data. The recording time should be longer than the maximum time scale of the data filtering model, such as 7 days of data. The recorded data is then processed by the data filtering model to remove drastic changes in soil moisture. The monitoring data from the most recent day is then input into the temperature correction model. The output of the model is the soil moisture data after temperature correction.
[0073] Furthermore, after the target soil moisture sensor collects new data every 7 days, it automatically triggers an incremental training mode. The new data is used to fine-tune the parameters of the temperature correction model to adapt to the temperature characteristic drift caused by the aging of the sensor's electronic components. The parameter fine-tuning adopts a transfer learning strategy, which can freeze the bottom feature extraction layer of the model and only update the leaf node weights of the top tree structure. The learning rate is set to 0.1 times that of the initial training phase.
[0074] The temperature correction model training method in this invention utilizes the characteristic of constant soil moisture, separating the data from the drastic changes caused by external factors such as rainfall and irrigation, and the fluctuations caused by temperature. Only the data with the dominant temperature influence is analyzed to construct the correction model. The correction model is trained using long-term historical data recorded by sensors, and then the trained model is run on the sensors. This fully utilizes the historical data recorded by sensors to uncover the influence of temperature on the measurement results, eliminating the need for laboratory experiments to construct the temperature correction model. Data selection and the temperature correction model are constructed using intelligent methods, satisfying the non-linear influence of temperature on soil moisture sensor measurement results, thus making the correction results more accurate.
[0075] The temperature compensation device for the soil moisture sensor provided by the present invention is described below. The temperature compensation device for the soil moisture sensor described below can be referred to in correspondence with the temperature compensation method for the soil moisture sensor described above.
[0076] Figure 4 This is a schematic diagram of the temperature compensation device for the soil moisture sensor provided by the present invention, specifically including: The data acquisition module 401 is used to acquire first historical soil moisture data and first historical soil temperature data collected by the target soil moisture sensor to be temperature compensated. The first historical soil moisture data and first historical soil temperature data are data synchronously collected within a first preset time period prior to the current moment. For detailed explanation, please refer to the relevant descriptions in the above method embodiments; they will not be repeated here.
[0077] The data acquisition module 401 is used to acquire the current soil moisture data collected by the target soil moisture sensor at the current moment. For detailed explanation, please refer to the relevant descriptions in the above method embodiments, which will not be repeated here.
[0078] The data correction module 402 is used to input the first historical soil moisture data, the first historical soil temperature data, and the current soil moisture data into the temperature correction model, and to perform temperature compensation processing on the current soil moisture data through the temperature correction model to obtain the temperature-corrected target soil moisture data. For detailed explanations, please refer to the relevant descriptions in the above method embodiments, which will not be repeated here.
[0079] The model training module 403 is used to acquire second historical soil moisture data and second historical soil temperature data with the same timestamps recorded by the sample soil moisture sensor; the initial model is trained using the second historical soil moisture data and the second historical soil temperature data; when the training result meets the multidimensional criteria, the model training is considered complete, and a temperature correction model is obtained. For detailed explanations, please refer to the relevant descriptions in the above method embodiments, which will not be repeated here.
[0080] Figure 5 An example is a schematic diagram of the physical structure of an electronic device, such as... Figure 5As shown, the electronic device may include: a processor 510, a communications interface 520, a memory 530, and a communications bus 540, wherein the processor 510, the communications interface 520, and the memory 530 communicate with each other through the communications bus 540. The processor 510 can call logic instructions in the memory 530 to execute a temperature compensation method for a soil moisture sensor. This method includes: acquiring first historical soil moisture data and first historical soil temperature data collected by the target soil moisture sensor to be temperature compensated, wherein the first historical soil moisture data and first historical soil temperature data are data synchronously collected within a first preset time period prior to the current moment; acquiring current soil moisture data collected by the target soil moisture sensor at the current moment; inputting the first historical soil moisture data, the first historical soil temperature data, and the current soil moisture data into a temperature correction model, and performing temperature compensation processing on the current soil moisture data through the temperature correction model to obtain temperature-corrected target soil moisture data; wherein the temperature correction model is trained through the following steps: acquiring second historical soil moisture data and second historical soil temperature data with the same timestamp recorded by the sample soil moisture sensor; training the initial model using the second historical soil moisture data and the second historical soil temperature data; and determining that the model training is complete when the training result meets the multidimensional criteria, thus obtaining the temperature correction model.
[0081] Furthermore, the logical instructions in the aforementioned memory 530 can be implemented as software functional units and, when sold or used as independent products, can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, or a part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0082] On the other hand, the present invention also provides a computer program product, which includes a computer program that can be stored on a non-transitory computer-readable storage medium. When the computer program is executed by a processor, the computer can execute the temperature compensation method for a soil moisture sensor provided by the above methods. The method includes: acquiring first historical soil moisture data and first historical soil temperature data collected by the target soil moisture sensor to be temperature compensated, wherein the first historical soil moisture data and the first historical soil temperature data are data synchronously collected within a first preset time period before the current moment; acquiring current soil moisture data collected by the target soil moisture sensor at the current moment; inputting the first historical soil moisture data, the first historical soil temperature data, and the current soil moisture data into a temperature correction model, and performing temperature compensation processing on the current soil moisture data through the temperature correction model to obtain temperature-corrected target soil moisture data; wherein the temperature correction model is trained through the following steps: acquiring second historical soil moisture data and second historical soil temperature data with the same timestamp recorded by the sample soil moisture sensor; training the initial model with the second historical soil moisture data and the second historical soil temperature data; and determining that the model training is complete when the training result meets the multidimensional criteria, thereby obtaining the temperature correction model.
[0083] In another aspect, the present invention also provides a non-transitory computer-readable storage medium storing a computer program thereon. When executed by a processor, the computer program implements a temperature compensation method for a soil moisture sensor provided by the methods described above. This method includes: acquiring first historical soil moisture data and first historical soil temperature data collected by a target soil moisture sensor to be temperature compensated, wherein the first historical soil moisture data and first historical soil temperature data are data synchronously collected within a first preset time period prior to the current moment; acquiring current soil moisture data collected by the target soil moisture sensor at the current moment; inputting the first historical soil moisture data, the first historical soil temperature data, and the current soil moisture data into a temperature correction model; performing temperature compensation processing on the current soil moisture data through the temperature correction model to obtain temperature-corrected target soil moisture data; wherein the temperature correction model is trained through the following steps: acquiring second historical soil moisture data and second historical soil temperature data with the same timestamp recorded by sample soil moisture sensors; training an initial model using the second historical soil moisture data and the second historical soil temperature data; and determining that the model training is complete when the training result meets the multidimensional criteria, thus obtaining the temperature correction model.
[0084] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate. 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. Those skilled in the art can understand and implement this without any creative effort.
[0085] Through the above description of the embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of software plus necessary general-purpose hardware platforms, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solutions, in essence or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute the methods described in the various embodiments or some parts of the embodiments.
[0086] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A temperature compensation method for a soil moisture sensor, characterized in that, include: Acquire the first historical soil moisture data and the first historical soil temperature data collected by the target soil moisture sensor to be temperature compensated, wherein the first historical soil moisture data and the first historical soil temperature data are data synchronously collected within a first preset time period before the current moment; Acquire the current soil moisture data collected by the target soil moisture sensor at the current moment; The first historical soil moisture data, the first historical soil temperature data, and the current soil moisture data are input into the temperature correction model. The temperature correction model is used to perform temperature compensation processing on the current soil moisture data to obtain the temperature-corrected target soil moisture data. The temperature correction model is trained through the following steps: Acquire second historical soil moisture data and second historical soil temperature data with the same timestamps recorded by the soil moisture sensor. The initial model is trained using the second historical soil moisture data and the second historical soil temperature data. When the training results meet the multidimensional criteria, the model training is considered complete, and a temperature correction model is obtained.
2. The method according to claim 1, characterized in that, The step of training the initial model using the second historical soil moisture data and the second historical soil temperature data includes: The second historical soil moisture data and the second historical soil temperature data with the same timestamp are divided into multiple training samples according to a fixed time window. Each training sample contains pairs of second historical soil temperature and humidity data that are synchronously recorded hourly within a continuous time period, thus obtaining a time-dependent training dataset. Construct an initial model based on the time-series decomposition method; The second historical soil temperature data and its corresponding time-series derived features in the training dataset are used as input variables, and the second historical soil moisture data is used as the target to be corrected. The nonlinear mapping relationship between the temperature disturbance component and the soil moisture measurement deviation is learned through the initial model. The initial model is trained by iteratively optimizing the objective function of the initial model.
3. The method according to claim 2, characterized in that, When the training results meet the multidimensional criteria, the model training is determined to be complete, and a temperature correction model is obtained, including: When the objective function converges and satisfies the preset multidimensional criteria, the trained temperature correction model is obtained. The objective function contains multiple adversarial constraint terms, and the multidimensional criteria include multiple evaluation criteria for the model output results.
4. The method according to claim 1, characterized in that, The acquisition of second historical soil moisture data and second historical soil temperature data with the same timestamps recorded by the soil moisture sensor includes: Acquire historical time-series data recorded by a soil moisture sensor over at least one complete rainfall cycle, the historical time-series data including synchronously acquired historical soil moisture data sequences and historical soil temperature data sequences; The data filtering model identifies and removes abrupt data segments in the historical soil moisture data sequence caused by external factors, while retaining effective data segments where soil moisture shows a natural and gradual trend. External factors include rainfall and / or irrigation. Based on the valid data segments, determine the second historical soil moisture data and the second historical soil temperature data with the same timestamp.
5. The method according to claim 4, characterized in that, The process of identifying and removing abrupt data segments in the historical soil moisture data sequence caused by external factors through a data filtering model, while retaining effective data segments showing a natural and gradual trend in soil moisture, includes: The historical soil moisture data sequence is divided into a first time scale and a second time scale, and then input into a first bidirectional gated cyclic unit network and a second bidirectional gated cyclic unit network that run in parallel, respectively. The first time scale is smaller than the second time scale. The prediction outputs of the first bidirectional gated recurrent unit network and the second bidirectional gated recurrent unit network are combined using Gaussian weighting to obtain the combined prediction value. When the error between the combined predicted value and the actual measured value at a certain moment is greater than or equal to the error threshold, the historical soil moisture data at that moment is determined to be external factor interference data and is removed, while the effective data segment showing a natural and gradual change trend of soil moisture is retained.
6. The method according to any one of claims 1-5, characterized in that, The method further includes: After the target soil moisture sensor collects the latest data over a period of time, the parameters of the temperature correction model are fine-tuned using the latest data.
7. A temperature compensation device for a soil moisture sensor, characterized in that, include: The data acquisition module is used to acquire the first historical soil moisture data and the first historical soil temperature data collected by the target soil moisture sensor to be temperature compensated, wherein the first historical soil moisture data and the first historical soil temperature data are data synchronously collected within a first preset time period before the current moment. The data acquisition module is used to acquire the current soil moisture data collected by the target soil moisture sensor at the current moment; The data correction module is used to input the first historical soil moisture data, the first historical soil temperature data and the current soil moisture data into the temperature correction model, and to perform temperature compensation processing on the current soil moisture data through the temperature correction model to obtain the temperature-corrected target soil moisture data. The model training module is used to acquire second historical soil moisture data and second historical soil temperature data with the same timestamps recorded by the soil moisture sensor; the initial model is trained using the second historical soil moisture data and the second historical soil temperature data; when the training results meet the multidimensional criteria, the model training is determined to be complete, and a temperature correction model is obtained.
8. An electronic device comprising a memory, a processor, and a computer program stored in the memory and running on the processor, characterized in that, When the processor executes the computer program, it implements the temperature compensation method for the soil moisture sensor as described in any one of claims 1 to 6.
9. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by the processor, it implements the temperature compensation method for the soil moisture sensor as described in any one of claims 1 to 6.
10. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by the processor, it implements the temperature compensation method for the soil moisture sensor as described in any one of claims 1 to 6.