**2. Background**

This section provides background information for comparing different approaches to writing data to an SD card or improving the power efficiency of microcontrollers.

It also provides an initial comparison of commercially available microcontrollers in terms of functionality and power consumption.

#### **2.1 Energy consumption of microcontrollers**

To get a basic understanding of microcontroller power consumption, the following formula illustrates the factors that contribute to the microcontroller power consumption [8]:

$$P\_d = f \text{CU} \mathbf{2} \tag{1}$$

*Pd*—Dnamic part of power consumption

*f*—CPU Clock-frequency

*C*—Total capacitance of the field-effect transistors (FETs) in the circuit *U*—Operating voltage

This relation shows that power consumption can be reduced by lowering the CPU clock-frequency *f*, the capacitance *C* or by decreasing the operating voltage *U* [8]. Since the power consumption is proportional to the operating voltage U squared, it seems to be obvious to initially reduce it as much as possible. Historically, early microprocessors used to run on a 5 V supply voltage. Since then, the voltage has been continuously lowered for that reason. In contrast, the maximum clock frequency has increased over the years to achieve a higher computing performance. However, this has also led to increased power consumption. Nowadays the strategy is to max out the clock frequency capability of a microcontroller while running on a significantly lower clock frequency [8].

The total capacitance is the sum of the capacitances of the individual field-effect transistors (FETs). Due to miniaturization, the FETs' individual capacitances have become smaller, but the number of FETs per processor's core continues to grow. The total capacitance of a given system, therefore, can only be reduced by switching off individual parts of the processor [8].

#### **2.2 General energy saving measures for microcontrollers**

Microcontrollers are usually optimized for an energy-efficient operation with a number of mechanisms to minimize energy consumption available. An energyefficient operation of the microcontroller is usually implemented without the need of an operating system, which means that the programmer has to give appropriate instructions in the application program. Most microcontrollers offer a flexible adjustment of the clock frequency as well as low-power or sleep modes. Depending on the architecture of the microcontroller, certain processor parts or peripheral components are clocked down, the operating voltage is lowered or even disconnected from the power supply. This results in the following rules for energy-efficient programming [5, 6]:


Before describing methods for implementing these rules, it is important to consider the SD card communication options in order to select a microcontroller that offers a good trade-off between power efficiency and write performance.

#### **2.3 SD-card communication**

An SD-Card (Secure Digital Memory Card) is a digital storage medium that works on the principle of flash storage. This section deals exclusively with standard SD-Cards with 9 pins. All information in this section is taken from the SD specifications of the SD-Card technical committee [10].

#### *2.3.1 Communication systems*

The host (microcontroller, card reader, laptop, smartphone, etc.) can access the SD-Card using either the Serial Peripheral Interface (SPI) or the proprietary SD bus protocol.

*SD bus:* Communication via the SD bus is based on command and data bit streams that are initiated by a start bit and terminated by a stop bit. Each message consists of a command, response, and data block tokens.


*SPI bus:* The SPI bus is a bus system consisting of three channels for serial synchronous data transmission. Microcontrollers mostly communicate with SD-Cards via the SPI bus. The SPI protocol does not allow all functions of SD-Cards, like energy saving functionality (e.g., low voltage). Additionally, the maximum transfer speed of the bus speed does not correspond to the maximum read/write speed of the used SD-Card.

#### *2.3.2 Write speed*

The maximum supported clock rate is decisive for the highest data transfer rate that can be achieved. Clock frequencies available for standard SD-Cards at the respective communication protocols are listed in **Table 1**.

Unfortunately, most microcontrollers only support the SPI bus for storing data on an SD card. However, the ESP32, which is widely used for IoT applications, supports both SPI and SD bus. For this reason, the features and power saving options of the ESP32 will now be examined in more detail.
