## 3 Adaptive Data Transmission Algorithm  
The wearable sensor system is also an embedded system with the implemented adaptive data transmission algorithm. The general structure of the WSS operation is  
Figure 5: Arrangement of sensors in WSS: (**a**) block diagram and (**b**) view of the system placed on the hand. presented in Figure 6, where the block of the radio transmission control algorithm is marked with a dashed line. This algorithm allows to increase the energy efficiency of the WSS and reduce the load on the sensor network. In turn, the input data of the algorithm are the vector \(\omega_{i}\) and the defined threshold values \(TH1\), \(TH2\), and \(TH3\). In addition, the WSS operation diagram includes the processing of vectors \(a_{i}\), \(m_{i}\), and the quaternion \(q_{i}\), which is also indicated in the pseudocode in Figure 7. During operation, the ESP32 module collects data from \(\mathrm{S}_{i}\) sensors (\(i=1\), \(2\), \(\ldots\), \(16\)). The sampling frequency of sensors in the implemented system for the accelerometer and the gyroscope is \(119\) Hz. The data obtained from each sensor are in the form of three vectors \(a_{i}\), \(\omega_{i}\), \(m_{i}\) (1), where \(i=1\), \(2\), \(\ldots\), \(16\) denotes the indexing of the sensor number. \[ \begin{array}{l}a_{i}=\left[a_{ix},a_{iy},a_{iz}\right]\\ \omega_{i}=\left[\omega_{ix},\omega_{iy},\omega_{iz}\right]\\ m_{i}=\left[m_{ix},m_{iy},m_{iz}\right]\end{array}  \tag{1}\]  
The vectors \(a_{i}\), \(\omega_{i}\), \(m_{i}\) represent the data of individual sensors. The coordinates \(a_{ix}\), \(a_{iy}\) and \(a_{iz}\) of the vector \(a_{i}\) correspond to the acceleration in relation to the \(x\), \(y\) i z axes, respectively. Similarly, the coordinates \(\omega_{ix}\), \(\omega_{iy}\), \(\omega_{iz}\) correspond to the rotational speeds of rotations performed by individual sensors around the \(x\), \(y\) and \(z\) axes. In turn, the coordinates \(m_{ix}\), \(m_{iy}\), \(m_{iz}\) correspond to the values of the magnetic field induction measured by the magnetometers of the individual sensors. The data obtained from the \(i\)-th sensor are used by the fusion algorithm (SENSOR FUSION ALGORITHM) to determine the quaternion \(q_{i}\). An algorithm for AHRS (Attitude Heading Reference System) was used for the sensor Fusion [40]. The data (\(a_{i}\), \(\omega_{i}\), \(m_{i}\)) from the sensor and the quaternion \(q_{i}\) are saved in the data buffer along with the index number of the \(i\)-th sensor to which they correspond. The operation of the data transmission control algorithm requires only a small number of simple arithmetic operations. The results of testing the algorithm in the context of energy efficiency are presented in more detail in Section 4.2. In turn, Sections 4.3.1 and 4.3.2 show the algorithm effectiveness in terms of optimizing network traffic. On the basis of the rotational speed vector \(\omega_{i}\), the parameter \(d_{i}\) is also determined according to the Formula (2) and is related to the resultant angle of rotation of individual  
Figure 6: Logical diagram of WSS operation. sensors. Taking into account the rotation from all system axes allows for more effective transmission. \[d_{i}=\sqrt{{\omega_{ix}}^{2}+{\omega_{iy}}^{2}+{\omega_{iz}}^{2}} \tag{2}\]  
Input:  
Sensor data array. Each element of the array is a structure containing averaged values from the accelerometer (ax, ay, az), gyroscope (ux, uy, uz) and magnetometer (mx, my, mz), as well as the latest quaternion (q0, q1, q2, q3) and parameter d. Threshold values for the algorithm (TH1, TH2, Th3). Counter that counts the number of cycles of reading data from sensors (counter). The parameter \(d_{i}\) calculated for the \(i\)-th sensor is used to control the radio transmission (TRANSMISSION FREQ CONTROLLER). Based on the values of parameters \(d_{1}\)-\(d_{16}\), the frequency of radio data sending from individual sensors and the content of individual  
Figure 7: Pseudocode for the transmission control algorithm. transmission frames are determined.