5. Algorithm Design
The software algorithm is designed to enhance the accuracy of pressure sensing and the reliability of IoT transmission, encompassing three key components: pressure data pre-processing, optimization of IoT communication protocols, and a battery safety warning model [
7].
Based on electrochemical kinetics and elastic mechanics theory, a multi-field coupled pressure evolution model is established, with the core expression as follows:
Here, represents the internal pressure of the battery at time t, denotes the initial pressure, and , , and k3 are the pressure coupling coefficients corresponding to capacity decay, temperature change, and structural strain, respectively. signifies the capacity loss due to aging, stands for temperature, and represents the structural strain of the battery pole piece. The improved Kalman filter (EKF) algorithm is used to denoise multi-source sensor data and improve pressure monitoring accuracy. The core iterative formula is as follows:
State prediction equation:
Covariance prediction equation:
State Upgrading Function:
Covariance update equation:
Here, is the filtered pressure state value at k time, is the original observed value of the sensor, A is the state transition matrix, H is the observation matrix, Q is the process noise covariance, R is the observation noise covariance, and I is the identity matrix.
The NSGA-II multi-objective optimization algorithm is used to achieve balanced control of safety, service life, and energy consumption. In future work, the NSGA-II will be fully illustrated; the current objective functions and constraint conditions are as follows:
Optimization objectives: Pressure approaching optimal threshold:
Minimizing capacity attenuation rate:
Minimizing control energy consumption:
Constraint conditions: Pressure safety threshold:
Charging/discharging current limit:
Temperature safety range:
A. Pre-process Algorithm for Pressure Sensing Data
The raw pressure data collected by the sensor may contain errors due to environmental temperature and electromagnetic interference, necessitating preprocessing [
6,
8]. The sensor data preprocessing process can be completed through the following three steps:
(1) Outlier removal: Set the effective pressure range of the battery at 0–100 kPa and remove data outside this range using a threshold method to avoid interference from invalid data. (2) Noise reduction processing: First, employ sliding average filtering (with a window size of N = 10) to eliminate random interference. Then, use wavelet denoising (db4 wavelet, three-level decomposition) to filter out high-frequency noise and reduce data fluctuations. (3) Temperature compensation calibration: The operating temperature of the battery can affect the accuracy of the sensor, so a temperature compensation model is established—collecting sensor output values at different temperatures (−20∼80 °C) and under standard pressure, fitting a compensation formula, and combining the real-time temperature collected by the temperature chip to correct the pressure value, eliminating temperature drift errors.
The flow of the algorithm is as follows:
===================== Main Flow ======================
Step 1: Loading Primary Data (Pressure and Temperature):
raw_pressure = LOAD_RAW_PRESSURE_DATA()
real_time_temp = LOAD_REAL_TIME_TEMP()
Step 2: Offline fitting of temperature compensation model (only needs to be executed once, for subsequent real-time use):
temp_calib_dataset = LOAD_CALIB_TEMP_DATA()
pressure_calib_dataset = LOAD_CALIB_PRESSURE_DATA()
compensation_model = fit_compensation_model(temp_calib_dataset, pressure_calib_dataset)
Step 3: Real-time data processing process:
valid_pressure = remove_outliers(raw_pressure)
smoothed_pressure = sliding_average_filter(valid_pressure)
denoised_pressure = wavelet_denoise(smoothed_pressure)
final_pressure = temperature_compensation (denoised_pressure, real_time_temp, compensation_model)
B. Optimization of IOT protocol
To adapt to battery-monitoring scenarios, the MQTT lightweight communication protocol was optimized to ensure low power consumption and high data-transmission reliability. (1) Data Frame Design: Design a fixed-length lightweight data frame containing five fields—battery number (2 bytes), pressure value (4 bytes), temperature value (2 bytes), warning level (1 byte), and checksum (1 byte)—to reduce data transmission volume. (2) Retransmission mechanism: When the gateway does not receive a response signal within 500 ms, the node retransmits the data, with a maximum of three retransmissions to reduce the packet loss rate. (3) Low-power scheduling: In normal battery conditions, the node collects data once every 5 s; in abnormal conditions, it collects data once every second, balancing sensing timeliness and power consumption. The main process design is as follows:
=====================The main process is as follows:=========
Step 1: Initialize the node (taking a single battery node as an example, expandable to multiple nodes) target_battery_id = “BAT001”: //Target battery number
INITIALIZE_SENSOR() //Initialize pressure/temperature sensor
INITIALIZE_COMMUNICATION() //Initialize communication module
(such as LoRa/Bluetooth)
6. Experimental Assessment
In this section, a factual experiment is carried out to verify the system. The experimental results are shown in
Figure 2,
Figure 3,
Figure 4,
Figure 5 and
Figure 6. We define the connotation of accuracy for the sensor layer, signal processing layer and early warning model layer:
Sensor layer: Accuracy refers to the measurement accuracy of the physical sensor, characterized by the relative error between the measured value and the standard reference value.
Signal processing/estimation layer: Accuracy refers to the estimation accuracy after denoising and compensation, characterized by the error between the estimated pressure value and the true value.
Early warning model layer: Accuracy refers to the classification accuracy of the warning model for different risk levels, characterized by the overall consistency between the predicted warning level and the actual risk level.
Figure 2.
System Prototype.
Figure 2.
System Prototype.
A. Experimental Environment Construction
To verify system performance, a complete experimental platform (as shown in the figure below) is built, which includes three parts:
(1) Battery testing platform: 18,650 lithium battery modules, battery testing system (realizing charging and discharging, overcharging/overheating simulation);
(2) Sensor transmission platform: three IoT pressure sensing nodes, one LoRa/WiFi 6 gateway, standard pressure calibrator (accuracy ± 0.05 kPa), network analyzer;
(3) Monitoring platform: cloud server (8-core 16 GB), monitoring APP and PC end;
(4) Evaluation indicators: detection accuracy, response delay, transmission packet loss rate, end-to-end delay, warning accuracy, the system power consumption.
B. Calibration and Uncertainty
(1) Number of Repetitions per Calibration Point
During the calibration process, the pressure range was set to 0–50 kPa, which is consistent with the actual working range of the IoT battery protection system. For each calibration point (with an interval of 5 kPa, totaling 11 points: 0, 5, 10, …, 50 kPa), six independent repeated measurements were performed to reduce random errors caused by manual operations and environmental fluctuations. All repeated measurement data are retained in the article for verification.
(2) Loading/Unloading Sequence and Hysteresis
A standard loading–unloading cycle sequence was adopted for calibration to evaluate the hysteresis characteristics of the MEMS pressure sensor: (1) Loading phase: The pressure was gradually increased from 0 kPa to 50 kPa at a rate of 2 kPa/s, and the sensor output was recorded after stabilizing for 3 s at each calibration point. (2) Unloading phase: The pressure was gradually decreased from 50 kPa to 0 kPa at the same rate (2 kPa/s), and the sensor output was recorded under the same stabilization condition. Hysteresis is defined as the maximum difference between the loading and unloading output values at the same pressure point, and the calculation result (≤0.03 kPa) has been included in the new subsection to reflect the stability of the sensor.
(3) Fitting Model and Residuals
To establish the correlation between the actual pressure (ground truth, provided by a reference calibrator with an accuracy of ±0.05 kPa) and the sensor output voltage, a linear fitting model (y = kx + b, where y is the actual pressure, x is the sensor output voltage, k is the sensitivity coefficient, and b is the offset) was adopted after verifying the linearity of the sensor (linearity R2 > 0.999). The fitting parameters (k = 2.35 kPa/mV, b = −0.012 kPa) were calculated using the least squares method. Residuals were obtained by subtracting the fitted pressure values from the actual measured pressure values; the maximum residual is ≤0.02 kPa, and the root mean square error (RMSE) is 0.011 kPa. All the above data have been reported in the new subsection to demonstrate the fitting accuracy.
(4) Expanded Uncertainty (Type A and Type B Components)
The expanded uncertainty of the calibration results was evaluated in accordance with the Guide to the Expression of Uncertainty in Measurement (GUM), including both Type A and Type B uncertainty components:
Type A uncertainty: Caused by random errors of repeated measurements, calculated as the standard deviation of six repeated measurements at each calibration point, with an average value of u_A = 0.008 kPa.
Type B uncertainty: Derived from the uncertainty of the reference calibrator (±0.05 kPa, uniformly distributed, u_ref = 0.05/√3 ≈ 0.0289 kPa) and the temperature drift of the sensor (negligible under constant temperature conditions, u_temp = 0.005 kPa). The combined Type B uncertainty was calculated as u_B = √(u_ref2 + u_temp2) ≈ 0.0294 kPa.
The combined standard uncertainty is u_c = √(u_A2 + u_B2) ≈ 0.0305 kPa. Taking the coverage factor k = 2 (confidence level 95%), the expanded uncertainty is U = k × u_c ≈ 0.061 kPa. This result has been clearly stated in the new subsection.
(5) Temperature Conditions During Calibration
To avoid the impact of temperature on sensor performance and calibration accuracy, all calibration experiments were conducted in a constant-temperature chamber, with the ambient temperature controlled at (25 ± 1) °C. The temperature change was monitored in real time to ensure that the temperature fluctuation during calibration did not exceed ±0.5 °C. This temperature control condition has been supplemented to the new subsection to ensure the reliability of the calibration results.
C. Communication Configuration
The specific parameters are as follows:
LoRa Module Configuration: Spreading Factor (SF) = 12, Bandwidth (BW) = 125 kHz, Coding Rate (CR) = 4/5, Transmission Power (Tx Power) = 17 dBm, antenna type is omnidirectional ceramic antenna (gain 3 dBi), communication frequency is 433 MHz, frame interval is 100 ms, maximum retransmission times is three.
Wi-Fi Module Configuration: Adopting 802.11b/g/n protocol, operating frequency band is 2.4 GHz, channel 6 is selected, transmission rate is fixed at 11 Mbps, encryption method is WPA2-PSK, transmission power is 15 dBm, antenna gain is 2 dBi, connection timeout is 500 ms.
MQTT Protocol Configuration: MQTT version 3.1.1 is adopted, client ID is “IoT_ Battery_001”, Broker address is Alibaba Cloud public MQTT server, QoS level is 1 (at least once delivery), payload size is 64 bytes, heartbeat cycle is 60 s, reconnection interval is 10 s.
CoAP Protocol Configuration: CoAP version 13 is adopted, operating mode is Non-Confirmable (NON), port is 5683, payload format is JSON, data transmission cycle is 500 ms, maximum retransmission times is two, timeout is 200 ms.
D. Experimental Results and Analysis
The experiment is divided into three parts: sensor performance testing, IoT communication performance testing, and overall system performance verification. Each indicator is tested three times, and the average value is taken as the final result to ensure data reliability. From the following aspects, we evaluated the experiment.
Sensor layer: Added MAE (kPa), RMSE (kPa), maximum absolute error (kPa), repeatability (SD, kPa) and sensor resolution (0.01 kPa) based on actual test data.
Signal processing/estimation layer: Quantified noise reduction effect by adding SNR improvement value (dB) and residual variance (kPa2) after processing, and supplemented the estimation error (MAE/RMSE, kPa) relative to the pressure reference.
Early warning model layer: Added precision, recall, and F1-score of each warning level, supplemented the confusion matrix of three-level warning (low/medium/high), and clearly reported the false alarm rate (FAR) and missed detection rate (MDR) of the model.
Figure 3.
Testing Module Prototype.
Figure 3.
Testing Module Prototype.
a. Performance testing of pressure sensors
This test verifies the sensor’s detection accuracy and response speed after preprocessing and compares the effectiveness of the preprocessing algorithm with that of the original data. The results are analyzed in detail as follows:
Testing accuracy test (accuracy up to 99.97%): Use a standard pressure calibrator to output pressure values of 0–50 kPa to the sensor (with an interval of 5 kPa), collect raw data and preprocessed data separately, and calculate the absolute error and relative accuracy. The results showed that the absolute error of the original data was 0.06∼0.15 kPa, the average error was 0.105 kPa, and the experimental accuracy was 98.8%. The absolute error after preprocessing is 0.03∼0.08 kPa, the average error is 0.048 kPa, and the relative accuracy after preprocessing is 99.2%, which is better than the nominal accuracy of the sensor (±0.1 kPa).
Results have shown that the preprocessed data has more stable errors, and temperature compensation effectively eliminates temperature-induced errors—when the temperature rises from −20 °C to 80 °C, the preprocessed data error only increases by 0.02 kPa, while the original data error increases by 0.08 kPa. According to the standard of 1 square meter, the pre-processing data error is Δm = 20 × 0.1 ÷ 9.8 ≈ 0.204 kg. The original data error is Δm = 80 × 0.1 ÷ 9.8 ≈ 0.816 kg. The accuracy is the same as that of the measured data, with a positive or negative 1.7 kg.
Response Delay Test
The time from the pressure change of the testing calibration instrument to the effective data output of the sensor showed a response delay of 42–48 ms, with an average of 45 ms, which is lower than the design target of 50 ms and meets the real-time monitoring requirements for battery pressure.
C. IoT Communication Performance Testing
This test verifies the transmission performance of IoT sensing nodes and gateways at different distances and node numbers. The results are as follows:
a. Transmission distance and packet loss rate test
Test the transmission performance of LoRa modules separately. LoRa module: When the distance is 0–2000 m, the packet loss rate is 0.1% 0.45%, which is lower than the target value of 0.5%; when the distance exceeds 2200 m, the packet loss rate exceeds 1%, making it suitable for long-distance scenarios such as energy storage power stations.
This is a transmission testing image and provides TCP/UDP testing results to better presents the package loss. The packet loss rate curve shown in the diagram indicates stable transmission within the effective distance, meeting the reliability requirements for battery monitoring data transmission.
b. Number of nodes and end-to-end latency testing
The end-to-end delay (the time it takes for the nodes to collect data and receive it on the cloud platform) was tested when the number of sensing nodes was 1–10. The results showed that when the number of nodes was 1–10, the end-to-end delay was 120–185 ms, with an average delay of 162 ms, which was lower than the design target of 200 ms. The delay increases linearly with the number and distance of nodes, but the growth rate is slow—when the number of nodes increases from 1 to 10, the delay only increases by 15 ms, and the bandwidth is also significantly optimized, indicating that the optimized MQTT protocol effectively reduces the probability of data collision.
Figure 5.
Transmission Testing.
Figure 5.
Transmission Testing.
Figure 6.
Packing Loss testing.
Figure 6.
Packing Loss testing.
c. System power consumption test
Test the current consumption of the sensing node in both working and standby states, and the results show that the working current is 8.2∼9.5 mA, with an average of 8.8 mA; the standby current is 0.6∼0.8 mA, with an average of 0.7 mA. Calculated based on a 3.7 V/2000 mAh lithium battery, the node can work continuously for 92 days in working state and 148 days in standby state, achieving low-power long-term operation.
d. Performance Comparison with Traditional Solutions
Having compared this system with traditional wired pressure sensing systems and non-communication pressure sensing systems, the results are shown in
Figure 7. It can be seen that this system has significant advantages in detection accuracy, response delay, deployment flexibility, and remote warning capability: detection accuracy is 0.7% higher than traditional wired systems, response delay is shortened by 35 ms, and wireless transmission enables remote monitoring and solves wired deployment limitations. Compared to the lack of communication systems, the addition of remote warning capabilities is more suitable for large-scale battery safety monitoring. The detailed performance on power consumption analysis is as follows:
1. Supplemented mode-wise power consumption data: The power consumption of the system in three working modes (Active, Sleep, Transmission) is clearly defined: 25 mA in Active mode, 0.1 mA in Sleep mode, and 30 mA in Transmission mode (unit: mA). 2. Supplemented duty cycle and sampling period: The duty cycle is set to 10% (the proportion of Active + Transmission time), the sampling period is 10 s, and the switching logic between Sleep mode and Active mode is clearly explained to ensure the transparency of the power consumption model. 3. Recalculated autonomy and supplemented relevant indicators: Based on mode-wise power consumption and duty cycle, the autonomy under each scenario is recalculated using an explicit formula (Autonomy = Battery Capacity/Average Current); energy per message (1.2 mJ/msg) and average current under each condition are reported.
Figure 7.
Networking Testing.
Figure 7.
Networking Testing.
e. Long-term stability testing
Under normal operating conditions, the system runs continuously for 30 days to test its stability. The results show that the sensor data drift is less than 0.03 kPa, the transmission packet loss rate is stable at less than 0.4%, the warning accuracy is 98.5%, and the system runs stably without any faults, meeting the long-term monitoring requirements.