## 4 Hierarchical Energy Balancing Protocol (HEBP) Design
### Optimizing WSN Performance with HEBP  
#### 4.3.1 Conceptual View  
The results of the previous subsection highlighted the heterogeneous nature of an ambient energy harvester WSN. Considering that the harvest rates of the different WS are not equal, we envisaged in the protocol proposed here to define a hierarchy of the various WSs of the network at the beginning of each measurement cycle. The WS ranking was established based on each node's energy level at the start of the cycle. At the start of the \(n\)th measurement cycle, the energy level \(E_{i_{n}}\) of a node \(i\) was evaluated as follows:  
\[E_{i_{n}}=E_{H_{i_{n}}}+E_{R_{i_{n-1}}} \tag{16}\]  
where \(E_{H_{i_{n}}}\) is the energy predicted by the PHPV evaluated by Equation (10) and \(E_{R_{i_{n-1}}}\) is the residual energy at the end of the previous cycle, and this is evaluated with Equation (13).  
The energy cost associated with the minimum required QoS \((b_{min})\) is designated by \(E_{min}\). Three categories of WS are defined based on the energy levels defined above. The node with the highest energy level is the CH, WSs with an energy level below \(E_{min}\) are classified as the needy nodes, while WSs with an energy greater than \(E_{min}\) are self-sufficient nodes. A hierarchy was then established between these other two categories of WSs:  
* For the needy WSs, the classification is made from the least needy to the neediest.
* Self-sufficient WSs are classified from most self-sufficient to least self-sufficient.  
Once this hierarchy was established, it was then carried out to balance the energy of the different WSs. In the protocol, the self-sufficient WS with the highest energy will start delivering its extra energy to the needy node with the lowest energy deficit and so on. This will maximize the number of WSs that can transmit during a measurement cycle. Once this balancing is achieved, all nodes will send data, avoiding long queues in data memory for needy WSs. The protocol proposed to ensure this minimum QoS to the network is called the Hierarchical Energy Balancing Protocol (HEBP). The operating algorithm boils down to the different steps shown on the block diagram in Figure 13.  
Figure 12: Performances DSMP. (**a**) Cumulated transmitted data for \(b_{min}=512\) bits. (**b**) Quantity of data transmitted by each node during the month for \(b_{min}=512\) bits. (**c**) Cumulated transmitted data for \(b_{min}=4096\) bits. (**d**) Quantity of data transmitted by each node during the month for \(b_{min}=4096\) bits. (**e**) Cumulated transmitted data for \(512\) bits \(\leq b_{min}\leq 4096\) bits. (**f**) Quantity of data transmitted by each node during the month for \(128\) bits \(\leq b_{min}\leq 4096\) bits.  
Unlike the MDSP, whose performance was evaluated in the previous subsection, each node transmits its data to the cluster head, thus reducing the energy dissipation associated with long-range transmission to the BS. The free space model was used to fill the energy gap of a needy WS as in [57]. Thus, the energy \(E_{\text{t}}\) transmitted by the self-sufficient WS to a needy WS was defined as follows, assuming unity antenna gains:  
\[E_{\text{t}}=E_{\text{r}}\bigg{(}\frac{4\pi f_{\text{LoRa}}d_{1}}{c}\bigg{)}^{2} \tag{17}\]  
where \(c=3\times 10^{8}\) m/s is the speed of light, \(f_{\text{LoRa}}\) is the frequency of the LoRa transmitter, and \(d_{1}\) is a distance between the self-sufficient WS and the needy WS fixed at 10 m, corresponding to the average dimensions of the semi-autogenous mill [58]. \(E_{\text{r}}\) is the energy received by the needy WS; it was evaluated as the energy gap between the energy level \(E_{i}\) of the WS and the energy \(E_{min}\) required to satisfy the minimum QoS. It was then calculated as follows:  
\[E_{\text{r}}=E_{min}-E_{i} \tag{18}\]