**2.4 ESP32: Energy options**

Like many other microcontrollers, the ESP32 offers a wide range of power saving options. Its processor core is divided into different modules (radio module, main

*IoT on an ESP32: Optimization Methods Regarding Battery Life and Write Speed to an SD-Card DOI: http://dx.doi.org/10.5772/intechopen.110752*


#### **Table 1.**

*SD-card communication protocols and respective max write speeds [10].*


#### **Table 2.**

*Power mode and energy consumption of the ESP32 [11].*

processor core, and memory, cryptographic hardware acceleration, ultra-low-power co-processor with real-time clock and recovery memory), which can be switched off individually to save energy. **Table 2** lists the different power options of the ESP32 with the power consumption in the corresponding mode, according to the manufacturer's specifications.

#### **2.5 Comparison of ESP32 development modules**

Not only the processor contributes to the total energy consumption of a microcontroller but also all the peripheral modules like voltage regulators, sensors or external flash memory do so as well. Therefore, different developer modules using the ESP32 should be considered with regard to the total energy consumption in the respective power modes. **Table 3** shows the results of the measurements at the different power options.

The differences in power consumption between the different developer boards are considerable, as shown in **Table 3**. As a possible reason for the distinct deviation in power consumption, the built-in voltage regulators come into consideration since the

#### *Edge Computing – Technology, Management and Integration*


#### **Table 3.**

*Comparison of the energy consumption of different ESP32 developer modules [12].*

measured energy consumption exceeds the specifications from the data sheet by far. Voltage regulators are known to contribute significantly to the overall consumption of the system due to their quiescent current, which is especially noticeable in sleep states [13]. The voltage regulator of the FireBeetle ESP32, for example, has a maximum voltage drop of 0.31 V at 600 mA and a quiescent current of 4 μA, while the voltage regulator of the Adafruit HUZZAH32 has a voltage drop of 0.4 V at 600 mA and a quiescent current of 80 μA.

Nevertheless, the ESP32 itself is rather an energy-consuming. In consequence, the ESP32 family expanded by some more energy-efficient versions with the ESP32-S2 being the most interesting one for IoT applications. It provides almost all the known functionalities but comes as a single-core processor for less power consumption. The comparison of the ESP32 to the ESP32-S2 and its power consumption is summarized in **Table 4**.

The ESP32-S2 is an excellent choice for a variety of IoT applications, but the lack of an SD bus is a limiting factor in achieving an optimal combination of SD card write speed and power efficiency.

Now that the various options for writing to the SD card have been presented, as well as general and specific methods for reducing microcontroller power consumption, the next step is to review related work to evaluate the current best practice for power optimization in combination with high-resolution data acquisition.


#### **Table 4.**

*Comparison of power consumption between ESP32 and ESP32-S2 [11, 14].*

*IoT on an ESP32: Optimization Methods Regarding Battery Life and Write Speed to an SD-Card DOI: http://dx.doi.org/10.5772/intechopen.110752*

### **3. Related work**

One work that optimizes the energy consumption when writing data to an SD card was done by Bradley and Wright in which the energy consumption of the Arduino Atmega328P was determined at 5 V and 16 MHz and 3.3 V and 8 MHz [15]. In each case, the SD card communication was implemented via SPI. It was found that the lower clock rate resulted in a lower discharge. At 16 MHz the transmission time was 9–10 ms, while at 8 MHz, 15 ms was measured. Also, at 8 MHz, a slight delay in SD card response was observed. In deep sleep, the microSD card adapter used for SPI communication contributed significantly to the total power consumption. Without the SD card, 120 and 96 μA were measured, while 800 and 750 μA were measured with the SD card connected. To reduce power consumption, a BS170 power control N-channel MOSFET was used. This reduced the current consumption during deep sleep to 21.1 and 18.6 μA, respectively, which is a reduction factor of 40. However, this MOSFET also led to a reduction in the transmission speed for SD communication from 20 to 150 ms. Further work with higher clock speed and larger SRAM is announced [15]. This work demonstrated a good option to minimize power consumption when using SD cards but only if a low sampling or transmission rate is required.

Regarding optimizing the write speed to an SD card, we could not find any comparable work in the scientific literature, but a blog post has been written demonstrating the performance increase when using the SD bus on the ESP32 compared to the SPI and how this was achieved [16]. A difference of about 230% for write operations and about 400% for read operations was shown using the SD bus in 4-bit mode compared to SPI.

Similarly, only one paper was found that addressed the energy-efficient operation of an ESP32 [17]. This paper gives a best practice for using an ESP32 in an industrial wireless sensor network. The different operating modes of the ESP32, as mentioned above, are listed with a recommendation to switch between operation modes over time to perform tasks with the suitable operation mode. It is also noted that in active mode, energy efficiency can be further improved by adjusting the processor clock speed.

As shown in the introduction and related work, there has been scarce work addressing the requirements of microcontrollers for wearable IoT applications and optimizing communication to a local storage medium. This is certainly a niche area, but the steady growth, ease of access, and the resulting variety of use cases have shown that the evaluation of further optimization methods is nevertheless useful and relevant.

Therefore, in the following, possible approaches to optimize the speed of writing data to an SD card while taking power consumption into account will be investigated. In addition, possible methods for further reducing power consumption by making various adjustments to the ESP32's operating modes will be investigated and different microcontrollers will be compared.

#### **4. Material and methods**

This section lists all the microcontrollers used, the different operating states, power-saving measures, and SD communication methods, as well as the measurement methods and evaluation methods of each test.
