BLYNK
HOME       📲 GETTING STARTED       📗 DOCS       ❓HELP CENTER       👉 SKETCH BUILDER

ESP32 4x SLOWER than ESP8266

esp8266
esp32
#1

Hello everyone!

I am wondering, why the ESP32 is slower than the ESP8266.

In my case I have several ESP8266 boards (NodeMCU V3, D1 Mini V2.3.0, D1 Mini Pro,…) and the DOIT ESP32 DEVKIT V1.

All the ESP8266 boards are at least 4x faster than the ESP32.

Only difference in code is:

For ESP32:

#include <WiFi.h> //Wifi
#include <WiFiClientSecure.h> //Blynk SSL
#include <BlynkSimpleEsp32_SSL.h> //Blynk SSL

For ESP8266

#include <ESP8266WiFi.h>            //Wifi
#include <BlynkSimpleEsp8266_SSL.h> //Blynk SSL
#include <ESP8266mDNS.h>            // for OTA

In the loop(), I am doing this:

  Blynk.run();
  ArduinoOTA.handle();  // For OTA updates
  timerMinutes();       // timer gets called every minute to control things
  timerSeconds();       // timer gets called every second to control things

  // some other blynk related functions here...

  // and finally the speed test
  speedcounter++;
  if (speedcounter >= 100)
  {
    speedcounter = 0;
    unsigned long currentSpeedCheckMillis = millis();
    Serial.println(currentSpeedCheckMillis - previousSpeedCheckMillis);
    previousSpeedCheckMillis = currentSpeedCheckMillis;
  }

If I have a look at the SerialMonitor, I get values about 9-11 (ms) from the ESP8266 NodeMCU V3 while the ESP32 only gives me 43-48 (ms) with sometime very slow ~120 (ms) every 5 seconds.

So one loop needs about 10/100 ms = 100µs for the ESP8266 while the the ESP32 needs about 45/100 = 450µs for the same task.

I am uploading the code with the Arduino IDE.
ESP8266 is set to 80MHz CPU frequency.

The funny thing is, that I can choose 160MHz CPU frequency for the ESP8266.
This makes it even faster and gives me values of 4-5 in the Serial Monitor.

There is no option availible for the ESP32, but the flash frequency is set to 80MHz.

To be fair, the ESP8266 is even faster than 4x (or 8x with 160MHz) , because serial communication is always slow.

How is this even possible?
Is the SSL communication the reason, why the ESP32 is so much slower - even if it should be faster?
Maybe it is integrated in a different way or perhaps its another reason I dont know.

I hope someone can give me more information :wink:

1 Like

#2

Are my problems really so advanced that nobody can help me?

0 Likes

#3

I’d rather suspect, this is not the correct place for such a discussion. ESP32 is much different platform as compared to ESP8266 and it would be better to ask developers of Arduino Core for ESP’s why such a difference. And the ESP32 is obviously less popular device on this forum for a simple reason: most users sees the ESP8266 as “good enough” for their needs, is better supported and cheaper (Yet the ESP’s 32 prices dropped significantly too)

2 Likes

#4

@Phil333 if you decide to take the question to another forum please post a link so that I can follow…very interested in this

1 Like

#5

@ marvin7: it just feels like any issue I have is not possible to solve/answer.

The ESP32 itself is not the problem.
Running the speedcounter without all the blynk stuff makes the ESP32 faster as expected (on Arduino IDE).
Thanks anyway

0 Likes

#6

The ESP32 did come out later in Blynk development, and was not as popular a device due to expressif’s own issues while slowly developing their Arduino Core… so yes, Blynk’s ESP32 library may not be up to Blynk’s ESP8266 library “standards”.

Now, with Blynk 2.0 on the horizon and support for this older version waning… we will just have to wait and see what will or will not get fixed in the future.

0 Likes

#7

It’s difficult to know, from what you’ve written, how much investigative work you’ve done yourself to try to narrow down the cause of the issue.

Personally, I think I’d try some of these things:

  1. Using different versions of the ESP32 core. If you’re running the latest version then try downgrading.
  2. Try other types of ESP32 dev boards from different suppliers
  3. Try Non SSL versions of the Blynk libraries.
  4. Check that there’s nothing ESP32 specific that can be switched off in your code to give more speed (turning BLE off for example).
  5. Look at forcing the ESP32 to use its multiple cores differently.
  6. Research if others are reporting issues in certain situations, to see if this a Blynk library issue of something else.

Threads like this one:


Might be useful when looking at how best to use the multiple cores.
I’ve seen another thread (but I can’t be bothered to search for it) where a community member ran Blynk code on one core and horrible code with blocking delays on another core, just to prove that it can be done without affecting Blynk’s operation.

Pete.

0 Likes

#8

I have the same issue with my PedalinoMini project. When I enable Blynk my PedalinoMini is not very responsive.
When I disable Blynk it is running very smooth.

Regards
alf45tar

0 Likes

#9

I an running my project on a NodeMCU and an ESP32 Wroom with different auth.
ESP32 is 4x faster than my NodeMCU and more stable.
the only weird thing with ESP32 is that I have to reset it , each time power shutdown.

0 Likes

#10

@PeteKnight:
Thanks for the infos!
I have already done a few of your suggestions, as I have:

    1. Tryed other types of ESP32 dev boards from different suppliers
    1. Tryed Non SSL versions of the Blynk libraries.
    1. Checked that there’s nothing ESP32 specific that can be switched off in your code to give more speed (turning BLE off for example).
    1. Researched if others are reporting issues in certain situations, to see if this a Blynk library issue of something else.

I will look and test the other ideas as well.

@Blynk_Coeur:
Can you give me an example of your code so I can verify and check it on my devices?
BTW: I also have a NodeMCU ESP8266 and a NodeMCU ESP32.

The reset appears also to me, but this is currently the least important thing.
It seems like it has something to do with not connecting to wifi after a normal power shutdown.
Maybe a delay on startup will help for this issue to give more time to get everything prepared for the wifi connection. (just a rough guess)

1 Like

#11

@alf45tar This OP seems to be more about whether the Blynk library support for ESP32 is as optimised as the one for ESP8266… and probably a difficult one to determine, as both devices are significantly different architectures from one another.

I don’t see your “issue” as being the same as this OP’s topic… ANY existing process will run slower, or seem less responsive if you add in another timing and communication intensive process to it… that is just common sense.

If you are having issues merging Blynk into your project, please create your OWN topic for it, not tagging into others, Thank you.

1 Like

#12

@Phil333 Not sure if this will assist you in your determination, but I added Blynk (a simple uptime display) to an existing test sketch that runs 24/7. It is just displaying time, date, loop count, random RGB values, CPU temp and RSSI on an LCD screen.

I did discover that adding Blynk.run() to the void loop() slowed it down some…

Without Blynk.run() - around 21500 loop cycles per second

With Blynk run() - around 9900 loop cycles per second

However… the Display widget in the App continued to work even without Blynk.run() in the loop :astonished: Some peculiarity with the ESP32 library?? (and NO, it is NOT anywhere else in the code… there is just a single Blynk command in the SimpleTimer based timed display loop…)

  Blynk.virtualWrite(V0, millis() / 1000);

So, when treating the ESP as a single CPU device at least… It seems Blynk does slow somthing down… but removing Blynk.run(), speeds it up without stopping App connection??? Test it and see in your case.

2 Likes

#13

Nice catch Gunner! :D:D

I will test it this evening and report the results.
Looks like the developement state is really “in progress” for the ESP32 :smiley:

EDIT: I couldnt hold myself for testing this…
Exact the same code except the left side has no Blynk.run(); in it.
Updates to the app every second.


Left side (no Blynk.run) is ~125 times faster!

This evening I will compare the ESP32 again to the ESP8266.
Looks like the table has turned now :smiley:

0 Likes

#14

maybe you can create 2 tasks using the xTaskCreatePinnedToCore() function :thinking:

0 Likes