PlatformIO Community

Webserver ESP32 fails and in arduino IDE it works


i was working on ESP32 with WIFI and MQTT and that worked.
Very simpel begin , just switch on and off a LED on GPIO pin, by subscribing to the topic and publish on or of.

When i wanted to extend the code with webserver and configured lib dependencies it compiled but when i go to the IP address of the device in a web browser it crashed.
So got in contact with the designer of the library and got as feedback that platformio had some issue’s , he asked me to load the code in Arduino IDE which i did and it compiled and works for days now.

The link to the github discussion is the following:
[WebServer** example
WiFiWebServer/examples/WebServer at master · khoih-prog/WiFiWebServer · GitHub)

The ticket that i filed

The comment that i got back from him when i asked the differences between Arduino IDE and Platformio i got the following answer:

The conclusion of this is that platformio is not compatible

IMO, PIO is not totally mature yet, and must require more knowledge and skills to manually configure / modify the settings of PIO as well as related libraries, or receiving compiler errors. This currently is the price you have to pay for better debugging environment, if necessary or a must.

We’re still waiting the days PIO can compile as easily as Arduino IDE, without changing anything internally to the libraries’ settings.

You can contribute to PIO by posting an issue in PIO Forum and make that day closer.

It’ll be beneficial if you’d post the link here after having created the PIO Forum issue.

I think the proof is delivered when compiling the same project with Arduino IDE and it works right away.

Anyone tried this code example on a ESP32 Heltec Wifi Kit 32 ?


Can we get a short summary of what Arduino-ESP32 core version you work with in the Arduino IDE (Tools → Board → Board Manager → esp32) and what version of the library you’re working with?

What platformio.ini are you using? What is the “PLATFORM: ESPRESSIF32 x.x.x” version that appears in the console when you press Build?



I use with board manager Heltec ESP32 series dev boards 0.0.5
Library is Wifi Webser 1.8/.0
Arduino IDE version 1.8.19

In platformio.ini is :slight is:

platform = espressif32
board = heltec_wifi_kit_32
framework = arduino
upload_port = COM[5]
debug_tool = esp-prog
debug_init_break = tbreak setup
lib_deps =
    256dpi/MQTT @ ^2.5.0
monitor_speed = 115200
monitor_rts = 0
monitor_dtr = 0

PLatform version:

PLATFORM: Espressif 32 (5.0.0) > Heltec WiFi Kit 32

Okay so you’re not using Arduino-ESP32 directly but the Heltec version from Heltec ESP32+LoRa Series Quick Start — Heltec Automation Docs V0.0.1 documentation? Then there are big differences with PlatformIO, since it always uses the Arduino-ESP32 version for all ESP32 boards, including the Heltec ones, because these board variants exist there too. The rest of the core logic may have differences of course.

To have any fair comparison with PlatformIO at all, you would need to select the Heltec WiFi Kit 32 from the Arduino-ESP32 2.0.3 in the Arduino IDE, as that is what the platform-espressif32 5.0.0 is using.

Let me have a quick look on how to integrate the Heltec core version with PlatformIO… there was a topic about this not too long ago.

Okay a related but not exactly equal topic is the M5stack Paper help, helloworld does not execute, default platform.ini seems broken. I have a working guess with using M5Stack boards with their M5Stack core fork instead of Arduino-ESP32. Fundamentally it’s the same concept with the Heltec fork.

But wow, what a horrible core to work with. The 0.0.5 and 0.0.6 board package (so, you’re using an outdated version btw.) referenced here are some version of Arduino-ESP32 but with the original version info and all PlatformIO related things (package.json + builder scripts) erased. Not nice.

  1. Can you check whether your program still works with Heltec 0.0.6 version in the Arduino IDE?
  2. Can you check whether your program still works with Arduino-ESP32 2.0.3 in the Arduino IDE?

i will to that tomorrow.

i am new to the ESP32 in Arduino IDE
I made other project with 2812B led strip with FasLed in platofrmio and no error’s
I use platgormnio because of the JTAG debugging feature , wich can not be done in Arduino IDE or can it?

I’ve see the YT video of Dave’s Garage (Dave Plummer , former MW systems engineer) and he made a couple of video’s about VSC+Platformio and the debugging capabilities.

He also uses the VSC+ platformio as his platform.
So i thought i will build the webserver also with platformio not anticipating this kind of behaviour.

I did the setup that was suggested on this link:

did this

compiled it and it runs.

I need, some guidelines how to implement this in Arduino IDE.
need a link .

But then that already is Arduino-ESP32.


platform =

and upload the program again. Does it behave the same?

Also when you write

void messageReceived(MQTTClient *client, char topic[], char Message[], int Message_lentgh)
  Serial.println(String("incoming: ") + String(topic) + " - " + String(Message) + "\n");

that’s not particularly safe, you’re ignoring Message_lentgh. I don’t know if it’s garuanteed that Message will be NUL-terminated. So cnostructing a String(Message); is dangerous – you should do String m = String(Message, Message_lentgh); and use that.

Idid not write that myself.
is demo code, i changed that and made use of the length.

I used the demo code to see how it is being used and later i will rewrite that and put stuf in functions.

But i wanted to test this to see if it would work.

I indeed saw that the length was ignored which is not good.

i dont’s use char pointer also but rather do something like:

char message[]=“this ia a test”;

can use reference in c++.

But with the examples there’s always somehting wrong with that.

i mostly read the lib doc and do it myself.