How to fix PlatformIO serial monitor scrambled output
Problem:
When using the Monitor
function of platformIO, you see strange characters instead of strings being printed, for example:
)�
�␜ܠ��J��1��1!y��!���!��
Solution
This issue almost always appears due to the Monitor
function using the wrong UART speed. You can see from the log in our screenshot above:
--- Miniterm on /dev/ttyUSB0 9600,8,N,1 ---
that PlatformIO is using 9600
baud in this case - but your microcontroller is sending data at a faster speed (or, rarely at a slower speed).
Most firmwares using serial IO use 115200
baud, so that’s what I’d recommend to try first, but if that doesn’t work, look out for config options named baud rate or similar, or for lines of code like
Serial.begin(57600);
in the firmware.
In order to change the Monitor UART speed, open platformio.ini
and add
monitor_speed = 115200
Full platformio.ini
example for ESP32:
[env:esp32dev]
platform = espressif32
board = esp32dev
framework = arduino
monitor_speed = 115200
After that, restart the Monitor function.