Therefore the charge becomes,
since , and are constants, we have,
However, in order to minimize the power consumption of a node, it is necessary to enable the switching of node components between ON, OFF and SLEEP modes such that a node component is only activated when needed. If T represents the period of node operation (that is, the amount of time that elapses between two consecutive wake-ups of the ESP module) where the transducer is only switched ON once from time to and OFF at other times, the voltage regulator circuit is expected to be ON throughout the entire period T, while the ESP module is at SLEEP from time to , ON but not transmitting from time to and transmitting from time to . Also, let , and represent the current consumption of the ESP module in the SLEEP, ON (but not transmitting) and transmitting modes, respectively. Therefore from Equation (4), the current consumption of the node over the period T is
where and .
Also note that
Therefore the current consumption of an ESP8266 based monitoring node is
4. FSM Model
FSM is used to model the states and behavior of the ESP8266 module. A FSM is a 5-tuple given as (States, Inputs, Outputs, update, initial State)  , where States is a finite, non-empty set of states, Inputs is a finite, non-empty set of input valuations, Outputs is also a set of output valuations, update is a function that maps a state and an input valuation to a next state and an output valuation, and initial State is the initial state (which is an element of States).
4.1. Time-Based Monitoring
An ESP8266 module used in a time-based monitoring node will operate in one of the four possible states indicated in Equation (8) at a time.
In the ON state, the module is switched on but not connected to an AP (access point or Internet gateway). In the CON state the module is on, connected to an AP and processing sensor data. In the TX state, the module is on, connected to an AP and transmitting node data to the AP. Lastly, in the SLP state, the module goes into the deep-sleep power saving mode. Also, as shown in Equation (8), the FSM has two inputs, that is, time and sensor. The input type, sensor, can either be present (with a valid sensor reading which can be a bit, several bits or an analog value) or absent while the input type, time, has valuations TC, TP, TX and TS (which are all constants). TC is the time it takes the ESP module to connect with an AP after waking up from deep-sleep, TP is the time it takes the module to receive and process sensor data into node message, TX is the time it takes the module to wirelessly transmit node massage via the AP and TS is the duration of sleep of the module. The FSM has only one output, node, which has valuations node Data and absent. The ON state is the initial state.
The update function is given by,
where u, s and i represent update, current state and input, respectively, i (time) is the time the ESP8266 module spends in a particular state and i (sensor) indicates that sensor data is present.
The state transition diagram of the FSM is shown in Figure 1. The count variable is incremented (by 1) every second within a state and it is reset to zero when there is a transition from one state to another.
Figure 1. State transition diagram of a time-based monitoring node.
Using an application layer protocol with low overhead such as MQTT   for data transfer, the average current consumption of the ESP8266 module when it is Fully ON and when its WiFi modem is active (that is, transmitting or receiving) is approximately the same. Also, from the state transition diagram, in order to save energy, the sensor should also be switched off when the ESP module is in the sleep mode and only be switched on during the time duration TP (after the module has connected to an AP and ready to process sensor data). However, if the time it takes the sensor to stabilize after it is switched on is greater than, or approximately TC (which is often the case with digital sensors), then the sensor should also be switched on as soon as the ESP module wakes up from sleep. Therefore, from Equation (5), the current consumption of a time-based monitoring node, assuming that the time taken for the sensor to stabilize is much less than TC, over the period T is,
otherwise it is
In some cases, the sensor used (also mostly digital sensors) will have a quiescent current consumption different from its current consumption when its data is being processed and transmitted to the microcontroller. In such cases, the current consumption (quiescent current consumption) during TC will be different from the current consumption during TP. Therefore, Equation (11) becomes
where ITDq is the quiescent current consumption of the sensor. Also, it is important to note that since T represents the time between two consecutive wake-ups of a monitoring node, then
4.2. Event-Based Monitoring
An ESP8266 module used in an event-based monitoring node will also operate in one of the four states defined under time-based monitoring per time. However, the SLP (sleep) state becomes the initial state in event-based monitoring as shown in Equation (14) and the sleep time, TS is no longer one of the possible inputs because the sleep time is not predetermined but depends on an event occurring.
The update function is given by Equation (15). The state transition diagram of event-based monitoring is shown in Figure 2. The ESP module continues to
Figure 2. State transition diagram of an event-based monitoring node.
sleep until the sensor reading exceeds a set threshold. When the threshold is exceeded, the time spent sleeping is stored in variable TS and the module transitions into the ON state. Equations (10) to (14) can also be used to calculate the current consumption of an ESP-enabled event-based monitoring node over a period T.
where TH is a set threshold.
5.1. Time-Based Monitoring Case Study
A temperature and humidity monitoring node was setup using a DHT22 sensor  , an ESP-12E module  , a HT7333 low power voltage regulator  and four 1.5 V AA Alkaline replaceable batteries (rated 2500 mAh). The flowchart of the node operation is shown in Figure 3. Each time the node wakes up, it connects with an Internet gateway. If the monitoring node does not connect with the gateway within 3 s (after waking up), the node goes back into deep-sleep mode. This will ensure that energy is not unnecessarily wasted when the Internet
Figure 3. Flowchart of temperature and humidity monitoring node.
gateway is unavailable because it only takes the node an average time of about 1 s to connect with the gateway.
Also, if the microcontroller receives an invalid reading from the sensor (as a result of damaged sensor or circuit), it attempts to read from the sensor again. If the reading is still invalid at this second attempt, the node goes into deep-sleep mode. This will also ensure that energy is not unnecessarily wasted when the DHT22 sensor is faulty. In both cases, an alarm can be triggered before the node goes back to sleep. The “Delay” interval is used to specify the maximum amount of time that the monitoring node will continue to attempt to connect with the MQTT broker and publish its message (in cases of weak or problematic Internet services). A delay interval of 10 s was set in this case study. Also, the DHT22 sensor is powered from one of the GPIO pins of the ESP8266 module instead of powering it from the power supply (or the output of the HT7333 voltage regulator) so as to ensure that the sensor module is also switched off when the ESP module goes into the deep-sleep power saving mode. The DHT22 sensor has a quiescent current consumption ITDq and a measuring current consumption ITD of 10 µA and 1.6 mA, respectively. The ESP module has a current consumption of 10 µA in the deep-sleep mode and 70.5 mA in both the ON ( ) and the TX ( ) states. The quiescent current consumption of the voltage regulator is about 1 µA. It takes the node an average of 1 s to connect with the Internet gateway. That is, TC = 1 s. The processing time TP is 3.5 s, the sleep duration TS is 1800 s (30 minutes), while the transmitting time TX is determined by the delay interval, that is, TX = 10 s.
Therefore from Equation (13), T =1814.5 s, Qc ≈ 0.29 mAh from Equation (12) and the current consumption of the node Ic ≈ 0.58 mA from Equation (7). So the Alkaline batteries will last for approximately 6 months before replacement will be required (assuming that only the current consumption of the node components affect the capacities of these batteries). Figure 4 shows the relationship between deep-sleep duration TS and the current consumption Ic of the ESP8266-based temperature and humidity monitoring node. The average current consumption is 70.89 mA if the node does not go into sleep mode while it is 0.25 mA when the sleep duration is 71 minutes (the maximum deep-sleep duration of an ESP module). However, at a deep-sleep duration of just 1 minute, the current consumption has been significantly reduced to 13.81 mA from 70.89 mA. That is, the battery life will increase by a factor of 5 with a sleep duration of just 1 minute (when compared with no sleep).
5.2. Event-Based Monitoring Case Study
A motion detection node that uses a PIR motion detector  was set up in this case. Other node components are same as used for the temperature and humidity monitoring node. The flowchart of the node is shown in Figure 5. The ESP
Figure 4. Graph of current consumption against deep-sleep duration of an ESP8266-enabled time-based monitoring node.
Figure 5. Flowchart of motion detection node.
module cannot go into deep-sleep mode in event-based monitoring because the sensor needs to continuously monitor the physical parameter (motion in this case) and switches on the ESP module whenever motion is detected (or a threshold is exceeded). The PIR motion detector has a quiescent current consumption ITDq and a measuring current consumption ITD of 0.04 mA and 0.21 mA, respectively.
However and remains the same at 70.5 mA and 1 µA, respectively. Also, TC and TX remain the same at 1 s and 10 s respectively, while TP is now 0.5 s. Lastly, TS depends on an event occurring, that is, motion detection in this case. Using Equations (7), (12) and (13), Figure 6 shows the effect of varying TS on Ic. The current consumption of the node when it is not allowed to go to sleep is 70.51 mA. However, it is 12.1 mA, 2.21 mA, 1.34 mA, 1.12 mA and 0.97 mA at forced light-sleep durations of 1 minute, 10 minutes, 30 minutes, 1 hour and 3 hours, respectively. The battery life in each case can also be estimated by simply dividing the battery capacity (in mAh) by the calculated current consumption.
Figure 6. Graph of current consumption against forced light-sleep duration of an ESP8266-enabled event-based monitoring node.
Power models have been presented for low-cost ESP8266-enabled time-based and event-based IoT monitoring nodes. These models will enable solution developer to calculate the current consumption of an IoT node from the knowledge of the current consumption of each of the components that make up the node in order to estimate the battery life of batteries used to power these ESP8266-enabled IoT monitoring nodes. The models assume that only the current consumption of the components of a node affects the battery life of the batteries used in powering the nodes.
Results from the two case studies have shown the usability of the models presented for calculating the average current consumption of an IoT monitoring node. The battery capacity (in mAh) is then divided by the calculated average current consumption to obtain the expected life of the battery. Also, as the sleep duration of a monitoring node increases, its current consumption (and ultimately its power consumption) decreases significantly.
Various IoT application domains such as smart home, healthcare and agriculture that are enabled with ESP8266 will benefit from the models presented. The models presented can be modified and used for other IoT hardware platforms.
This work is supported by Petroleum Technology Development Fund (PTDF), Nigeria.
Conflicts of Interest
The authors declare no conflicts of interest regarding the publication of this paper.
Cite this paper
Akintade, O.O., Yesufu, T.K. and Kehinde, L.O. (2019) Development of Power Consumption Models for ESP8266-Enabled Low-Cost IoT Monitoring Nodes. Advances in Internet of Things, 9, 1-14. https://doi.org/10.4236/ait.2019.91001