Adaptive Nonlinearity Compensation System for Integrated Temperature and Moisture Sensor

Measuring temperature and moisture are important in many scenarios. It has been verified that temperature greatly affects the accuracy of moisture sensing. Moisture sensing performance would suffer without temperature calibrations. This paper introduces a nonlinearity compensation technique for temperature-dependent nonlinearity calibration of moisture sensors, which is based on an adaptive nonlinear order regulating model. An adaptive algorithm is designed to automatically find the optimal order number, which was subsequently applied in a nonlinear mathematical model to compensate for the temperature effects and improve the moisture measurement accuracy. The integrated temperature and moisture sensor with the proposed adaptive nonlinear order regulating nonlinearity compensation technique is found to be more effective and yield better sensing performance.


Introduction
Temperature and moisture sensors have extensive applications in many industries, including agriculture, food, pharmaceuticals, mining, construction, and so on. For instance, integrated temperature and moisture sensors have been widely deployed in the wheatland in Zhejiang academy of agricultural sciences, as shown in Figure 1.  However, previous researchers have proven that temperature variation has a significant and nonlinear influence on moisture measurement results [1,2]. On the one hand, the materials which make up the moisture sensing elements behave in a nonlinear way with the temperature. On the other hand, all moisture sensors must contain active electronics, which are characterized by a nonlinear relationship with temperature [3,4]. To obtain a correct moisture reading, primitive moisture measurement data need to be adjusted according to temperature, often in a nonlinear manner [3][4][5][6].
In general, a commercial sensor would be made of a temperature sensing unit and a moisture sensing unit integrated together. Conventionally, moisture adjustment by temperature was achieved with look-up tables (LUTs), which are large datasets consisting of measured temperatures, measured moistures, and corresponding adjusted moisture values [6]. Manufacturers perform huge numbers of tests under various temperatures and moisture levels in order to construct LUTs. However, the accuracy of this nonlinear mapping relationship depends on the precision of the measurements and the size of the LUT [7,8]. LUT-based adjustment can be highly accurate; however, a sensor unit can potentially be used in a huge range of temperatures, thus requiring a huge LUT to accurately provide moisture level readings. Despite this, the LUT method is effective and straightforward, although its huge size means it cannot be implemented in a microcontroller with limited memory.
A mathematical model of nonlinear adjustment can overcome the shortcomings of conventional sensors, and to a large extent, reflect and compensate the complex effect of temperature on moisture readings [9][10][11]. However, the existing compensation methods often use nonlinear mathematical models with fixed orders, which may not reach optimal error under different usage environments, thus making it difficult to attain the best compensation effects. In addition, these models are hard to migrate from one type of sensor to another.
In order to achieve a better sensing performance and lower measurement error, we propose a nonlinear compensation method for adaptive order adjustment. A high-order mathematical formula is used to reflect the nonlinear relationship between the actual moisture and the sensor's measured probe voltage [12,13]. A high-order mathematical compensation model with the smallest error is selected by an adaptive order selection module. The experimental results verify that the measurement accuracy of this adaptive order nonlinearity compensated temperature and moisture sensor is significantly improved.

System Construction
The structure of a conventional temperature and moisture sensor is shown in Figure 2. A temperature sensor and a moisture sensor are integrated in the system. The analog measurement results are digitized by an analog-to-digital converter (ADC) and then calibrated by a LUT-based linearization module [14]. The calibration memory should be large enough to store a large LUT for high-accuracy temperature and moisture sensing, thus this traditional method requires a large storage capacity. As shown in Figure 3, the temperature-moisture sensor uses a fixed-order temperature-dependent nonlinear compensation model rather than a look-up table. Temperature-dependent nonlinear modeling requires three sets of data, including internally detected moisture, internally detected temperature, and true moisture transmitted from the outside via the RS485 interface [15]. When determining the fixed-order nonlinear model, the least square (LS) algorithm is used to estimate the model coefficients.  The adaptive order-adjusted temperature and moisture sensor proposed in this paper, as shown in Figure 4, adds an adaptive order adjustment and feedback module based on the Figure 3 fixed-order nonlinear compensation model. The same as the architecture shown in Figure 3, temperature-dependent nonlinear modeling requires the same three sets of data, including internally detected temperature, internally detected moisture, and true moisture. The adaptive nonlinear order regulation algorithm module is added to search for the model with the optimal nonlinear order and the best nonlinearity compensation performance. During the searching process, the LS algorithm is used to estimate coefficients of the variable order models.  The advantages and disadvantages and degree of difficulty of the three temperature and moisture sensors are shown in Table 1. All of the three integrated sensors can be implemented by a common sensor with temperature and moisture sensor cores and an STM32L4R5 microcontroller with 2048 KB flash, 640 KB ram, 12-bit DACs (digital-analog convertor), and 16-bit ADCs (analog-digital convertor) from STMicroelectronics in Geneva, Switzerland.

Sensors' Architectures Linearization Technology Advantages Disadvantages
Conventional sensor ( Figure 2) LUT-based linearization Simple and easy-to-achieve Too many experiments, too much memory consumption, poor performance Current sensor ( Figure 3) Model-based linearization Practical and efficient Inflexible, performance can be improved Proposed sensor ( Figure 4) Adaptive nonlinear order regulating model-based linearization Perfect performance More computational resources

Adaptive Nonlinear Order Regulating Model-Based Nonlinearity Compensation Algorithm
We performed a total of 12 sets of tests among an adaptively-ordered nonlinearly-corrected sensor, a noncalibrated sensor, and a fixed third-order nonlinearly-corrected sensor just as in [15]. The true moisture levels of each test were fixed, and moisture was measured in a changing environment from 5 • C to 40 • C, and subsequently compared with the true moisture values. The nonlinear effects of temperature on moisture measurements are clearly observed. The nonlinear modeling and the coefficients estimation are brought out by the experimental data of moisture sensing, as listed in Table 2.
To be clear, the true moisture values in the Table 2 were measured using the weighting method after drying, which is a well-known standard method of moisture measurement [16,17].  The empirical Topp's equation describes the nonlinear relationship between the volumetric water content θ and the dielectric constant of water ε b [18]: Thus, during the measurement, we expected the measured moisture θ meas to vary with temperature according to the following relationship: where i = 1, 2, . . . , 12, and T m = 5, 10, . . . , 40 • C, and where m = 1, 2, . . . , 8. During the test, the dielectric constant of water decreases with increasing temperature [19][20][21], and so a temperature-dependent nonlinear model needs to be constructed to compensate for the effects of temperature [15,22,23]. The relationship between the fixed actual moisture value θ real and the actual water dielectric constant can be seen in Equation (3). The nonlinear relationship we constructed can be seen in Equations (4) and (5).
where θ real (i) is the real moisture of the i th test; ε b,real (i) is the real dielectric permittivity of water in general; C n (i, T m ) is temperature-related nonlinear factor; and a k (i), k = 1, 2, . . . , n are the n nonlinear coefficients to be estimated. Estimated nonlinear coefficients are applied to validate the performance of the temperature-related nonlinearity compensation. By pluggingâ k (i), k = 1, 2, . . . , n and ε b,meas (i, T m ) into Equations (3)-(5), one gets the estimation of the real moisture valuesθ real (i). For each test i, the moisture error ratios with and without nonlinearity compensation [15], expressed by R e,w (i) and R e,wo (i), are respectively defined as where m is the temperature index, and M is the total number of the temperatures. The specific calculation process can be seen in Algorithm 1: Algorithm 1 Calculation process. compute ε b,meas (i, T m ) by solving Equation (2) with the measured moisture θ meas (i, T m ) in each row of Table 2; 5: acquire ε b,real (i) by solving Equation (3) with the real moisture θ real (i) in each row of Table 2; 6: obtain C n (i, T m ) by plugging ε b,meas (i, T m ) and ε b,real (i) into Equation (4); 7: compute a k (i), k = 1, 2, . . . , n by solving Equation (5) by LS algorithm; 8: acquire R e,wo (i); 9: obtain R e,w (i); 10: determine S(i) = boolean(mean(R e,w (i)) > R e,w,tmp ); 11: if (S(i) == 0) then 12: set R e,w,tmp = mean(R e,w (i)) 13: set P = n 14: else 15: set P = n − 1 16: end if 17: until (S(i) == 1) 18: min R e,w (i) is found, P is the optimal corrected nonlinear order.
In particular, the LS algorithm in Step 4 can be represented in matrix form as follows: For the ith moisture index, Equation (4) can be rewritten in the matrix form as where the matrixes with nth nonlinear order are The least squares solution to Equation (9) iŝ whereâ i is the estimated nonlinear coefficients matrix.

Experimental Results and Discussion
Moisture error ratios under various nonlinear model-based compensation methods and the traditional methods are displayed in Figure 5. Measurement environments were kept the same throughout. It is obvious that the measurement error is very large without correction, which shows that temperature has a significant and nonlinear influence on the measurement results. In addition, measurement errors were greatly reduced when using third-order nonlinear correction. To further enhance sensor performance, we proposed and studied the adaptive order adjustable model. For the sensors studied in this article, the moisture error ratio reached a minimum under the eighth-order nonlinear compensation model, which indicated the best correction effect. Furthermore, corrections at even higher orders (ninth and above) would not yield better results as they would be overcorrected.
In the condition of moisture index i = 12, the real moisture is θ real (12) = 12.6%, the measurement error ratio without nonlinearity compensation is R e,wo (12) = 17.86%, but the error ratio with 3rd-order nonlinearity compensation is reduced to R e,w (12)| n=3 = 7.852%, while the error ratio with 8th-order nonlinearity compensation is R e,w (12)| n=8 = 1.885%. It is verified that the proposed adaptive nonlinear order regulating model-based nonlinearity compensation algorithm can obtain the optimal nonlinear order and achieve the best compensation performance. To be clear, the 3∼8th-order nonlinear coefficients are estimated and listed in Tables 3-8, respectively. Table 3. Estimated nonlinear coefficients for the 3rd nonlinear order model.  Table 4. Estimated nonlinear coefficients for the 4th nonlinear order model. 3.7140 × 10 −3 5.1586 × 10 −4 −6.0784 × 10 −6 −1.1983 × 10 −6 12

Conclusions
This paper presents an adaptive nonlinear order regulating model-based nonlinear compensation system for integrated temperature and moisture sensors. On the basis of a temperature-dependent multiorder nonlinear model for compensation correction, the measurement performance of each order nonlinear model and traditional method is compared. The experimental results verify that the nonlinear model compensation method can significantly reduce the sensing error, and the eighth order nonlinear model achieves the best measurement performance on the the integrated temperature and moisture sensor deployed in the wheatland in Zhejiang academy of agricultural sciences. Through this adaptive nonlinear compensation method, the measurement performance of the temperature and moisture sensor is greatly improved.

Conflicts of Interest:
The authors declare no conflict of interest.