Enabling USB CDC on Boot on ESP32-C3 Devkit

I’m trying to get Serial communication working over the ESP32-C3’s built in JTAG/CDC interface but can’t seem to get it working. I’m just using a basic program to print “Hello World” to the serial monitor repeatedy. I can upload the code without issues, but the serial print statements in my code are not showing up in the serial monitor.

When I upload the same code from Arduino IDE after setting the “USB CDC on Boot” option to “Enabled”, everything works perfectly. However, I can’t figure out how to enable this setting in platformio. Below is the platformio.ini file that I’ve been using, and that seems like it should work based on other posts I’ve read here:

[env:esp32-c3-devkitm-1]
platform = espressif32
board = esp32-c3-devkitm-1
framework = arduino
upload_port = COM6
monitor_port = COM6
monitor_speed = 9600
board_flags =
-DARDUINO_USB_CDC_ON_BOOT=1

What do I need to add/change in my config file to get serial output to work properly? If it’s possible in Arduino IDE, I’m sure it’s possible using platformio, I’m just not sure what to do at this point. Any help would be greatly appreciated. Thanks.

3 Likes

I know this is a bit old, but I was struggling with this exact issue on my ESP32-C3-Devkit-M1. I went through a dozen posts over several days before I came across the solution.
For me, the critical addition appeared to be the change in monitor speed. I had been operating at 115200, but it did not work. The specific use of 460800 was noted here and that’s what made it work for me.

I hope this helps the next person!

[env:esp32-c3-devkitm-1]
platform = espressif32
board = esp32-c3-devkitm-1
framework = arduino
upload_port = /dev/cu.usbmodem323101
monitor_speed = 460800
build_flags = 
	-D ARDUINO_USB_MODE=1
	-D ARDUINO_USB_CDC_ON_BOOT=1    
3 Likes