## 4 Hierarchical Energy Balancing Protocol (HEBP) Design
### Performance Evaluation of Each WS Based on Its Harvesting Capacity  
By setting a measurement cycle time of \(\tau\); corresponding to the frequency at which each WS must transmit information about the state of the system, the harvestable energy during a measurement cycle for node \(i\) is evaluated as follows:  
\[E_{H_{i}}=\int\limits_{t}^{t+\tau}\Bigl{(}p_{PHPV}(u)-E_{a_{\max_{i}}}\Bigr{)}du \tag{10}\]  
where \(t\) is the start time of the measurement cycle, \(p_{PHPV}(u)\) is the power predicted by the PHPV during the measurement cycle. As defined in Equation (9), \(E_{a_{\max_{i}}}\) corresponds to the maximum absolute error reached; the values depending on the measurement points are reported in Table 2. An energy cost per bit \(E_{WS}\) was established, so the maximum quantity of bits that can be transmitted by node \(i\), in a measurement cycle is the solution to the following optimization problem (designated by P1) [7]:  
\[\min_{b}\bigl{(}E_{H_{i}}-b\cdot E_{WS}\bigr{)} \tag{11}\]  
Subject to:  
\[\left\{ \begin{matrix}E_{H_{i}}-b\cdot E_{WS}\geq 0\\ b\geq 0\end{matrix} \right. \tag{12}\]This optimization problem maximizes the amount of data, \(b\) (an integer) that each node in a measurement cycle can transmit. Using the energy harvested by node \(i\), the energy level of the node is updated at the beginning of the following cycle as follows:  
\[E_{H_{i}}\gets E_{H_{i}}-b^{*}.E_{WS}+\int\limits_{t}^{t+\tau}(p_{real}(u) -p_{PHPV}(u))\cdot du \tag{13}\]  
where \(p_{real}(u)\) is the actual power harvested during the earlier cycle, \(b^{*}\) is the solution of the optimization problem P1 defined by Equations (11) and (12), with the other parameters being defined as previously. The protocol thus presented aimed to maximize the amount of the data transferred by the WS based on the energy expected to be collected; it was referred to in [7] as the Maximization Data Size Protocol (MDSP). However, the study only focused on a single node (the one with the highest harvest rate), thus not guaranteeing the energy autonomy of the WSN. A more generic flowchart than that proposed in [7] of the MDSP is shown in Figure 11. For an energy cost \(E_{WS}\) per data bit, the maximum and minimum size of data transferable per measurement cycle was defined, and the residual energy of each node was updated before the start of the next cycle. \(N\tau\) in the flowchart represents the total number of measurement cycles; \(b_{min}\) is the minimum size of the data associated with a minimum required QoS. Figure 11: MDSP flowchart. In this work, the energy cost associated with \(b\) data bits \(E_{\text{WS}}\)\((b,d)\) is the sum of the energy dissipation for data acquisition \(E_{\text{acqui}}(b)\), for data reception \(E_{rx}\)\((b)\), for their processing \(E_{\text{pro}}(b)\), and finally for their transmission to the BS, \(E_{\text{tx}}(b,d)\)[52]. With \(d\) representing the distance between the BS and the network, it was assumed that the BS is sufficiently far from the network so that all the WSs are approximately at the same distance \(d\) from it. It was also assumed that each node has a LoRa (Long Range) transmitter, one of the IoT protocols offering advantages in terms of lifetime and capacity [53]. Many recent studies have been proposed to quantify the WS energy budget. From the review proposed in [54], it emerges that some of the most relevant results in the field have come from the work [31; 52]. The different sources of dissipation considered above are then expressed as in works [7; 31; 52; 55] by the set of Equation (14). \[\left\{