Development of Power Consumption Models for ESP8266-Enabled Low-Cost IoT Monitoring Nodes

The development of energy and cost efficient IoT nodes is very important for the successful deployment of IoT solutions across various application domains. This paper presents energy models, which will enable the estimation of battery life, for both time-based and event-based low-cost IoT monitoring nodes. These nodes are based on the low-cost ESP8266 (ESP) modules which integrate both transceiver and microcontroller on a single small-size chip and only cost about $2. The active/sleep energy saving approach was used in the design of the IoT monitoring nodes because the power consumption of ESP modules is relatively high and often impacts negatively on the cost of operating the nodes. A low energy application layer protocol, that is, Message Queue Telemetry Transport (MQTT) was also employed for energy efficient wireless data transport. The finite automata theory was used to model the various states and behavior of the ESP modules used in IoT monitoring applications. The applicability of the models presented was tested in real life application scenarios and results are presented. In a temperature and humidity monitoring node, for example, the model shows a significant reduction in average current consumption from 70.89 mA to 0.58 mA for sleep durations of 0 and 30 minutes, respectively. The battery life of batteries rated in mAh can therefore be easily calculated from the current consumption figures.


Introduction
Internet of Things (IoT) nodes are smart, Internet-connected, resource con-Advances in Internet of Things strained end devices embedded with at least one transducer (sensor or actuator), a microcontroller, a wireless transceiver and a power source. The transducer is used to interact with physical parameters while the transceiver is used to wirelessly communicate with other nodes and users locally or via the Internet. Commonly used low energy wireless transceivers include ZigBee, Bluetooth, Bluetooth Low Energy (BLE), WiFi, etc. The microcontrollers used in IoT node development are usually small sized and therefore have low processing and storage capacities. So also, the power source is usually a small battery. Though a number of Internet of Things (IoT) hardware platforms are available off-the-shelf [1], the recent introduction of ESP8266 modules (simply called ESP modules) into the market has enabled the development of miniature and low-cost IoT nodes. An ESP module [2] fully integrates WiFi networking capabilities and a microcontroller (Tensilica L106 32-bit) at a cost of just about $2 and an external size of 16 mm × 24 mm × 3 mm. The module can thus act as both the transceiver and the processor for IoT nodes. Numerous IoT solution providers and researchers therefore use these modules in their projects. However, the power consumption of these modules is high. An ESP8266-12E module, for example, consumes an average of 70.5 mA when it is fully on (that is, when its WiFi modem and microcontroller are both on) even when the transceiver is inactive (neither receiving nor transmitting). At this current consumption, a typical Alkaline 2500 mAh battery will only last for about 36 hours (less than two days) assuming that only the current consumption of the ESP module affects the battery capacity (other factors that affect battery capacity include ambient temperature and the current consumption of other node components). The active/sleep energy saving approach is therefore commonly used to ensure the efficient use of available energy in monitoring applications. Monitoring applications can either be time-based (where a physical parameter of interest is monitored and data is transmitted at regular time intervals) or event-based (where the physical parameter is continuously monitored but a threshold is set such that data obtained from the physical phenomenon is transmitted only if it is greater than or less than the set threshold).
Presently, ESP modules support three power saving modes, which are, modem-sleep, light-sleep and deep-sleep modes with current consumptions of 15 mA, 0.9 mA and 10 µA, respectively [2]. Consequently, the deep-sleep mode is the primary target for most low energy monitoring applications. In this mode, the WiFi modem, system clock and CPU are all switched off while only the real time clock (RTC) is left on to enable user-defined periodic wake-ups. Therefore, the deep-sleep mode is most suitable in time-based monitoring when there is a long time interval between sensor readings or where it is not necessary to continuously transmit data or monitor a physical parameter. For example, a node that monitors the temperature and humidity in a poultry farm does not need to continuously transmit its data. Such a node can sleep for about half an hour or even more. Since IoT monitoring nodes are generally powered by small battery sources, there is a need for developers to be able to estimate how long these small batteries can continue to service the nodes without a need for replacement or recharge. Therefore the focus of this work is on the development of power consumption models that will enable IoT solution developers to determine approximately how long a power source (of known mAh capacity) will continue to power an ESP8266-enabled IoT time-and event-based monitoring node before it will require a replacement or recharge. The model however assumes that only the current drawn by the components of the node affects the capacity of the battery.
The remainder of this paper is organized as follows; a review of related works is presented in Section 2. Section 3 presents a general energy model for ESP8266 based IoT monitoring nodes while FSM is used in Section 4 to model the states and behavior of ESP8266-enabled time-based and event-based IoT monitoring nodes. Results obtained from the application of these models are presented in Section 5 while concluding remarks and recommendations for further studies are presented in Section 6.

Related Works
References [6] and [7] have shown that the power consumption of the transceiver is much higher than that of the other IoT or wireless sensor network (WSN) node components and that the transceiver consumes about the same amount of energy when it is active and when it is switched on but idle or inactive. WSN and IoT nodes are similar; the only difference between them is that IoT nodes data are intended for ubiquitous access via the Internet while local accesses will suffice for WSN nodes data. A few works have therefore been done on modeling the power consumption of IoT and WSN nodes with a lot of emphasis on the power consumption of the transceivers. While some of these works proposed generic models that can be used for all transceiver types, others focused on specific tran-

The Energy Model
Since IoT monitoring nodes are mostly powered from small battery sources and the capacity of these battery sources are rated in mAh which is a unit of electric charge (Q) and indicates the amount of current that a battery can continue to supply for one hour, the energy model proposed in this work focuses on the current consumption of IoT node components. The current consumption of a node over time t (that is, charge) can be modeled as, 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 Also note that Therefore the current consumption of an ESP8266 based monitoring node is c c

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) [14], 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).

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)  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 T C , T P , T X and T S (which are all constants). T C is the time it takes the ESP module to connect with an AP after waking up from deep-sleep, T P is the time it takes the module to receive and process sensor data into node message, T X is the time it takes the module to wirelessly transmit node massage via the AP and T S 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. Using an application layer protocol with low overhead such as MQTT [15] [16] 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 T P (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 T C (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 T C , over the period T is,

Q I T T I T I T T T I T
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 T C will be different from the current consumption during T P . Therefore, Equation (11) Q I T I T I T I  T T T  I T  = + + + + + + (12) where I TDq 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 C P X S T T T T T = + + + (13)

Event-Based Monitoring
An ESP8266 module used in an event-based monitoring node will also operate The update function is given by Equation (15). The state transition diagram of event-based monitoring is shown in Figure 2.  ( ) where TH is a set threshold.

Time-Based Monitoring Case Study
A temperature and humidity monitoring node was setup using a DHT22 sensor [17], an ESP-12E module [2], a HT7333 low power voltage regulator [18] and four 1.5 V AA Alkaline replaceable batteries (rated 2500 mAh). The flowchart of the node operation is shown in Figure 3  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 Internet gateway. That is, T C = 1 s. The processing time T P is 3.5 s, the sleep duration T S is 1800 s (30 minutes), while the transmitting time T X is determined by the delay interval, that is, T X = 10 s. Therefore from Equation (13), T =1814.5 s, Q c ≈ 0.29 mAh from Equation (12) and the current consumption of the node I c ≈ 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

Event-Based Monitoring Case Study
A motion detection node that uses a PIR motion detector [19] 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  Also, T C and T X remain the same at 1 s and 10 s respectively, while T P is now 0.5 s. Lastly, T S 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 T S on I c .
The current consumption of the node when it is not allowed to go to sleep is

Conclusions
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.