Here is how you can do this with ESP-IDF directly (VSCode ESP-IDF extension) or PlatformIO.
I tested it on a ESP32-S3.
There are two thing you want to change:
- IDE serial monitor baudrate - the baudrate the IDE monitor is expecting.
- ESP32 console output baudrate - the baudrate of the ESP32 device for the UART used for console output.
Setting the IDE Serial Monitor Baudrate
For ESP-IDF extension, go to the settings, type esp-ifd baud rate
in the search box, you will get two results: "ESP-IDF Flash Baud rate" and "ESP-IDF Monitor Baud rate". The monitor is the one you are looking for. Set it the value you want e.g. 230400.
For PlatformIO extension, you can set the monitor speed by adding/changing the monitor_speed
option in platformio.ini, e.g. monitor_speed = 230400
.
Setting the ESP32 Console Output Baudrate
There are two ways I found.
1. Configure ESP-IDF sdkconfig File
To open a configuration editor, for ESP-IDF you can use the command ESP-IDF: SDK Configuration editor
(or the corresponding icon) or type idf.py menuconfig
(for PlatformIO pio run -t menuconfig
) in the terminal.
The configurations you want to change are:
- Component config -> ESP System Settings -> Channel for console
output:
Set it to Custom UART
.
- Component config -> ESP System
Settings -> UART peripheral to use for console output (0-1):
Set it
to UART0
.
- Component config -> ESP System Settings -> UART console
baud rate:
Set it to the value you want e.g. 230400.
P.S. The CONFIG_CONSOLE_UART_BAUDRATE option of the sdkconfig is no longer supported, see ESP-IDF Monitor.
2. Hard code the baudrate
The default console output is UART0
, so right at the beginning of the program add: uart_set_baudrate(UART_NUM_0, 230400)
:
#include "driver/uart.h"
void app_main()
{
uart_set_baudrate(UART_NUM_0, 230400);
// ...
}
When using this option, the serial monitor may output some garbage before the code reaches this line do to some init code logs that are sent before changing the baudrate to what the monitor is expecting.