Cannot view serial monitor after compiling and uploading to ESP32S3

I am trying to upload a simple blinky code to ESP32-S3-DevKitC-1 and view the serial monitor.

void setup() {
  pinMode(LED_BUILTIN, OUTPUT);
  digitalWrite(LED_BUILTIN, LOW);

  Serial.begin(115200);
  Serial.println("Start blinky");
}

void loop() {
  ledON();
  delay(200);

  ledOFF();
  delay(200);
}

void ledON() {
  Serial.println("LED ON");
  digitalWrite(LED_BUILTIN, LOW);
}

void ledOFF() {
  Serial.println("LED OFF");
  digitalWrite(LED_BUILTIN, HIGH);
}

I am successful in compiling and uploading via the Arduino IDE 1.8.13 and viewing the serial monitor with the following settings with USB CDC on Boot Enabled: Dropbox - File Deleted

With arduino-cli I can also compile and upload successfully as the blinky LED can be seen, but I cannot view the serial monitor. The serial monitor is blank. I wonder if I should add certain flags or arguments to the compile command.

arduino-cli compile --fqbn esp32:esp32:esp32s3 ./

I suspect it's something to do with the extra flags for USB.
Thanks!

Hi @sayanee.

The default baud rate of arduino-cli monitor is 9600. So if the board is communicating at a different baud, as is the case here, you must configure the port.

Configuration is done via the --config flag. The format of the flag is like this:

arduino-cli monitor --config <ID>=<value>[,<ID>=<value>]...

You can learn the available setting IDs and values by running the arduino-cli monitor --port <address> --describe command. For example:

$ arduino-cli monitor --port COM7 --describe
ID        Setting   Default Values
baudrate  Baudrate  9600    300, 600, 750, 1200, 2400, 4800, 9600, 19200, 38400, 57600, 115200, 230400, 460800, 500000, 921600, 1000000, 2000000
bits      Data bits 8       5, 6, 7, 8, 9
parity    Parity    None    None, Even, Odd, Mark, Space
stop_bits Stop bits 1       1, 1.5, 2

From this we can see that the ID of the "Baudrate" configuration setting is baudrate. So if I want to monitor COM7 at 115200 baud, I run this command:

$ arduino-cli monitor --port COM7 --config baudrate=115200

Generally baudrate does not matter with the boards that use a native USB CDC port, so it is possible that none of the above is actually relevant for your particular problem. I don't have any experience with the ESP32-S3 boards. But anyway it is worth a try. If it doesn't work after setting the baudrate to 115200, please let me know and I'll see if I can help out.

Thanks @ptillisch!

I did 2 things, but the results are the same: the serial monitor was empty.

  1. I changed my code to Serial.begin(9600);
  2. I ran the command arduino-cli monitor --port /dev/tty.usbmodem14101 --config baudrate=9600

I am ok to keep it as Serial.begin(9600);. Wondering how can I enable the CDC USB on Boot in the arduino-cli command because in the Arduino IDE when I disable it, I also cannot view the serial monitor. Not sure, if this is the root cause.

Thank you once again!

OK, I guess I already had the suspicion the port configuration was not the solution. But maybe the information will be of use to someone using a non-native USB board who finds the post while searching for information.

Custom board options such as "USB CDC On Boot" are set via the FQBN you pass to arduino-cli commands via the --fqbn flag.

The format of the FQBN is like this:

<vendor ID>:<architecture>:<board ID>[:<menu ID>=<option ID>[,<menu ID>=<option ID>]...]

You can learn all the available menu IDs and option IDs for a given board by running the following command:

arduino-cli board details --fqbn <FQBN>

(where <FQBN> is replaced by the fully qualified board name of the board you are using)

For example:

$ arduino-cli board details -b esp32:esp32:esp32s3
Board name:            ESP32S3 Dev Module
FQBN:                  esp32:esp32:esp32s3
Board version:         2.0.4

Package name:          esp32
Package maintainer:    Espressif Systems
Package URL:           https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json
Package website:       https://github.com/espressif/arduino-esp32
Package online help:   http://esp32.com

Platform name:         esp32
Platform category:     ESP32
Platform architecture: esp32
Platform URL:          https://github.com/espressif/arduino-esp32/releases/download/2.0.4/esp32-2.0.4.zip
Platform file name:    esp32-2.0.4.zip
Platform size (bytes): 259715595
Platform checksum:     SHA-256:832609d6f4cd0edf4e471f02e30b7f0e1c86fdd1b950990ef40431e656237214

Required tool:         esp32:riscv32-esp-elf-gcc                                     gcc8_4_0-esp-2021r2-patch3   

Required tool:         esp32:xtensa-esp32-elf-gcc                                    gcc8_4_0-esp-2021r2-patch3   

Required tool:         esp32:xtensa-esp32s2-elf-gcc                                  gcc8_4_0-esp-2021r2-patch3   

Required tool:         esp32:xtensa-esp32s3-elf-gcc                                  gcc8_4_0-esp-2021r2-patch3   

Required tool:         esp32:esptool_py                                              3.3.0                        

Required tool:         esp32:mkspiffs                                                0.2.3

Required tool:         esp32:mklittlefs                                              3.0.0-gnu12-dc7f933

Option:                PSRAM                                                                                    PSRAM
                       Disabled                                                      ✔                          PSRAM=disabled
                       QSPI PSRAM                                                                               PSRAM=enabled
                       OPI PSRAM                                                                                PSRAM=opi
Option:                Flash Mode                                                                               FlashMode
                       QIO 80MHz                                                     ✔                          FlashMode=qio
                       QIO 120MHz                                                                               FlashMode=qio120
                       DIO 80MHz                                                                                FlashMode=dio
                       OPI 80MHz                                                                                FlashMode=opi
Option:                Flash Size                                                                               FlashSize
                       4MB (32Mb)                                                    ✔                          FlashSize=4M
                       8MB (64Mb)                                                                               FlashSize=8M
                       16MB (128Mb)                                                                             FlashSize=16M
Option:                Arduino Runs On                                                                          LoopCore
                       Core 1                                                        ✔                          LoopCore=1
                       Core 0                                                                                   LoopCore=0
Option:                Events Run On                                                                            EventsCore
                       Core 1                                                        ✔                          EventsCore=1
                       Core 0                                                                                   EventsCore=0
Option:                USB Mode                                                                                 USBMode
                       Hardware CDC and JTAG                                         ✔                          USBMode=hwcdc
                       USB-OTG (TinyUSB)                                                                        USBMode=default
Option:                USB CDC On Boot                                                                          CDCOnBoot
                       Disabled                                                      ✔                          CDCOnBoot=default
                       Enabled                                                                                  CDCOnBoot=cdc
Option:                USB Firmware MSC On Boot                                                                 MSCOnBoot
                       Disabled                                                      ✔                          MSCOnBoot=default
                       Enabled (Requires USB-OTG Mode)                                                          MSCOnBoot=msc
Option:                USB DFU On Boot                                                                          DFUOnBoot
                       Disabled                                                      ✔                          DFUOnBoot=default
                       Enabled (Requires USB-OTG Mode)                                                          DFUOnBoot=dfu
Option:                Upload Mode                                                                              UploadMode
                       UART0 / Hardware CDC                                          ✔                          UploadMode=default
                       USB-OTG CDC (TinyUSB)                                                                    UploadMode=cdc
Option:                Partition Scheme                                                                         PartitionScheme
                       Default 4MB with spiffs (1.2MB APP/1.5MB SPIFFS)              ✔                          PartitionScheme=default
                       Default 4MB with ffat (1.2MB APP/1.5MB FATFS)                                            PartitionScheme=defaultffat
                       8M Flash (3MB APP/1.5MB FAT)                                                             PartitionScheme=default_8MB
                       Minimal (1.3MB APP/700KB SPIFFS)                                                         PartitionScheme=minimal
                       No OTA (2MB APP/2MB SPIFFS)                                                              PartitionScheme=no_ota
                       No OTA (1MB APP/3MB SPIFFS)                                                              PartitionScheme=noota_3g
                       No OTA (2MB APP/2MB FATFS)                                                               PartitionScheme=noota_ffat
                       No OTA (1MB APP/3MB FATFS)                                                               PartitionScheme=noota_3gffat
                       Huge APP (3MB No OTA/1MB SPIFFS)                                                         PartitionScheme=huge_app
                       Minimal SPIFFS (1.9MB APP with OTA/190KB SPIFFS)                                         PartitionScheme=min_spiffs
                       16M Flash (2MB APP/12.5MB FAT)                                                           PartitionScheme=fatflash
                       16M Flash (3MB APP/9MB FATFS)                                                            PartitionScheme=app3M_fat9M_16MB
                       RainMaker                                                                                PartitionScheme=rainmaker
Option:                CPU Frequency                                                                            CPUFreq
                       240MHz (WiFi)                                                 ✔                          CPUFreq=240
                       160MHz (WiFi)                                                                            CPUFreq=160
                       80MHz (WiFi)                                                                             CPUFreq=80
                       40MHz                                                                                    CPUFreq=40
                       20MHz                                                                                    CPUFreq=20
                       10MHz                                                                                    CPUFreq=10
Option:                Upload Speed                                                                             UploadSpeed
                       921600                                                        ✔                          UploadSpeed=921600
                       115200                                                                                   UploadSpeed=115200
                       256000                                                                                   UploadSpeed=256000
                       230400                                                                                   UploadSpeed=230400
                       512000                                                                                   UploadSpeed=512000
Option:                Core Debug Level                                                                         DebugLevel
                       None                                                          ✔                          DebugLevel=none
                       Error                                                                                    DebugLevel=error
                       Warn                                                                                     DebugLevel=warn
                       Info                                                                                     DebugLevel=info
                       Debug                                                                                    DebugLevel=debug
                       Verbose                                                                                  DebugLevel=verbose
Programmers:           Id                                                            Name
                       esptool                                                       Esptool

Here we can see that the ID for the "USB CDC On Boot" menu is CDCOnBoot and the ID for the "Enabled" option is cdc.

So the full FQBN is:

esp32:esp32:esp32s3:CDCOnBoot=cdc

I think if you use that FQBN in the arduino-cli compile command then the communication with Serial Monitor will start working.

3 Likes

Thanks a lot, I can view the serial monitor!

Thanks, especially for taking the time to explain the FQBN format and the board details command which will come in handy for me in debugging similar issues.

You are welcome. I'm glad if I was able to be of assistance.

Regards, Per

1 Like

For me, the solution was... in the Arduino IDE (on Windows 10) on the Tools menu, set "USB CDC on Boot" to Enabled.

1 Like

Hi @ptillisch , I had the same issue as @sayanee , so i downloaded arduino-cli for windows , tha i had never used, compiled a ble sketch for esp32 board ( it takes lots of time as the arduino gui) , and if i compile the sketch with the suggested ```CDCOnBoot=cdc option , it works fine and i can see serial logs on a terminal .
However i wonder about this : is it possible to get the same result using the arduino ide ? WIth IDE i can compile and upload the sketch , it works exept the pitfall of usb serial interface not working. Any idea ?

Bye
Stefano B

Hi @okami00.

Yes. Select "Enabled" from the Tools > USB CDC On Boot menu in Arduino IDE. That has the same effect as using CDCOnBoot=cdc in your Arduino CLI command.


Not directly related to your question, but something that might be interesting to those reading this thread: The recently released Arduino IDE 2.1.0 has a nice enhancement of printing the FQBN of the board in the verbose compilation output. Although it is not necessary to know the FQBN when using Arduino IDE by itself, it can be useful when you want to replicate the same board configuration in your Arduino CLI commands as you had when compiling in Arduino IDE. Rather than having to look through the arduino-cli board listall and arduino-cli board details output to understand how to compose the correct FQBN, you can simply copy/paste the FQBN from the Arduino IDE "Output" panel.

@ptillisch , @garyinsandiego ,

I'm working on a ESP32-S3-DevKitC - the dual USB-C dev board (I think) Espressif designed. I'm connected to the "COM" port on the DevKitC. I'm working on Windows 10, using IDE 1.8.19. I've set the Tools menu, set "USB CDC on Boot" to Enabled.

The output screen says that it uploaded and does the "Hard resetting via RTS..."
The Serial Output does say the following immediately after uploading, but does not output the Serial.println() statements:

ESP-ROM:esp32s3-20210327
Build:Mar 27 2021
rst:0x1 (POWERON),boot:0x0 (DOWNLOAD(USB/UART0))
waiting for download

The same simple sketch works as expected on an ESP8266 NodeMCU and Pico-W.

EDIT: Totally my fault. Found another Internet reference saying I needed to use the USB port on the ESP32-S3-DevKitC board instead of the COM

1 Like

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.