# Routing with Renewable Energy Management in Wireless Sensor Networks
## 3 REBORN-Renewable Energy-Based Routing Algorithm
A node that has the active state has higher priority so that, if a node is in the discovery state and it receives a message from a node that is in the active state (line 25), this node will immediately switch to sleep mode (line 26). The node in the active state coordinates the time duration of the node in the sleep mode, in such a way that the nodes enter discovery mode at the same time. On the other hand, if the nodes are in the same state (line 27), the remaining energy is checked (line 28). This node will switch to energy saving mode (line 29) if it receives a message from a neighbor who has more energy. In this case, if the nodes are in the active state, the rule is applied immediately, but if they are in a state of discovery, they will be able to receive the information of the neighbors so that they know which neighbor has the largest amount of energy. Finally, when the first timer expires, the state change happens (line 33). When a node is in the active state, the information stored in the variable _discTime_\({}_{i}\) is updated (line 35). From this point on, a new set of helper timers will be needed for the management of power modes (lines 36-38). While the node remains in the active state, it will be possible to send discovery packets at _discTime_\({}_{i}\) time intervals, that is, every time the first timer expires, the value of _remTimeAct_\({}_{i}\) is updated with the time the node will remain active (lines 40 and 41). If _remTimeAct_\({}_{i}\) is greater than _discTimeri_\({}_{i}\), the timer in question will be re-enabled. When the helper timer _aTimeri_\({}_{i}/2\) expires, a broadcast message is sent to the network (Figure 1c) containing a data packet with the gathered data, the message identifier, and the distance to the sink (line 43). Finally, when the helper timer _aTimeri_\({}_{i}\) expires, the node returns to the discovery state (line 52). During the process of forwarding packets to the sink, if a node is in the active state and receiving a packet, it checks if the

Figure 1: REBORN example: (**a**) the sink node starts a controlled flooding to send its position information to the network; (**b**) the nodes in each cell, which are in the discovery state, elect the node that will remain active; (**c**) an active node sends its data by broadcast, and active nodes in adjacent cells opportunistically forward the data toward the sink node using a greedy forwarding scheme. received message came from a node farthest from the sink. In addition, the node checks if it has already received this message previously (line 45), and if it has received it, checks if the sender is a node farthest from the sink. If the node has not yet received such a message, the node updates its distance information and prepares a message with its distance to the sink. This message will then be broadcasted (lines 46 and 47), otherwise, the received packet will be discarded. When a node enters the save state, all timers already configured are deactivated. However, it is possible for the node to switch to a more battery-saving mode. In these cases, the timer configured upon receipt of a discovery message will be activated (line 50). Finally, when this timer expires, the node returns to discovery mode (line 52) and the election process is restarted. To better visualize all of these steps and state changes, Figure 2 shows a flowchart of states and decisions for the nodes. ### Renewable Energy

To evaluate the performance of our routing algorithm, we need a way for simulating the harvested energy. Some solar models can be found in the literature [34; 35] that focus on being the most robust and realistic, taking into consideration aspects such as seasonal variations, weather forecasts, and even the dissipation of energy by voltage regulators. However, these models are complex and provide an unnecessary level of detail for our case. Thus, based on more simplistic but still realistic models [36], in this section, we describe our proposed solar model. The first step is to understand the behavior of the solar intensity.