# Battery Life Prediction for Ensuring Robust Operation of IoT Devices in Remote Metering
## 3 Remote Metering Life Prediction Method
### Data Collection and Preprocessing
Second, convolution-based smoothing [23] was employed to reduce noise in the discharge capacity and voltage data. This technique was selected based on empirical analysis comparing various denoising methods, ensuring that essential signal patterns were preserved while removing irrelevant fluctuations. Third, the primary point for triggering alerts was mathematically determined based on the first voltage drop. Lastly, min-max normalization was applied to enhance model performance. During the data collection process, missing values in discharge capacity, temperature, voltage, and communication count can occur due to communication interruptions between the smart gas meter and the server. Algorithm 1 presents the pseudocode for imputing missing voltage values through interpolation, maintaining the voltage variation patterns attributed to LoRa communication, as observed in the measured data. Here, \(T\) represents a time series with \(N\) empty values, \(T^{*}\) is the imputed version of \(T\), \(X\) signifies the previous data point for \(T\), and \(Y\) stands for the subsequent data point for \(T\). Line 3 assigns \(X\) to \(T\), and lines 4 and 5 calculate the average of \(X\) and \(Y\), respectively. Line 6 finds the bias, and lines 7 and 8 update \(T\) by subtracting the bias from each element of \(T\). Line 9 allocates the updated \(T\) to \(T^{*}\). The same procedure is applied to the temperature and the communication count for the same reasons. Missing values for discharge capacity were imputed through linear interpolation. Figure 4 illustrates the change in voltage data after implementing Algorithm 1. ```
1:time series \(T=[t_{m+1},t_{m+2},\cdots,t_{m+n}]\), with empty value of length \(N\)
2:filled time series \(T^{*}\)
3:Let \(X=[t_{m-n+1},t_{m-n},\cdots,t_{m}]\), Length \(N\)
4:Let \(Y=[t_{m+n+1},t_{m+n+2},\cdots,t_{m+2n}]\), Length \(N\)
5:\(T\gets X\)
6:\(x_{average}=\frac{1}{n}\sum_{i=m-n+1}^{m}t_{i}\)
7:\(y_{average}=\frac{1}{n}\sum_{i=m+n+1}^{m+2}t_{i}\)
8:\(Bias=\frac{x_{average}-y_{average}}{2}\)
9:for each \(t\) in \(T\)do
10: Update \(t\) as \(t\gets t-Bias\)
11:\(T^{*}\gets T\)
```  
**Algorithm 1** Voltage Interpolation  
\begin{table}
\begin{tabular}{c c c c} \hline \hline
**Timestamp** & **Voltage [V]** & **Temperature [\({}^{\circ}\)C]** & **Communication Count [Count]** \\ \hline
1658103487 & 3.814 & 32.81 & 0 \\
1658104087 & 3.814 & 32.76 & 0 \\
1658104687 & 3.785 & 32.86 & 3 \\
1658105287 & 3.811 & 32.71 & 0 \\
1658105887 & 3.811 & 32.69 & 0 \\
1658106487 & 3.813 & 32.74 & 0 \\ \hline \hline \endDuring data collection, noise can significantly affect the training process. To address this, we applied a convolution-based smoothing technique commonly used in signal processing, as defined in Equation (3). \[h(t)=f(t)*g(t)=\sum_{k=0}^{N}f(k)g(t-k), \tag{3}\]  
where \(g(t)\) is the input filter, \(N\) is the length of the data collected for \(f(t)\), \(t\) is the time parameter, and \(h(t)\) is the denoised data obtained by the convolution of \(g(t)\) and \(f(t)\). Figure 5 shows a clear and noticeable reduction in noise after the data passes through the filter. The process of determining the primary point utilized the second derivative of the daily voltage data, as shown in Figure 5(a). These second derivative values capture significant changes in the voltage slope between consecutive days. A negative second derivative indicates a decreasing voltage slope, marking the onset of a voltage drop, whereas a positive second derivative reflects an increasing voltage slope, signifying the end of the voltage drop. The primary point was identified as the point with the smallest second derivative value (as defined by Equation (4)). \[Primary\ point=Minimum(\frac{\mathrm{d}}{\mathrm{d}^{2}t}V(t)), \tag{4}\]  
where \(V(t)\) represents the voltage discharge curve over time. Figure 5(b) visually illustrates the placement of the primary point on the discharge curve, while Figure 5(c) showcases the extracted data for learning, using the primary point as a reference.