Introduction: SpeedTest: Arduinos - ESP32 / 8266s - STM32

About: Do you like technology? Follow my channel on Youtube and my Blog. In them I put videos every week of microcontrollers, arduinos, networks, among other subjects.

Which microcontroller is faster: Arduinos, ESPs, or the STM32? This video examines this question, where I perform a speed test, the SpeedTest, with several devices running the same series of commands.

Follow and see the result!

Our main goal will be to show how much time each of the chosen microcontrollers spends to execute a series of commands of a simple program. We will perform this test with a program that will execute one million iterations and, from the iteration of 100,000; we will execute commands so that the internal led flashes.

I found other speed tests with microcontrollers on the Internet, including one from Chester Lowrey, which produced this table below. I placed it here for you to observe.

So I decided to perform my own test which is based on a common program: it goes into loop repetition, does a lot of loop comparisons, calls the function and commands it to light a pinmode, runs a digitalwrite, among other simple actions that we have done a million times.

This test, therefore, has no scientific character, and I don’t wish to berate the performance of any microcontroller, but simply show the magnitude of processing that each model has.

We performed and compared with a million iterations, and my result resembled what Chester found in some respects. For example, the ESP32, per core, was 60 times faster than the Arduino Uno. In Chester's case, he did a Divide Float, that is, a floating-point operation, and recorded 83,462 milliseconds for the Arduino Uno against 1,398ms for the ESP. After performing the calculations, this shows that the ESP is 59.7 times faster than the Arduino Uno. Contrarily, there are some characteristics that show many similarities. For example, other parameters range from 10 to 170 times the speed in the comparison between these two microcontrollers.

Step 1: Microcontrollers That We Use:

Arduino Uno

Arduino Nano Atmega 328p

Arduino Leonardo Pro Micro

Arduino Mega ADK

Arduino Mega 2560

Arduino Due

STM32F103C8T6

STM32 Maple Mini

ESP12 ESP8266

ESP32 NodeS

Step 2: Results

Different architectures running the same code: Arduino IDE "GCC"

Here, we have the diagrams of ATMega328, ARM M3 STM32F103, and ESP32. These are all different microcontrollers. So, we have nothing scientific here because the architecture of the chips is different. But, we wrote a source code that compiles in all microcontrollers and runs in the same compiler: the GCC.

Step 3: Source Code

We ran several tests and came up with a program that was as simple as possible and could be represented on any microcontroller. So, in this source code I made A for 1 million. I also lit a LED. So, when you give 100,000, it goes into the alternator.

unsigned long inicio, tempoTotal;
unsigned long contador = ITERACOES; long int LEDcounter = 0; //contador de piscadas do LED boolean alternador = false; //controlador para alternar a ativação do LED digitalWrite(LED_BUILTIN, LOW); //desliga o LED long int i; inicio = millis();//guarda o tempo de inicio da execução do algoritmo //iterações for ( i = 0; i < contador; i++) { //verifica se o LED ja deve começar a piscar if (i+1 > FLASH) { LEDcounter++; if (alternador) { digitalWrite(LED_BUILTIN, HIGH); alternador = false; } else { digitalWrite(LED_BUILTIN, LOW); alternador = true; } } } tempoTotal = millis() - inicio; //calcula o tempo gasto na execução do algortimo (resultado em ms)

Step 4: Arduinos - ESP32 / 8266s - STM32

So how did we do the test? We ran the Loop a million times and analyzed how many milliseconds each microcontroller took for such actions. Our table above shows that the Arduino Uno took 4.920 milliseconds, while the ESP32 needed only 164ms.

The Problem of Making a Table using Milliseconds

A millisecond is inversely proportional to performance. So, I normalized everything, that is, I created an index: I got 10,000 and divided by T (time and millisecond). The red bars of the table indicate this index. This means that the higher the bar, the higher the performance.

During the test, we had some surprises. I believe that the Arduino Due was the most powerful of microcontrollers due to its quantity of IOs. It’s Mega! An ARM Cortex-M3! But, its index was actually below my expectation, with little difference in relation to the Arduino One.

Another surprise I had was in relation to the performance of the STM32. The STM32F103C8T6 and the STM32 Maple Mini had scores well above Arduino Due. In terms of monetary values, the performance was even better. While the Arduino Due costs on average R $130,00, the STM32 F103C8T6 is in the range of $14.00, and has more IOs than the Arduino Nano.

In the case of the Arduino Mega, I was astonished: the index was 1.38, the lowest on the list. I was also surprised, in a bad way, about the ESP8266. I thought it was much faster because of Clock, which goes from 80 to 160 MHz. Thus, I was disappointed with its rate of 6.83, as I expected more. The best performance was from ESP32, which has two Colors.

Step 5: Highlight of the Test

The highlight of the test, in my analysis, is the STM32.

Step 6: The Fastest

The champion in our evaluation, therefore, is the ESP32. It has the best performance with regard to the speed for running the program we created specifically for this test. And that's not to say that it's because it's dual core, because we use only one core in the evaluation. I’ll talk more about programming this microcontroller in an upcoming video.