# Real-Time Human Activity Recognition on Embedded Equipment: A Comparative Study
## 5 Results of Implementation
### Implementation on STM32 and ESP32 with MicroPython  
The objective of this section is to study the performances of the algorithm on STM32-NUCLEO H753 ZIT6 and Espressif ESP32 microcontrollers for the longer activity period (Sleeping in this work). MicroPython is an optimized implementation of the Python 3 programming language that includes a small subset of standard libraries of Python and is optimized to run on microcontrollers and in constrained environments. It is packed full of advanced features such as arbitrary precision integers, interactive prompts, generators, list comprehension, closures, exception handling, and more. It runs on microcontrollers in constrained environments within just 256 k of code space and 16 k of RAM. Table 10 presents the processing time and the memory used by the algorithm coded with MicroPython. \begin{table}
\begin{tabular}{c c c} \hline \hline  & **STM32** & **ESP32** \\ \hline Processing time & 0.01 s & 0.15 s \\ \hline Memory & 9232 octets & 9232 octets \\ \hline \hline \end{tabular}
\end{table} 
Table 10: Performance Comparison of MicroPython on STM32 and ESP32 for Long Sleeping Period. From experimental results, the following interpretations can be drawn:  
1. For STM32: * Period of long activity in the dataset: The device is in a low-power state (sleeping) from t = 00:03 to t = 05:40. * Processing time: During each time step within the sleeping period, the algorithm takes 0.01 s to process. * Used memory: The amount of memory used by the algorithm is 9232 octets (bytes). 2. For ESP32: * Period of Sleeping activity: Similar to STM32, the ESP32 is in a low-power state (sleeping) from t = 00:03 to t = 05:40. * Processing time: During each time step within the sleeping period, the algorithm takes 0.15 s to process. This is significantly longer than the processing time on STM32. * Used memory: The amount of memory used by the algorithm is the same as on STM32, which is 9232 octets. From these results, we conclude that the processing time on ESP32 is 15 times longer than on STM32. The processing time difference between ESP32 and STM32 could be influenced by various factors, and the presence or absence of cache memory is one of them. The ESP32 features a two-tiered cache system: an instruction cache and a data cache. Caches are designed to improve memory access times by storing frequently accessed instructions and data. However, the algorithm used here does not benefit much from the cache function. Cache memory in STM32 is smaller compared to ESP32. Also, ESP32s and STM32s have different hardware architectures. ESP32s are based on dual-core microcontrollers and have more hardware resources, including a dual-core Tensilica Xtensa processor, which can increase processing time. The ESP32 microcontroller uses more hardware resources compared to some other microcontrollers such as multiple cores and various peripheral interfaces, there is additional overhead involved in managing and coordinating the utilization of those resources. For example, in the case of the ESP32's dual-core architecture, coordinating tasks between the two cores and ensuring optimal resource allocation can introduce overhead that affects processing time. The coordination between the cores of the ESP32 microcontroller is indeed facilitated by an onboard mini RTOS. This real-time operating system manages task allocation and scheduling across the dual cores, enabling parallel processing capabilities. However, it is important to note that the algorithm employed in the project is not specifically optimized to fully exploit this parallelism. As a result, the processing time is adversely affected, reflecting the need for more efficient utilization of the ESP32's resources. In addition, development tools, available libraries, and programming environments vary between the two platforms. Some tools or libraries may be optimized for a platform, which may affect performance.