# An Energy Aware Adaptive Sampling Algorithm for Energy Harvesting WSN with Energy Hungry Sensors
## 3 Energy Aware Adaptive Sampling Algorithm
### Energy Model of an Energy Harvesting WSN Node with a Power Hungry Sensor  
The development of an appropriate energy model, capable of accurately evaluating the energy consumption of hardware in different states of operation is an important task that will make the simulation and evaluation of potential deployments possible. The energy consumed during an operation is a function of the time required to carry out the operation in the particular operational mode of the underlying hardware. For example, once it is known that a particular task requires a certain number of microcontroller clock cycles, the amount of energy required (\(E_{ALG}\)) is easily calculated (e.g., \(E_{ALG}=P_{MCUI}t_{ALG}\)) where \(P_{MCU}\) is the power consumption of the MCU in Active Mode, and \(t_{ALG}\) is the time required to execute the algorithm. In the state machine in Figure 1, we assume a duty cycled node which has harvesting capabilities and a power hungry sensor. When the node samples the sensor it also sends the measurement to the BS. We assume that the earlier described ASA is running on the BS. When the ASA detects a change in the frequency of the signal, the base station sends a new sampling frequency, \(f_{ASA}\), to the node. The node, which has information on how much energy is available in its battery (and how much energy is harvested), adapts this sampling frequency \(f_{ASA}\) (received from the BS) according to Equations (1) and (2) resulting in a new sampling rate \(f_{EASA}\). Assuming that the information on the harvested power available, \(P_{i\ HARVESTED}\), for each \(i\) energy source, and the period of harvesting is available (\(t_{ihur}\)), the amount of harvested energy from the \(n\) sources can be calculated using Equation (3). \[E_{H}=\sum_{i=1}^{n}P_{i\;HARVESTED\;i\;i_{\;harv}} \tag{3}\]  
During the period when the node is active (\(t_{ACTIVE}\)), the node first listens for a message that contains the new sampling frequency from the BS (\(t_{RX}\)). The associated power consumption to this state is \(P_{RX}\). If within this time (\(t_{RX}\)), the node receives a message containing a new sampling frequency, it executes the energy aware function described with Equations (1) and (2) and adapts the sampling frequency received from the BS according to its energy levels. In the case when the node does not receive a message from the BS, the node continues sampling at the previous sampling frequency. The node samples the sensor for a period of time \(t_{SensorSamp}\). In the case of a power hungry sensor, the energy consumption in that period can be dominant due to the power required for sampling \(P_{SensorSampling}\), due to the duration of this phase, or in some cases both. After the data is acquired from the sensor, the next step is the processing phase where the data is analyzed by the microcontroller or additional circuits (_i.e._, ADC, level translators, _etc._). This phase is represented by \(P_{PROC}\) and \(t_{PROC}\) in Equations (4) and (5). Finally, the node sends a message to the BS (\(t_{TX}\) and \(P_{TX}\)) containing the acquired measurement. Thus, the active period can be described using Equations (4) and (5). \[t_{ACTIVE}=t_{TX}\;+\;t_{RX}+t_{SensorSamp}+t_{PROC} \tag{4}\]  
\[E_{ACTIVE}=P_{TX}t_{TX}+P_{RX}t_{RX}+P_{SensorSamp}t_{SensorSamp}+P_{PROC}t_{PROC} \tag{5}\]  
To evaluate the system energy spent during the sleep period, Equation (6) can be used, where \(P_{SLEEP}\) is the power consumption in sleep mode and the time spend in sleep (\(t_{SLEEP}\)) is the total period \(T\) minus the activity period (\(t_{ACTIVE}\)).