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).
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?
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.