# Routing with Renewable Energy Management in Wireless Sensor Networks
## 3 REBORN-Renewable Energy-Based Routing Algorithm  
In this section, we present our proposed REBORN (Renewable Energy-Based Routing) algorithm. As mentioned before, our algorithm assumes that each sensor node is equipped with a small solar cell, allowing them to recharge their batteries according to the available solar intensity (that varies during the day/night cycle). Different from most proposed solutions, REBORN uses both the residual battery level and the intensity of the available energy to decide on whether to send and/or forward data. REBORN, as shown in Algorithm 1, starts when the sink node initiates a controlled flood (Figure 1a). In this packet, a routing message containing its position in the grid is sent (line 11). To control the flooding, a variable that determines whether the packet was received by the node is maintained (lines 13 and 14). If the node has not yet received the packet, it computes its distance to the sink and forwards the message to its neighbors (lines 15 and 16); otherwise, the node ignores the duplicated packet. The node then computes the grid it belongs to by using its known position (line 17). This process continues until all of the network nodes receive the sink data. ```
1:\(i\)Time\({}_{i}\);
2:\(i\)Time\({}_{i}\);
3:\(dis\)Time\({}_{i}\);
4:\(ren\)Time\({}_{i}\);
5: state = discovery;
6:\(re\)cutcut\({}_{i}\); = false;
7: sinkDist\({}_{i}\);
8:\(grid1D_{i}\);
9:\(msg\);
10: Input;
11: Sink node sends routing message
12: Action;
13:\(sendRoutMsg(sinkPos_{i})\) {Sink initiates a controlled flooding}
14:\(input\)
15:2: Regular nodes receive routing message (msg\({}_{wait}\))
16: Action;
17: irouteConf; then
18: irouteConf; = true;
19: sinkDist; = getDist(msg\({}_{wait}\).sinkPos);
20:\(sendRoutMsg(sinkPos_{i})\) ;
21:\(grid1D_{i}\); = getGrid(nodePos);
22:\(input\);
23: Regular nodes enter in discovery state
24: Action;
25: discTime\({}_{i}\) = Constant
26: aTime\({}_{i}\) = remTimeAct\({}_{i}\) = getTimeToSend();
27: time\({}_{wait}\); trigger()
28: sendDscMessage(nodeID, gridID, remTimeAct, state, energyRat);
29:
30: Input;
31: Regular nodes receive discovery message (msg\({}_{0i}\))
32: Action;
33: if state = discovery and msg\({}_{0i}\),State = active then
34:\(\epsilon\)Time\({}_{i}\) = msg\({}_{0i}\),remTimeAct, state = sleep;
35: else if state = msg\({}_{0i}\),remTimeAct, state = sleep;
36: if energyRat = msg\({}_{0i}\),remTimeAct, state = sleep;
37: end if
38: end if
39: end if
40: input;
41: Time\({}_{wait}\)Time\({}_{i}\) fire
42: Action;
43: state = active {
44: \(\epsilon\)TimeAct; = time\({}_{start}\),remainingTime0;
45: Update timeAct, with rest time of aTime\({}_{i}\)
46:endDiscMessage(nodeID, gridID, remTimeAct, state, energyRat);
47:\(input\);
48:endDiscMessage(data, msg\({}_{0i}\), sinkDist);
49:
50: Output;
51: sendDscMessage(data, msg\({}_{0i}\), sinkDist);
52: sendDscMessage(msg\({}_{0i}\), data, msg\({}_{0i}\), diskSink);





After the configuration, the nodes go into the discovery state. In this step, the algorithm starts a first timer (_discTime_) that will be used to identify the time the node will remain in the discovery state (line 20). A second timer, which will be used to control the time a node will remain active, is also initialized (line 21). Such a timer is configured based on both the current solar intensity and the amount of remaining battery power (detailed in the next sections). At this point, a control variable called _remTimeAct_, will be used to store the remaining uptime on each node. When the first timer is started, the node broadcasts a message to all of its neighbors located in the same cell (line 23), as depicted in Figure 1b. In the discovery message submission step, nodes in the same cell exchange information with each other. This exchange of discovery messages among nodes enables the switching process between active and energy-saving modes, used to elect the neighbor responsible for forwarding messages toward the sink node. To establish a higher level of control during the message exchange process, some rules are proposed.