# Real-Time Extensive Livestock Monitoring Using LPWAN Smart Wearable and Infrastructure
## 3 Results
### Laboratory Tests
#### 3.1.2 Data Reconstruction Analysis  
In order to generate the codebook, VQ compression requires data to train the algorithm. As we have not yet collected enough motion data from the wearable in its intended operation scenario, we have accomplished the data reconstruction analysis with motion data from the Heterogeneity Activity Recognition Dataset [43], which provides a rich collection of inertial sensor data recorded in smartphones and smartwatches in different activities. Detailed analysis can be found in [39]. For example, considering sampling  
\begin{table}
\begin{tabular}{c c c c c c} \hline \hline
**Modulation** & **Payload** & **Time** & **Throughput** & **Energy per** & **Link Budget** \\ \hline LoRa (DR1) & 8 bytes & 495 ms & 129.3 b/s & 712 uJ & 148 dB \\ LoRa (DR5) & 228 bytes & 358 ms & 5.1 kb/s & 18.1 uJ & 138 dB \\ FSK & 61 bytes & 11 ms & 44.4 kb/s & 2.1 uJ & 123 dB \\ \hline \hline \end{tabular}
\end{table}
Table 1: Communication modes performance analysis.  
Figure 8: Current consumption while streaming IMU data sampled at 100 Hz.  
\begin{table}
\begin{tabular}{c c c c c c c} \hline \hline
**Mode** & **T**G**G**G**G**G**G**  
frequencies of 10 and 20 Hz, window sizes of 1, 5 and 10 s, we can achieve different compression ratios and codebook sizes as shown in Table 3.  
Shorter number of centroids with larger window sizes led to higher compression ratios which turns into lower required data rates, but they will also reduce PSNR as signal loss is greater. PSNR is computed as:  
\[\text{PNSR}=20\log\biggl{(}\frac{MAX^{2}}{MSE}\biggr{)}\, \tag{4}\]  
where \(MAX\) is the maximum value for the signal and \(MSE\) is the maximum squared error. For example, we can see the efect of varing the number of centroids of the codebook in a sample dataset of 1,500,000 training samples and 600,000 test samples at a sampling frequency of 100 Hz and window size of 1 s in Figure 9. Increasing the number of centroids  
\begin{table}
\begin{tabular}{c c c c c c} \hline \hline
**Sample Size** & **Sampling Freq** & **Window Size** & **Centroids** & **Codebook Size** & **Compression** & **Data Rate** \\
**(Bytes)** & **(Hz)** & **(s)** & **(KB)** & **Rate** & **(bps)** \\ \hline \multirow{8}{*}{1-axis (2 bytes)} & \multirow{8}{*}{10} & 256 & 15.36 & 60 & 8 \\  & & 1024 & 61.44 & 30 & 16 \\  & & 4096 & 245.76 & 30 & 16 \\ \cline{2-6}  & & 256 & 76.8 & 300 & 1.6 \\  & & 5 & 1024 & 307.2 & 150 & 3.2 \\  & & 4096 & 1228.8 & 150 & 3.2 \\ \cline{2-6}  & & 256 & 153.6 & 600 & 0.8 \\  & & 1024 & 614.4 & 300 & 1.6 \\  & & 4096 & 2457.6 & 300 & 1.6 \\ \cline{2-6}  & & 256 & 30.72 & 120 & 8 \\  & & 1024 & 122.88 & 60 & 16 \\  & & 4096 & 491.52 & 60 & 16 \\ \cline{2-6}  & & 256 & 153.6 & 600 & 1.6 \\  & & 1024 & 614.4 & 300 & 3.2 \\  & & 4096 & 2457.6 & 300 & 3.2 \\ \cline{2-6}  & & 256 & 307.2 & 600 & 1.6 \\  & & 1024 & 1228.8 & 600 & 1.6 \\  & & 4096 & 4915.2 & 600 & 1.6 \\ \hline \multirow{8}{*}{10} & \multirow{8}{*}{10} & 256 & 5.12 & 20 & 8 \\  & & 1024 & 20.48 & 10 & 16 \\  & & 4096 & 81.92 & 10 & 16 \\ \cline{2-6}  & & 256 & 25.6 & 100 & 1.6 \\  & & 1024 & 102.4 & 50 & 3.2 \\  & & 4096 & 409.6 & 50 & 3.2 \\ \cline{2-6}  & & 256 & 51.2 & 200 & 0.8 \\  & & 1024 & 204.8 & 100 & 1.6 \\  & & 4096 & 819.2 & 100 & 1.6 \\ \hline \multirow{8}{*}{20} & \multirow{8}{*}{10} & 256 & 10.24 & 40 & 8 \\  & & 1024 & 40.96 & 20 & 16 \\ \cline{1-1}  & & 4096 & 1638.4 & 20 & 16 \\ \hline \hline \end{tabular}
\end{table}
Table 3: Compression ratio and codebook size vs. codebook parameters.  
for a given window size improves PSNR figures, as the reconstructed signal is closer to the original signal, although using too many centroids will produce overfitting and may lead to badly generalizable codebooks.