ESP32 not working with 115200 buadrate

Hi I recently switched to PlatformIO from Arduino IDE. I am trying to program an ESP32 dev board but whenever I change the baudrate to 115200 (by setting monitor_speed = 115200 in the ini file) the serial monitor or terminal doesn’t print the expected output. Also with the 9600 baudrate the response is sometimes unreliable. I have tried restarting the IDE, unplugging and replugging the cable but it doesn’t make any difference. Strangely, it works without any issues in the Arduino IDE at whatever baudrate I choose. So I wonder what could be the issue. Could you please help me find the issue. Thanks.

I have made the experience that it’s good practice to set baudrate as well in platformio.ini as in your code (with Serial.begin)

I have done that. Both in the platform.ini as well as in the program itself (Serial.begin(9600)) but it seems like the terminal has problem with the higher baud rates. It works (mostly) with 9600.

Strange - for me it works even with 921600 baud:

Writing at 0x00030000… (100 %)
Wrote 276080 bytes (131746 compressed) at 0x00010000 in 3.2 seconds (effective 681.4 kbit/s)…
Hash of data verified.

Hard resetting via RTS pin…
============================================================ [SUCCESS] Took 16.01 seconds ============================================================
— Available filters and text transformations: colorize, debug, default, direct, esp32_exception_decoder, hexlify, log2file, nocontrol, printable, send_on_enter, time
— More details at Redirecting...
— Miniterm on /dev/ttyUSB0 921600,8,N,1 —
— Quit: Ctrl+C | Menu: Ctrl+T | Help: Ctrl+T followed by Ctrl+H —
ctor (OneCall-Impl)

filter: 927
doc: 3697

dtor (OneCall-Impl)
ctor (OneCall-Impl)

filter: 927

both in a native terminal (xterm) and in vscode