Abstract
To enhance the measurement accuracy of piezoresistive pressure sensors across a wide range of pressures and temperatures, this study proposes a temperature compensation model based on a Multi-strategy Fusion Improved Dung Beetle Optimization (MSDBO) algorithm. The model addresses three critical limitations of the traditional Dung Beetle Optimizer (DBO): (1) random population initialization that hinders effective environmental exploration, (2) a linear boundary convergence factor that weakens the global-local balance, and (3) susceptibility to local optima. To overcome these challenges, First, Maximin Latin Hypercube Sampling (MLHS) ensures uniform population distribution, enhancing convergence and compensation accuracy. Second, a nonlinear boundary convergence factor improves global search capability and accelerates convergence. Third, a dual-strategy combining beetle somersault foraging with adaptive Gaussian-Cauchy mutation prevents entrapment in local optima while boosting optimization capacity. The proposed MSDBO algorithm was applied to refine the weights and thresholds in a Back-Propagation Neural Network (BPNN) temperature compensation model. Practical implementation on an STM32F407VET6-based transmitter for 0–50 MPa/−20°C−70°C piezoresistive pressure sensors: temperature compensation reduced zero drift and sensitivity drift coefficients by one and three orders of magnitude, respectively, while improving full-scale accuracy from 6.36% to 0.041%—a two-order-of-magnitude enhancement.
Keywords
Introduction
Since Smith 1 discovered the silicon piezoresistive effect in 1954, piezoresistive pressure sensors have been widely used in industrial automation, biomedicine, consumer electronics, and other fields due to their high sensitivity, small size, high reliability, and cost-effectiveness.2,3 However, silicon-based semiconductor materials are thermally sensitive in terms of resistivity, meaning that the output of pressure sensors drifts with temperature changes, particularly in high-temperature environments commonly found in the automotive, aerospace, and petroleum and petrochemical industries. Such temperature drifts can significantly reduce the measurement accuracy of piezoresistive pressure sensors, negatively impacting the system’s high-quality operation.4–6
Extensive research on temperature compensation methods for piezoresistive pressure sensors has been conducted by scholars. The existing temperature compensation methods can be divided into two types: hardware and software compensation methods.7–9 In hardware compensation methods, the interference caused by temperature variations is mitigated by modifying the hardware circuit, and zero drift and sensitivity drift are usually compensated separately. For example, De Bruyker and Puers 10 used on-chip heaters and temperature sensing electrodes to form a constant temperature control circuit, thereby eliminating the dependence of pressure sensors on ambient temperature; Wang et al. 11 successfully fabricated a piezoresistive pressure sensor through a high-temperature packaging process, achieving good accuracy and stability through the use of circuits for compensating the sensitivity and deviation temperature coefficients; Some scholars designed temperature compensation circuits using specialized temperature drift compensation chips such as MAX1452 and NSA2860 to reduce the impact of temperature change on the output accuracy of pressure sensors.12,13 Considering the shortcomings of hardware compensation methods (e.g. difficulty in adjustment, high production costs, and limited compensation accuracy), software compensation—a more flexible and convenient approach that obtains compensation values via numerical calculation and machine learning—is more widely adopted in practical applications. Ali et al. 5 proposed a polynomial-based adaptive digital temperature compensation method for the application of piezoresistive pressure sensors in automobiles. Shu et al. 14 introduced a bilinear interpolation method to compensate for pressure deviation, which improved the full-scale measurement accuracy from 21.2% to 0.1%. Wang et al. 15 proposed a temperature compensation method based on Newton interpolation and cubic spline interpolation to reduce temperature drift. These numerical calculation-based compensation methods struggle to accurately model the complex interplay between temperature and pressure. Moreover, handling a broad temperature spectrum and a wide pressure measurement range to pursue higher compensation accuracy can lead to exponential growth in data volume.
Machine learning (ML), as an advanced data analysis tool, simulates the learning process of the human brain, enabling the extraction of features, discovery of patterns, and making accurate predictions or decisions from complex data.16–18 Machine learning compensation methods can effectively solve the problems in numerical calculations mentioned above. BP neural networks, with their excellent nonlinear fitting and adaptive learning capabilities, can accurately capture nonlinear and abrupt changes based on sensor output or new environmental data changes, and automatically update strategies to suit individual sensors. However, the efficiency of temperature compensation depends on the set values of neuron connection weights and thresholds. Therefore, how to use intelligent optimization algorithms to optimize weights and thresholds for efficient temperature compensation has become a research hotspot in the field of piezoresistive pressure sensors. Wang et al. 19 proposed a backpropagation neural network method based on the Whale Optimization Algorithm to replace the traditional least squares method for temperature compensation, resulting in a significant 0.25% reduction in error. Ye et al. 20 used a genetic algorithm (GA) to remedy two deficiencies of BP neural networks, which are slow convergence and a tendency to fall into local optima, significantly improving the calibration accuracy of pressure sensors. Wu and Jiang 21 proposed a BP neural network temperature compensation model based on particle swarm optimization and the Levenberg-Marquardt algorithm (PSO-LM-BP), effectively suppressing the temperature drift of pressure sensors. Although the above algorithms can improve the performance of BP neural networks to a certain extent and reduce the influence of temperature change on pressure sensors, their application is limited by several shortcomings. Data obtained in practical applications show that when piezoresistive pressure sensors are applied in complex scenarios, such as oil wells and aircraft/spacecraft, involving nonlinear mapping of high-temperature and high-pressure parameters, these algorithms generally suffer from problems such as the tendency to fall into local optima, limited optimization accuracy, and slow convergence, making it difficult to efficiently find the optimal combination of BP neural network weights and thresholds. Consequently, the effect of temperature compensation is not satisfactory, and it fails to meet the requirements for high-precision pressure measurement.
Based on the above analysis, we developed an improved multi-strategy fusion dung beetle optimization algorithm (MSDBO) by reforming the population initialization method, adjusting the beetle position updating mechanism, and incorporating a late-stage mutation mechanism into the traditional DBO. The MSDBO-BP neural network-based temperature compensation model for piezoresistive pressure sensors effectively optimizes the BP neural network weights and thresholds while balancing global search and local exploration capabilities. This approach prevents the DBO algorithm from converging to local optima, significantly enhancing the temperature compensation accuracy of piezoresistive pressure sensors. To verify the performance of the MSDBO-BP temperature compensation model and evaluate its superiority against the traditional BP and seven other BP-based temperature compensation models optimized by meta-heuristic algorithms, we conducted multiple simulations and experiments. The results demonstrate that MSDBO-BP achieves superior temperature compensation accuracy and strong generalization ability over a broad pressure range and a wide temperature range.
Temperature drift characteristics of piezoresistive pressure sensors
The core principle of piezoresistive pressure sensors is based on the piezoresistive effect of semiconductor materials. 7 This sensor uses diffusion or ion implantation methods to fabricate four nearly equal piezoresistors on a silicon diaphragm and arranges them in a Wheatstone bridge structure, As shown in Figure 1.

Working principle of piezoresistive pressure sensor.
When the diaphragm is subjected to pressure, it undergoes elastic deformation, causing lattice structure changes in the piezoresistors located in different areas: R1 and R3 are in the compression zone, and their resistance values increase; R2 and R4 are in the tension zone, and their resistance values decrease. Under the excitation of an external voltage, the precise measurement of pressure is achieved based on the proportional relationship between the unbalanced voltage output by the bridge and the pressure. The calculation of the resistance values of each bridge arm and the output voltage Uo is shown in equations and.
Where R1, R2, R3, and R4 are the initial values of the four resistors on the bridge arms, R0 is the resistance value of the bridge arm at 0°C, ΔRP is the resistance change caused by external pressure, and ΔRT is the resistance change caused by variations in ambient temperature.
From equations and, it can be seen that a change in temperature will affect the resistance value of the bridge arm, and thus cause a temperature-related voltage offset in the output Uo.
In practical pressure measurement, the accurate response capability of a sensor to pressure changes directly depends on its sensitivity, which is a core performance indicator. For silicon material, 1 + 2 μ ≪ πE, so the sensor sensitivity coefficient K is calculated as shown in the equation 22 :
where μ is the Poisson’s coefficient of the silicon material, π is the longitudinal piezoresistive coefficient of the silicon material, E is the elastic modulus of the material, Z and V are constants related to the concentrations of the silicon material and impurities, respectively, and T is the ambient temperature.
It can be seen from equation that the sensitivity K of the pressure sensor decreases with the increase of temperature T, thereby resulting in a decrease in the output accuracy of the sensor. In practice, the sensitivity coefficient is defined as the ratio of the change in output voltage to the change in pressure, which is typically determined through experimental measurement of this ratio. Sensor accuracy is susceptible to various factors, including uneven doping of piezoresistors, process deviations in Wheatstone bridges, mechanical stress, electromagnetic interference, and long-term aging. Among these influencing factors, once the manufacturing process and external mechanical conditions are fixed, temperature variations during practical operation will cause changes in the piezoresistive coefficient and elastic modulus of silicon materials, making temperature the most significant factor affecting accuracy. Therefore, temperature compensation measures need to be taken to ensure the accurate output of data in a wide-temperature environment.
MSDBO-BP temperature compensation model
Temperature compensation model based on BP neural network
The BP neural network is a three-layer feedforward architecture trained using the error backpropagation algorithm, consisting of input, hidden, and output layers. With high adaptability, self-learning ability, and fault tolerance, the network effectively solves intricate nonlinear mapping problems. The range of the number of nodes in the hidden layer can be determined according to the empirical formula

Temperature compensation model based on BP neural network for piezoresistive pressure sensors.
In this paper, the activation functions f and ϕ are the tansig function and purelin pure linear function respectively. The L-M algorithm is used to adjust the weights and thresholds layer by layer in reverse order to gradually reduce the mean square error (MSE) between the standard pressure P″ and the post-compensation pressure value P′ until the preset stopping condition is met. The calculation formula for MSE is shown in equation:
As seen in equation, the weight values
DBO algorithm
The DBO algorithm is a metaheuristic algorithm proposed by Xue and Shen 23 in 2022, which divides the dung beetles in a beetle population into five categories based on behaviors: ball rolling, dancing, breeding, foraging, and stealing. Its stability and simplicity provide advantages over other metaheuristic optimization algorithms.
Position updating of ball rolling dung beetles
When there are no obstacles on the road, a ball-rolling beetle utilizes the sun to navigate, ensuring that the dung ball rolls in a straight path. Natural factors such as light intensity and wind can influence its travel route. The position update can be calculated using equation:
where t is the current iteration count, and x i (t) represents the position of the i-th beetle in the t-th iteration, λ is a natural coefficient assigned a value of −1 or 1. A random number η∈ (0, 1) is introduced to control the switching of the dung beetle’s behavioral modes: when η < 0.9, λ = 1, indicating that the natural environment does not affect the original direction, and the dung beetle continues rolling the ball in the initial direction; when η ≥ 0.9, λ = −1, meaning the dung beetle encounters an obstacle and performs a dancing behavior, resulting in a significant change in direction. a is the deflection coefficient, b is a constant, according to Ref., 23 a∈(0,0.2), b∈(0,1) denotes the optimal parameter range for the DBO algorithm, which can accurately balance the exploration and exploitation capabilities of the algorithm. It effectively avoids problems such as search oscillation, convergence stagnation, or trapping in local optima caused by parameter values deviating from this range, thereby providing a fundamental guarantee for the stable and efficient optimization of the DBO algorithm. X worst is the global worst position, and Δx is used to simulate variations in light intensity.
Position updating of dancing dung beetles
When a dung beetle encounters an obstacle that blocks its path, it relocates itself to find a new route before continuing to roll the dung ball. The position update can be calculated using equation:
where θ is the deflection angle within the range (0,π])|x i (t)-x i (t–1)| is the position difference of the i-th beetle between the t-th and (t + 1)-th iterations. It can be observed that the position update of a dung beetle is closely related to both current and historical information.
Position updating of dung beetle egg ball
For progeny security, dung beetles select optimal position sites. The boundary selection strategy of the DBO algorithm can be used to model the spawning area of female dung beetles. As shown in Figure 3.

Conceptual model of boundary selection strategy.
The orange dot X better represents the local optimal position of the current beetle, while the black dot represents the brooding ball. The area between the lower limit Lb and upper limit Ub of the BP weight threshold is the initial spawning area of the female beetle. The boundary convergence factor R changes with the increase in iteration count t, updating the lower limit Lbbetter and upper limit Ubbetter of the spawning area. The mathematical expression for the spawning area is shown in equation:
Once the spawning area is identified, the female beetle lays eggs inside a brood ball in that specific area, and the egg ball’s coordinates are then updated according to equation:
where Fi(t) is the position of the i-th brooding ball at the t-th iteration,
Position updating of foraging dung beetles
To simulate the foraging behavior of young dung beetles after hatching from egg balls, the DBO algorithm establishes the optimal foraging area. The definition of the area boundary and the position update of young dung beetles are given in equation:
where X
best
represents the global optimal foraging location, Lbbest and Ubbest respectively represent the lower and upper limits of the optimal foraging area, B1 is a random number that follows a normal distribution, and
Position updating of thief dung beetles
In the beetle population, some thief beetles steal food. As seen in equation, X best is the global optimal foraging location, and the DBO algorithm takes X best as the best place for the thief beetle to steal food. The position update of the thief beetle can be calculated using equation:
where
From the iterative optimization processes of the five types of beetle individuals described above, the optimization ability of the DBO algorithm depends on the initial population position, position updating parameters, and the quality of individual positions. The randomness of DBO population initialization and the fixed iteration order can easily lead to the following undesirable situation: the algorithm fails to achieve sufficient global exploration and gets stuck in local optima during the iteration process. When DBO is used to deal with complex nonlinear relationships in the wide temperature range of piezoresistive pressure sensors, it may only find a locally optimal combination of weight and threshold values, failing to provide a high-quality temperature compensation effect. Based on this analysis, we improved the DBO algorithm by incorporating a multi-strategy fusion approach, improving global search ability by changing the population initialization method, adjusting the beetle position updating mechanism, and adding a mutation mechanism in the later stage of iteration.
DBO algorithm multi-strategy fusion improved DBO optimization algorithm
Improving beetle position initialization using MLHDS
The traditional DBO algorithm generates a random number to initialize the population position. As a result, the quality inconsistency between the initial beetle positions prevents the algorithm from traversing all positions in the solution space, degrading optimization performance and affecting convergence speed. Latin hypercube sampling (LHS) is an effective method for simulating random sampling from the distribution of multidimensional parameters, characterized by good uniformity, a decoupling effect, and diversity. 24 However, due to the randomness of the sample sequence, sample points are prone to linear or quasi-linear distribution, resulting in unsatisfactory spatial filling results. To address this issue, this paper introduces the concept of maximum and minimum values for optimization on the basis of LHS. Taking a 5 × 5 space as an example, the process of selecting sample points is as follows:
1) As shown in Figure 4(a) Step 1, when the first sample point is randomly selected from the P1-th point of the (i = 4)-th row, the distances between the P1-th point and the remaining rows in the second column (which are d((1,2), P1), d((2,2), P1), d((3,2), P1) and d((5,2), P1)) are calculated. The (i = 1)-th row corresponding to the maximum distance value d((1,2), P1) is selected to generate the second sample point P2.
2) As shown in Figure 4(b) Step 2, since the existing points P1 and P2 occupy rows No.4 and No.1 respectively, the distances between points P1 and P2 and the remaining rows (No.2, No.3, No.5) in column 3 (which are d((2,3), P1), d((3,3), P1), d((5,3), P1), d((2,3), P2), d((3,3), P2) and d((5,3), P2)) are first calculated, and then d((2,3), P1), and d((2,3), P2) are compared to select the minimum distance value d((2,3), P2) as the characteristic distance of the second row. Similarly, the characteristic distances of the third and fifth rows are determined separately (indicated by yellow lines). Finally, the characteristic distances of all rows are compared, and the (i = 5)-th row corresponding to the maximum characteristic distance value is selected to generate the third sample point P3.
3) As shown in Figure 4(c) Step 3, the fourth sample point P4 is generated using the method in step 2).
4) As shown in Figure 4(d) Step 4, in the fifth column, only one row (i = 2) remains to generate the fifth sample pointP5.

Process of sample point selection using MLHS: (a) Step 1, (b) Step 2, (c) Step 3 and (d) Step 4.
Assuming the initial positions of 500 dung beetles in a two-dimensional space are determined as a result of position initialization, Figure 5 presents the point distribution maps and three-dimensional histograms of the position initialization results obtained using the proposed MLHS method, the Rand method, and the LHS method. Evidently, the distribution of sample points generated by the MLHS method is more dispersed compared to those produced by the other two methods, striking a good balance between space-filling and uniformity. Consequently, the dung beetle population generated through this method exhibits greater uniformity and better spatial coverage, enhancing the convergence and accuracy of the temperature compensation algorithm.

Comparison of sample points generated by Random, LHS, and MLHS: (a)the random method, (b) the LHS method, (c) the MLHS method, and (d) histograms of the sample points.
Improving the boundary convergence factor R
As seen in equation, the boundary convergence factor R of the traditional DBO algorithm decreases linearly with the increase in iteration count t, causing the spawning area to shrink uniformly. This linear change is not only unfavorable for female dung beetles to fully explore the solution space in the early stage, but also significantly slows down local exploration in the later stage. To address this issue, this paper uses the sigmoid function to improve the boundary factor R. After this enhancement, the position updating of the beetle egg ball is conducted as shown in equation. The aim is to improve the global exploration ability while maintaining good balance between local search speed and accuracy.
where k represents the curve steepness of the improved boundary convergence factor R’, and Tmax is the maximum number of iterations. Experimental results show that the best performance can be achieved when the value of k is set to 0.1. The iteration curves of the original boundary convergence factor R and the improved boundary convergence factor R’ are shown in Figure 6.

Iteration curves of original and improved boundary convergence factors.
It can be seen from Figure 6 that after replacing the boundary convergence factor R with R’, R’ decreases at a comparatively slower rate in the early stages of iteration. This allows female beetles to expand their search for egg-laying areas, thereby improving global exploration ability and increasing the likelihood of finding the optimal solution. In the middle stage of iteration, the boundary convergence factor R’ rapidly decreases to enhance local exploration ability, thus accelerating the convergence speed of the algorithm. In the later stages of iteration, R’ is maintained at a low value to ensure the stability of algorithm convergence.
Improving position updating of foraging beetles using somersault strategy
As seen in equation, when the optimal foraging area is determined, the small beetle population quickly approaches the global optimal foraging position X best by randomly walking in a straight line. This significantly accelerates convergence, but insufficient exploration of surrounding areas can easily lead the algorithm to local optima. Inspired by the foraging behavior of manta rays, 25 this paper introduces somersault foraging into the behavioral repertoire of dung beetles. To address this issue, in addition to walking in a straight line toward the global optimal foraging position X best , a dung beetle can also use X best as a fulcrum to gradually approach the global optimal foraging position through back-and-forth somersaulting. After this improvement, the position update of a foraging dung beetle can be calculated using equation:
where S is the somersault factor, and r1, r2, and r3 are random numbers in the range [0,1]. The somersault foraging behavior of dung beetles is illustrated in Figure 7.

Schematic diagram of somersault foraging behavior of dung beetles.
As seen in equation and Figure 7, when a small dung beetle performs somersault foraging, its new position is always generated at a point between its current position and the symmetric point of its current position concerning the globally optimal foraging position X best . The search area decreases as the distance between the beetle and the current global optimal foraging position X best shortens. By combining the original foraging behavior and somersaulting, the foraging diversity and convergence of the small dung beetle are enhanced, helping the algorithm escape local optima and find the optimal combination of weight and threshold values for the BP neural network.
Adaptive Gaussian-Cauchy perturbation mutation strategy
Since the DBO algorithm follows a serial iteration process, if it falls into a locally optimal solution in the early stage, beetle individuals will gradually converge toward this solution in later stages, resulting in premature convergence and low optimization efficiency. To avoid this situation, this mutation strategy to modify the optimal individual position after the iteration of the entire beetle population is completed. As shown in Figure 8, the Cauchy distribution has a higher probability of producing a two-wing distribution compared to the Gaussian distribution. This means the former is more likely to generate a wider range of random numbers that spread farther from the zero point. Therefore, the Cauchy distribution is more suitable for the early stages of iteration, as it allows beetle individuals to search the optimal area with large step sizes, increasing the probability of escaping local optima. By contrast, the Gaussian distribution is more likely to generate random numbers near zero, making it suitable for later stages. It allows beetle individuals to explore the optimal area with small steps, thus quickly converging to the optimal value. Based on the above analysis, this paper introduces a mutation operator with an adaptive dynamic weight coefficient to balance the abilities of the two distributions, ensuring a balanced trade-off between global search and local exploration abilities. After this improvement, the position update is conducted as shown in the equation:

Gaussian distribution and Cauchy distribution.
where xbest(t) represents the current optimal position of the beetle individual, xnew(t) represents the individual position after mutation, and xnewbest(t) represents the final optimal position of the beetle individual, f (xbest) and f (x i ) are the optimal and current position fitness values, respectively, σ is the standard deviation of Cauchy-Gaussian mutation, while Gauss(0,σ 2 ) and Cauchy(0,σ 2 ) are random numbers respectively following Gaussian and Cauchy distributions, γ1 and γ2 are the dynamic weight coefficients of the two distributions that are adaptively adjusted with the iteration count. The formulas for calculating γ1 and γ2 are shown in:
As can be seen from equations and, the best beetle individual is selected for mutation in the optimization process of the algorithm, enabling it to escape local optima. In the early stage of iteration, the Cauchy dynamic weight coefficient γ2 is comparatively larger, so the algorithm makes use of the strong perturbation ability of Cauchy mutation to explore the entire search space. In the later stage of iteration, the Gaussian weight coefficient γ1 increases, so the algorithm relies on Gaussian mutation to explore the local area more finely. To guarantee better optimization capability of the algorithm after disturbance, this paper proposes to introduce greedy rules. Thus, the fitness values before and after mutation disturbance are compared before deciding whether to update the optimal position.
After the above improvement strategies are implemented, the proposed MSDBO algorithm is obtained. The flowchart of MSDBO is shown in Figure 9.

Flowchart of MSDBO algorithm.
Construction of temperature compensation model for MSDBO-BP
The MSDBO algorithm from Section 3.3 is used to find the optimal combination of weights and thresholds in the BP temperature compensation model. The optimized parameter values are then input into the BP model to achieve temperature compensation for the pressure sensor. The algorithm flow is shown in Figure 10, with the specific steps as follows:
1) Collect experimental data. Obtain the measured sensor pressure P and temperature T through calibration experiments, which serve as input for the MSDBO-BP model.
2) Data preprocessing. To avoid issues such as large computational load and failure to converge due to inconsistent units of input data, normalize the dataset within the range [–1, 1] according to equation.
3) Optimize the BP temperature compensation model using the MSDBO algorithm. Initialize the MSDBO algorithm parameters, including population size, maximum iteration count, and optimization range. Use the mean squared error between the actual pressure value and the predicted value as the fitness function for the algorithm optimization. Continue until the maximum iteration count Tmax is reached, at which point the optimal value is output as the optimal weight threshold combination for the BP temperature compensation model, forming the MSDBO-BP temperature compensation model.
4) Model training. Randomly divide the data into a training set and a test set in an 8:2 ratio, and train the MSDBO-BP temperature compensation model for 1000 iterations. Apply the inverse normalization equation to the trained output values to obtain the optimal weight threshold combination and the pressure values after intelligent compensation.

Flowchart of MSDBO-BP algorithm.
Experimental study and result analysis
The MSDBO-BP temperature compensation algorithm is implemented through a hardware system. First, based on the optimized BP neural network weights and thresholds derived from Figures 9 and 10, the FPU unit of the STM32F407VET6 chip is enabled in the MDK compilation environment. DSP library files and related header files are added, and a forward propagation program for the BP neural network is written. Second, the temperature and pressure values at the site are collected in real-time using the temperature-pressure integrated sensor designed in this paper. After filtering, amplification, and sampling hold circuits, the data is input into the STM32F407VET6 microcontroller. After conversion by the internal high-precision ADC, the MSDBO-BP algorithm is executed for intelligent compensation. Finally, the compensated pressure values are output in real-time via RS485. The hardware architecture of this system is shown in Figure 11.

System hardware architecture.
Calibration experiment
The sensor used in the experiment is a temperature-pressure integrated sensor designed for this paper, consisting of a PT100 temperature sensor and a CYX19–32 series oil-filled core from Tianshui Huatian. The sensor operates on a power supply of 15–28 VDC, has a measurement range of 0–50 MPa and can function stably within a wide temperature range of −20°C to 70°C. The experimental setup includes a RIGOL power supply, a host computer, a Druck PACE6000 modular pressure controller with an accuracy of 0.02% FS, and an ESPEC high-temperature and low-temperature test chamber, which simulate industrial site pressure and temperature changes, respectively. The experimental equipment connections are shown in Figure 12.

Experimental platform of calibration experiment.
The testing process starts at −20°C, with each temperature point increasing by 10°C, and each temperature point is maintained for 2 h until the temperature reaches 70°C. To avoid hysteresis errors, within the 0–50 MPa range, the pressure is adjusted from low to high in the same direction, with one pressure calibration point selected every 2 MPa, totaling 26 pressure values. The experimental data consists of 260 input-output pairs, as shown in Table 1.
Experimental data before temperature compensation.
The characteristic curves of the piezoresistive pressure sensor before temperature compensation can be plotted based on the experimental data obtained at different temperatures and pressures, as shown in Figure 13.

Characteristic curves and graphs of the piezoresistive pressure sensor before temperature compensation: (a) pressure characteristic curve, (b) temperature characteristic curve, (c) output relative error characteristic, and (d) quoted error surface.
To quantitatively evaluate the influence of temperature variation on pressure sensors, this paper introduces the indicators of zero drift coefficient α0, sensitivity drift coefficient
where |P0|max is the maximum absolute change of zero pressure within the temperature variation range, PFS is the pressure output value at the full scale of the pressure sensor, ΔT is the variation range of the sensor’s working temperature, Pmax and Pmin are respectively the maximum and minimum values of the pressure output obtained under maximum temperature drift conditions, and |ΔP|max is the maximum absolute error between the output pressure and the standard pressure.
As seen in Figure 13(a), the input-output curves of the sensor at different temperatures are distributed across a band, rather than overlapping, indicating that pressure is influenced by temperature variations. From Figure 13(b), it can be observed that the output value of the pressure sensor, obtained at different pressure points, drifts downward as temperature increases. This drift is most pronounced at 50 MPa, where the slope is the largest. In addition, Figure 13(c) shows that the maximum relative error in the output of the piezoresistive pressure sensor is as large as 3.33 MPa when compared to the reference temperature of 20°C. According to Table 1, PFS is 50 MPa, ΔT is 90°C, and |P0|max is 0.052 MPa. The largest temperature drift occurs when the sensor is subjected to a pressure of 50 MPa. The output pressure Pmax is the largest when the temperature is −20°C (which is 53.04 MPa), and the output pressure Pmin is the lowest when the temperature is 70°C (which is 46.82 MPa). By substituting these values into equations and for calculation, the zero drift coefficient α 0 = 1.15 ×10−5 and sensitivity drift coefficient α s = 1.38 ×10−3 can be obtained. It can be concluded that significant temperature drift is observed in this piezoresistive pressure sensor. When T is 70°C and P is 50 MPa, the pressure sensor has a maximum absolute error |ΔP|max of 3.18 MPa. The full-scale accuracyδ = 6.36%, calculated using equation, indicates that temperature drift seriously affects the measurement accuracy of the piezoresistive pressure sensor.
Analysis of temperature compensation results obtained from the MSDBO-BP model
To verify the effectiveness of the MSDBO-BP presented in this study, its compensation performance was compared with that of the traditional BP temperature compensation model, five different meta-heuristic algorithms including the Dung Beetle Optimizer (DBO), Particle Swarm Optimization (PSO), 27 Gray Wolf Optimizer Algorithm (GWO), 28 Whale Optimization Algorithm (WOA), 29 and Pelican Optimization Algorithm, 30 and the BP temperature compensation models based on two improved dung beetle optimization algorithms (MSADBO and MIDBO) proposed by other scholars.31,32 The above eight models are referred to as BP, DBO-BP, PSO-BP, GWO-BP, WOA-BP, POA-BP, MSADBO-BP, and MIDBO-BP, respectively. The parameter settings for each algorithm are provided in Table 2, with a population size of N = 30 and a maximum iteration count of M = 30. The fitness function of each algorithm is MSE, which quantifies the difference between the standard pressure P″ and the post-compensation pressure P′.
Parameter settings for each algorithm.
Each algorithm was trained 20 times on the training set, and a fitness curve was randomly selected as shown in Figure 14. It can be observed that MSDBO exhibits the best optimization ability and fastest convergence.

Iteration curves of different algorithms.
Each model’s efficacy was evaluated via MSE, root mean square error RMSE, mean absolute error MAE, maximum error Emax, minimum error Emin, and absolute quoted error |CE|, the calculation of the quoted error is shown in Equation. 33 The deviation between the model-predicted pressure values and the calibrated pressure values is measured by MSE and MAE. MAE quantifies the mean absolute deviation of pressure predictions from standard pressures, and |CE| is used to evaluate the performance of the sensor. Tables 3 and 4 detail the algorithm compensation outcomes from training and testing data. The performance comparison of different models on the test set is shown in Figure 15.
Compensation results of each algorithm on the training set.
The bold values in Table 3 represent the compensation results of the MSDBO-BP algorithm proposed in this paper on the training set. These values are bolded to highlight the superiority of the proposed algorithm.
Compensation results of each algorithm on the test set.
The bold values in Table 4 represent the compensation results of the MSDBO-BP algorithm proposed in this paper on the test set. These values are bolded to highlight the superiority of the proposed algorithm.

Algorithm performance comparison (test set).
As shown in Tables 3 and 4, the proposed MSDBO-BP model outperforms the other eight models: The post-compensation values of MSE, RMSE, MAE and Emax obtained on the training and test sets are the lowest compared with those of other models, the average error MAE is 2.96 × 10–3 MPa, and the maximum error Emax is only 2.01 × 10−2 MPa, indicating excellent compensation performance.
The calculated values of the mean quoted error |CE|ave, maximum quoted error |CE|max, and minimum quoted error |CE|min of the evaluated algorithms are shown in Table 5 with corresponding quoted error surfaces in Figure 16.
Quoted errors of the entire dataset after compensation.
The bold values in Table 5 represent the Quoted errors of the MSDBO-BP algorithm proposed in this paper. These values are bolded to highlight the superiority of the proposed algorithm.

Quoted error surfaces of pressure resistive sensor obtained under the temperature compensation of different temperature compensation models: (a) BP, (b) DBO-BP, (c) PSO-BP, (d) GWO-BP, (e) WOA-BP, (f) POA-BP, (g) MSADBO-BP, (h) MIDBO-BP, and (i) MSDBO-BP.
As seen in Table 5 and Figure 16, the piezoresistive pressure sensor yields a mean quoted error |CE|ave of 0.076% and a maximum quoted error |CE|max of 0.42% when the proposed MSDBO-BP model is used to provide temperature compensation, both of which are lower than those of the eight other models. In addition, the quoted error surface yielded by MSDBO-BP is flatter than those of other models, especially in high temperatures of 60°C–70°C, indicating that the compensation accuracy of MSDBO-BP is significantly better than those of other algorithms.
As shown in Figure 17, the pressure-temperature characteristic curves of the piezoresistive pressure sensor used in this experiment significantly improve after compensation by the proposed MSDBO-BP model. A comparison with Figure 13(a) and (b) demonstrates that the model effectively suppresses the negative impact of temperature on the sensor’s output characteristics.

Characteristic curves of piezoresistive pressure sensor under temperature compensation of MSDBO-BP: (a) pressure characteristic curve and (b) temperature characteristic curve.
The calculation results indicate that after temperature compensation, the zero drift coefficient α 0 and sensitivity drift coefficient α s are 4.24 × 10−6 and 4.63 × 10−6, respectively, representing improvements of one and three orders of magnitude respectively (before temperature compensation, the zero drift coefficient α 0 and sensitivity drift coefficient α s are 1.15 × 10−5 and 1.38 × 10−3, respectively), and accuracy δ improves from 6.36% to 0.041%, representing a two-order-of-magnitude increase. A series of experiments demonstrate that the MSDBO-BP compensation model proposed in this paper achieves high compensation accuracy across a large pressure range and a wide temperature range, and it is easily implementable in practical applications. It is particularly noted that the core advantage of the MSDBO-BP model lies in its independence from the structural parameters of specific sensors. Through the nonlinear fitting capability of the BP neural network and the global optimization ability of MSDBO, it adaptively learns the temperature drift characteristics of different sensors, thus possessing excellent versatility for other types of piezoresistive pressure sensors as well as within a wider pressure and temperature range.
Conclusion
(1) The introduction of the maximin Latin Hypercube sampling method, improved convergence factor, somersault foraging behavior of dung beetles, and adaptive Gaussian-Cauchy perturbation mutation strategy, enhances population diversity, achieves a good balance between global search and local exploration abilities, and solves some problems of the DBO algorithm such as falling into local optima during the optimization process.
(2) Leveraging MSDBO to fine-tune the weights and thresholds within the BP significantly enhances the temperature compensation model for pressure sensors dealing with a wide pressure and temperature range, boosting both its accuracy and generalization ability. A comparison was made between the model proposed in this paper and eight other temperature compensation models, namely BP, DBO-BP, PSO-BP, GWO-BP, WOA-BP, POA-BP, MSADBO-BP, and MIDBO-BP. The results indicate that the proposed model exhibits more effective compensation. After temperature compensation provided by MSDBO-BP, the zero drift and sensitivity drift coefficients of the sample piezoresistive pressure sensor are reduced by one and three orders of magnitude, respectively, and the full-scale accuracy is improved by two orders of magnitude This indicates that the temperature drift is effectively suppressed, and the measurement accuracy is significantly improved.
(3) The successful implementation of the proposed temperature compensation model in a piezoresistive pressure sensor transmitter based on STM32F407VET6 and the performance of the model in the following tests demonstrate that the proposed model can reduce hardware compensation cost and improve the measurement accuracy. Future research can further apply artificial intelligence and machine learning to the intelligent temperature compensation of pressure sensors, so as to improve its compensation accuracy and robustness.
Footnotes
Ethical considerations
This article does not contain any studies with human participants or animals performed by any of the authors. Therefore, no ethical approval was required.
Consent to participate
This study does not involve human participants, human data, or human tissue. No consent to participate was required.
Funding
The authors disclosed receipt of the following financial support for the research, authorship, and/or publication of this article: This work was supported by Xi'an Science and Technology Program Project under grant number 2024JH-ZCLGG-0032; Yulin Science and Technology Program Project under grant 2024-CXY-191, 2024-CXY-158; and Shaanxi Key Research and Development Program under grant number 2025CY-YBXM-168.
Declaration of conflicting interests
The authors declared no potential conflicts of interest with respect to the research, authorship, and/or publication of this article.
Data availability statement
The data in this article will be shared upon reasonable request.
