PlatformIO Community

Serial monitor works when uploaded from Arduino IDE, but prints gibberish when uploaded from PlatformIO

When I upload my code from the Arduino IDE, the serial monitor in both Arduino IDE and PlatformIO works perfectly.

But when I upload my code from PlatformIO, the serial monitor in both Arduino IDE and PlatformIO starts to print out gibberish/garbage values.

Mind you that I have set both the Serial.begin() and the monitor_speed in the platformio.ini both to 9600, the same as it is in Arduino IDE.(I have tried other rates and sadly did not work).

#include <Arduino.h>

void setup()
{
  Serial.begin(9600);
}

void loop() 
{
  Serial.print("Hello\n");
  delay(1000);
}

This is happening with an esp32 which I soldered to a custom board.

I have another esp32 board from espressif which works perfectly in both PlatformIO and Arduino IDE.

Is there a pre-setup for PlatformIO to communicate with a fresh esp32? or is my custom board bound to scrap or is just incompatible with PlatformIO?

The first bootloader from the ESP32 output is at 115200, so that will definitely be gibberish. I think the Arduino IDE though tries to filter it out / supresses bootloader output from to the user, but PlatformIO does not. Can you change your 9600 to 115200 in both code + platformio.ini and reupload & re-monitor? Is the gibberish gone?

both

I am guessing that it cant handle the code being uploaded from Platformio? and Printed out these lines in both of the serial monitors.

But the code that was uploaded from Arduino IDE worked fine in both serial monitors.

If I press the EN button when on the Arduino IDE the same message from the Platformio pops up, but then continues to print hello in both monitors.

Which version of the Arduino-ESP32 do you have installed in the Arduino IDE board manager? 2.0.2 or 1.0.6?

Latest one which is 2.0.2.

arduino

Open a CLI and execute pio platform update espressif32. Upload + monitor the firmware again. Does it make a difference?

Which exact board configuration have you chosen in the Arduino IDE?

I’m guessing this how it’s done?

image

Sadly it didn’t work and has the same output as before.

I have chosen the ESP32 Dev Module in Arduino IDE.

Hm well it’s using the 2.0.2 core here too.

Try using platform = espressif32@3.5.0 in the platformio.ini (to use the 1.0.6 core). Does it work in PlatformIO then?

I set the baud rate to 9600 again which seems to write the weird characters.

image

But yeah it still prints the same weird characters.

Even when I choose to print an empty string, it still prints out the same characters over and over.

image

It seems that there is something wrong when the upload process starts.

Change monitor_speed = 115200. Are these messages from the bootloader?

if I set it to 115200 the following is printed:

image

Hm.

Add board_build.flash_mode = dio (docs) to the platformio.ini and re-upload. Is it working?

I’m guessing like this? but still no luck.

image

Hm. Can you take a screenshot of the Arduino IDE “Tools” menu that shalls all configuration?

Of course.

image

Just for fun, have you tried qio instead of dio?

1 Like

Along with

board_build.f_flash = 80000000L

to match the 80MHz setting there.

1 Like

Oh my god, you sir are a legend!

Setting it to 80MHz was the key along with the qio!

Never have I ever seen that communicating with a flash faster gets rid of problems, but I guess there’s always a first time…

If all settings were 1:1 equal (between Arduino IDE Tools and platformio.ini) and it would have still not worked, I would have directed you at Issues · platformio/platform-espressif32 · GitHub, but it’s solved now.

2 Likes