Download as pdf or txt
Download as pdf or txt
You are on page 1of 6

instructables

SpeedTest: Arduinos - ESP32 / 8266s - STM32

by Fernando Koyanagi

Which microcontroller is faster: Arduinos, ESPs, or commands it to light a pinmode, runs a digitalwrite,
the STM32? This video examines this question, among other simple actions that we have done a
where I perform a speed test, the SpeedTest, with million times.
several devices running the same series of
commands. This test, therefore, has no scientific character, and I
don’t wish to berate the performance of any
Follow and see the result! microcontroller, but simply show the magnitude of
processing that each model has.
Our main goal will be to show how much time each of
the chosen microcontrollers spends to execute a We performed and compared with a million iterations,
series of commands of a simple program. We will and my result resembled what Chester found in some
perform this test with a program that will execute one respects. For example, the ESP32, per core, was 60
million iterations and, from the iteration of 100,000; times faster than the Arduino Uno. In Chester's case,
we will execute commands so that the internal led he did a Divide Float, that is, a floating-point
flashes. operation, and recorded 83,462 milliseconds for the
Arduino Uno against 1,398ms for the ESP. After
I found other speed tests with microcontrollers on the performing the calculations, this shows that the ESP
Internet, including one from Chester Lowrey, which is 59.7 times faster than the Arduino Uno. Contrarily,
produced this table below. I placed it here for you to there are some characteristics that show many
observe. similarities. For example, other parameters range
from 10 to 170 times the speed in the comparison
So I decided to perform my own test which is based between these two microcontrollers.
on a common program: it goes into loop repetition,
does a lot of loop comparisons, calls the function and

https://youtu.be/kRsEDeHI8cI

SpeedTest: Arduinos - ESP32 / 8266s - STM32: Page 1


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.

SpeedTest: Arduinos - ESP32 / 8266s - STM32: Page 2


SpeedTest: Arduinos - ESP32 / 8266s - STM32: Page 3
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)

SpeedTest: Arduinos - ESP32 / 8266s - STM32: Page 4


Step 4: Arduinos - ESP32 / 8266s - STM32

So how did we do the test? We ran the Loop a million Arduino One.
times and analyzed how many milliseconds each
microcontroller took for such actions. Our table above Another surprise I had was in relation to the
shows that the Arduino Uno took 4.920 milliseconds, performance of the STM32. The STM32F103C8T6
while the ESP32 needed only 164ms. and the STM32 Maple Mini had scores well above
Arduino Due. In terms of monetary values, the
The Problem of Making a Table using Milliseconds performance was even better. While the Arduino Due
costs on average R $130,00, the STM32 F103C8T6
A millisecond is inversely proportional to is in the range of $14.00, and has more IOs than the
performance. So, I normalized everything, that is, I Arduino Nano.
created an index: I got 10,000 and divided by T (time
and millisecond). The red bars of the table indicate In the case of the Arduino Mega, I was astonished:
this index. This means that the higher the bar, the the index was 1.38, the lowest on the list. I was also
higher the performance. surprised, in a bad way, about the ESP8266. I
thought it was much faster because of Clock, which
During the test, we had some surprises. I believe that goes from 80 to 160 MHz. Thus, I was disappointed
the Arduino Due was the most powerful of with its rate of 6.83, as I expected more. The best
microcontrollers due to its quantity of IOs. It’s Mega! performance was from ESP32, which has two Colors.
An ARM Cortex-M3! But, its index was actually below
my expectation, with little difference in relation to the

Step 5: Highlight of the Test

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

SpeedTest: Arduinos - ESP32 / 8266s - STM32: Page 5


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.

SpeedTest: Arduinos - ESP32 / 8266s - STM32: Page 6

You might also like