1. Introduction
Internet of things (IOT) is an emerging technology in which data transmission and information access among any objects or devices becomes easier, thus making life easier in many aspects [1]. This technology has grown exponentially. According to a report by Cisco, the number of internet-connected devices will be more than triple that of the global population. [2] Such rise in IoT devices will lend itself to a diversity of applications such as smart energy, smart building and health monitoring equipment. IoT is nothing but communication between devices all over the globe. This essentially upsurges inter-connectivity and sharing of data between devices and people. This leads to various issues which makes the IoT framework vulnerable in terms of scalability, security, privacy, energy efficiency, etc. [3]. Although IoT technologies are in the forefront of research and development [1], battery technologies are not evolving as fast to keep up with these emerging technologies. In addition, security requirements of IoT devices strains energy consumption, making optimization a necessity. Unfortunately, most programmers and developers lack the knowledge regarding software/energy dependence, failing on energy-friendly algorithm development. Researchers are continuously looking for ways to improve the energy efficiency of software running on embedded systems. Energy efficiency has a great impact on choosing the right MCU for a particular application [4]. Power management is a topic for static and mobile systems. In static systems, a well power management will reduce generated heat and electricity bills, and for mobile systems provide longer battery life. Power consumption of an MCU depends on operating voltage and current [5]. Different techniques can be implemented to reduce the power consumption, particularly in microcontrollers [6-8].
IoT devices have offered improvement for development in multiple areas, but these benefits might be limited by hardware and electronic design. There is a small list of advantages and disadvantages:
- Advantages:
- Disadvantages:
Most IoT devices are battery powered, hence these are battery restricted. Furthermore, these devices become useless or inoperable until a battery replacement is performed, which can represent a high operating cost for the IoT device. To reduce cost, it is necessary to maximize the use of energy and reduce battery replacement as much as possible.
Considering that IoT devices are wireless, there exists various ways to communicate with another device (M2M), thus sharing data becomes crucial and significant about energy consumption for IoT applications [9, 10], since it is necessary a certain procedure to send data, which will take resources from the board, a wireless technology such as Bluetooth, WIFI, Zigbee, Lora, among others, must be necessary. However, when using WIFI, it is possible to standardize the process in how information is sent using the following protocols:
1. The MQTT (MQ Telemetry Transport) is a simple Internet of things communication protocol. It is based on passing messages between clients through the central server. The client can be of the publisher type, sending their messages to defined topics (address, topic). The publisher can be represented by a sensor or meter [11].
CoAP (Constrained Application Protocol) is a specialized web transfer protocol for use with constrained nodes and constrained networks in the internet of things. It is generally used for machine-to-machine communication (M2M) [12].
In addition, HTTP (Hypertext Transfer Protocol) is an application protocol for distributed, collaborative, hypermedia information systems that allows users to communicate data on the World Wide Web [13].
These communication protocols are some of those used for the development of IoT applications, also called application layers. A study by Eclipse in 2021 [14] states that the top three communication protocols used by developers are MQTT with 44%, HTTP with 26% and REST with 23%.
When using IoT devices, it is beneficial to know how much energy is consumed when transmitting data using a protocol. Then, we will be able to optimize the number of messages that are necessary to transmit a byte, increasing the amount of running battery time that application requires.
2.- Related work
People have been concerned with analyzing energy consumption in IoT devices, implementing a similar approach to the one shown in this work.
In [9], an analysis of the current used in a development IoT device is done, making emphasis on the analysis of current consumption, using the ESP8266 development board for its cost, this article analyzes, Device on and off power task (Wake up, sleep mode), DHT22 sensor data acquisition, as well as the energy required to establish connection to the internet and a MQTT server.
They compare MQTT and aMQTT, a small variant of the protocol, yielding a very similar current consumption in both variations. Furthermore, the execution time is less when using aMQTT variant, thus representing a lower energy consumption.
In [15], a comparison of the different quality levels of the MQTT protocol (light QoS) is done with the ESP32 device, using a multimeter. This performs an analysis of battery voltage drop with respect to time. They state that the quality level Qos1 has a lower consumption compared to other levels.
In [16] a comparison of quality levels (QoS levels) has been done with the ESP8266 microcontroller, where a digital multimeter is used to monitor energy consumption. Results show that energy consumption with a higher quality level generates a very high energy consumption compared to the lowest level.
An ESP8266 development board is used in [17], which performs the task of using two different sensors, DTH22 and TSL2561, they observe battery life with the number of messages per MQTT sent in a time of one second and a half second. They conclude that when sending a message every second, you get approximately twice the battery life that when sending messages every 0.5 seconds.
In [18], several protocols used for the IoT industry are compared. They perform a simulation between them using the software WANem [19], based on simulations they obtain the energy consumption calculated by the number of packages. They conclude that the MQTT protocol consumes more energy than the COaP protocol.
A comparison of different communication protocols evaluated on the same development board, COaP, MQTT, HTTP is done in [20] they performed 25 read cycles for each protocol with a shunt resistance of 5.5 Ohm using 7.5 volts as their power supply. An average of the energy consumption is acquired and comparison is made, thus the protocols MQTT and COaP, are the most suitable for IoT devices.
2.- How MQTT works
MQTT is a lightweight, fast communication protocol designed for IoT. This allows communication between different devices using a Publish/Subscribe model [21, 22]. To do this you need to use a broker which works as a server. The IoT device can request data and send it directly to the broker. Publications are made by topic, and to read this information you need to subscribe to the correct topic. Figure 1 shows an example of how IoT communication and brokering works.
MQTT has three levels of quality (QoS):
QoS0 (At most once):
QoS1 (At least once):
The transmitted message may arrive one or more times until the recipient returns a confirmation response.
QoS2 (Exactly once):
The broker can be created locally, or remotely, you can observe a few brokers that can be implemented locally:
- Mosquitto [23]:
- Mosca MQTT [24]:
- ACTIVEMQ [25]:
3.- Materials and methods
MQTT is analyzed as it is of the most used protocols by developers, using a broker mosquitto implemented in windows with the quality level QoS0.
Many companies produce devices for the development of applications with IoT. One such device is the arduino Yun [26], which offers wifi and ethernet connectivity for IoT applications. Microchip has several devices [27, 28]. These include wifi connectivity for IoT application development.
ESPRESSIF, also develops the ESP32 [29] and ESP8266 [30] boards, which are ready for IoT applications.
Devices | Connectivity | Cost |
ESP32 | wifi & bluetooth | 18 dlls |
ESP8266 | wifi | 16 dlls |
PIC IoT | wifi | 95 dlls |
Arduino yun | wifi & ethernet | 95 dlls |
Raspberry pizero | wifi | 68 dlls |
This article uses a DEVKIT V1 NodeMCU-32 (ESP32) development board. This is a 32-bit MCU with Wi-Fi and Bluetooth dual mode, which makes it suitable for Internet of Things applications.
The development board is used with three power supplies at different voltages. Table 2 provides the voltages as well as the type of power supply.
Voltage | Type |
9 v | NiMH rechargeable battery 450 mAh |
5 v | USB Power Bank 5000 mAh |
3.7 v | Li-Po Battery 500mAh |
The code used to evaluate the energy consumption when sending data using the Wi-Fi module is the one provided by the manufacturer. First, basic configuration of the Wi-Fi module is set to establish network Wi-Fi communication. Afterwards, the ip address and port are defined. Then a publication is performed, therefore the ascii character "A" with the topic "test" is sent, this for MQTT (QoS0) message requirements. After sending the information, the algorithm goes into deep sleep via the WDT (WatchDog Timer) set to 1 millisecond; After the WDT finishes, it wakes up the NodeMCU-32 and the process restarts. The same algorithm is used to evaluate the energy consumption with every voltage source. Figure 2 describes the implemented Algorithm.
Current consumption of the Algorithm is measured using an USB Oscilloscope (Analog Discovery 2 [31]) and a Current Ranger [32].
The latter allows us to take precise current measurements, and also avoids the problem of burden voltage present in most Digital Multimeters (DMMs), whilst the former is used to measure the voltage provided by the current meter.
Figure 3 illustrates the measurement setup used for the oscilloscope. Time division is set until two periods are shown on screen (50 ms/div), resulting in a sample frequency of 5.1613KHz for Channel 1, taking 8192 samples. The voltage range was set to 100mV/div, offset set to 0 V and the sample mode as Average. It's important to note that oscilloscope input channels are equipped with Differential inputs. The current ranger has a hardware 7kHz RC Low Pass Filter at the output and will produce a clean smooth trace on the oscilloscope, very effective for current MCU measurements.
DIAdem [33] (National Instruments) is used to analyze the acquired signal. A waveform’s period is integrated to obtain energy (Joules), and also multiplied by its respective voltage source to obtain the period’s electric charge (Coulomb). A close view of the waveform signal in deep sleep mode just before restarting is shown on Figure 4, the red signal corresponds to a voltage of 3.7volts, the blue signal is when using 5 volts, and the green signal is at 9 volts.
Figure 5, shows one period of the waveform. The NodeMCU-32 runs the algorithm and starts on sleep mode, notice that before going to sleep a higher energy spike can be observed. The signal has an approximate duration of 300 milliseconds.
3. Results and discussions
Tables 3 through 5 show the mean current (in mA), mean energy (in mJ) and mean charge (in mC) obtained for every power source applied. The mean current consumption applying 5v is 4.35% less than using a 3.7v supply, something similar happened when comparing 3.7v and 9v sources, the current consumption is 7.86% less than 3.7v. This current variation may be caused by the voltage regulator. But evaluating energy (Joules), when using a 5v source yields 27.98% more energy than 3.7 battery source. Using a 9v source, the energy consumption is 119.7% higher than 3.7v. Furthermore, analysis of electric charge (Coulombs), shows that electric charge when using a 9v source will be 9.8% less than 3.7v, and 5v will be 5.8% less than 3.7v.
Voltage | Current | ||
Mean | Min | Max | |
3.7v | 57.03 mA | 24.28 mA | 254.4 mA |
5v | 54.55 mA | 8.4 mA | 381.2 mA |
9v | 52.55 mA | 19.89 mA | 295.6 mA |
Voltage | Electric charge (Coulomb) | ||
Mean | Min | Max | |
3.7v | 7.41 mC | 0 mC | 17.03 mC |
5v | 6.99 mC | 0 mC | 16.20 mC |
9v | 6.69 mC | 0 mC | 15.66 mC |
Voltage | Energy (Joules) | ||
Mean | Min | Max | |
3.7v | 27.43 mJ | 0 mJ | 27.43 mJ |
5v | 34.98 mJ | 0 mJ | 81.31 mJ |
9v | 60.28 mJ | 0 mJ | 140.99 mJ |
Table 3 shows the real current consumption, electric charge consumption and energy consumption for sending data through the internet of the NodeMCU-32 with every power supply. It is important to note that the internal linear regulator is operating when using 5v and 9v power sources. For 3.7v the regulator is not active.
By finding the electrical constants, we can estimate the duration of the device in operation, we can use the following equation:
Equation 1. Estimated time of work
We perform the analysis for each voltage source, using the same capacity of 500 mAh, we can observe in table 6 the estimated time in which the algorithm could be running.
Using the electric charge, we can give an estimate of how many messages are possible to transmit through MQTT, where we first need to find the charge in the batteries we are using, as shown in table 7. We perform the analysis assuming all power sources with a capacity of 500 mAh.
Battery | mAh | Coulomb | Messages |
3.7v | 500 mAh | 1800 c | 242.91k |
5v | 500 mAh | 1800 c | 257.51k |
9v | 500 mAh | 1800 c | 269.05k |
Looking at table 7, we can determine that it is possible to send approximately 242.91k data in messages with a battery of 3.7v and 500mAh, this may or may not be enough depending on the application. Using the other power sources, it's possible to send 257.5k data messages using a battery of 5v and 500 mAh, and 269k data messages using a battery of 9v and 500mAh.
The Developer/Designer has to contemplate the amount of data to send. This information could help estimate the time of duration of the developed application.
2. Future work
For further research, we plan to analyze the NodeMCU-32 when it Wakes Up. During tests, we notice that some peripherals (input/output) have been initialized into a logical high state, which represents an energy consumption issue. If there is an alternative to optimize energy consumption without modifying the initial algorithm, it will be the first step for a proper energy efficiency analysis. Furthermore, we also plan to apply the methodology of this paper to analyze different IoT MCU Boards, to see if there is a significant difference in energy consumption.
4. Conclusion
The microcontroller NodeMCU-32 suitable for IoT applications has been tested sending data through the internet using three different commercial power supplies, 3.7v, 5v and 9v. The higher current consumption was using 3.7 battery, followed by the 5v and the lowest current consumption was when using 9v. More voltage yields less current consumption; however, this does not mean less energy consumption, results demonstrate that when using 9v the energy consumption is two times higher than using 3.7v. The best option for energy optimization without modifying the algorithm for NodeMCU-32 when sending data will be using a 3.7v Li-po Battery.