🛠 Console sur l'USB-C natif (USB-Serial/JTAG)

ESP32-C3 · debutant · Schéma : IMG-esp32-c3-debutant-3-console-usb-c-serial-jtag.svg — Câble USB-C branché directement sur le ESP32-C3, périphérique USB-Serial/JTAG reliant terminal série et débogueur

Objectives

Unlike the classic ESP32, the ESP32-C3 integrates a USB-Serial/JTAG controller: the board's USB-C port communicates directly with the chip, without an external UART bridge (CP2102/CH340). You will learn how to use Serial over this native USB, how to avoid blocking when no terminal is open, and you will get a glimpse of JTAG debugging via the same port.

Hardware

Complete code

void setup {
  Serial.begin(115200);            // sur C3 : Serial = USB-Serial/JTAG
  Serial.setTxTimeoutMs(0);        // ne JAMAIS bloquer si terminal ferme
  delay(1000);                     // laisse le temps d'ouvrir le terminal
  Serial.println(F("Bonjour depuis l'USB natif du ESP32-C3"));
  Serial.printf("Coeurs : %d, flash : %u Mo\n",
                1, ESP.getFlashChipSize / 1048576);
}

void loop {
  if (Serial.available) {
    String s = Serial.readStringUntil('\n');
    s.trim;
    Serial.println(s);             // echo de ce que vous tapez
  }
  delay(2);
}

Expected verification

Opening the terminal at 115200 bauds and then resetting the board displays the welcome message and "Cores: 1, flash: 4 MB". Everything you type is echoed back, passing through the same USB-C cable used for flashing.

Common errors

Other tutorials for this board

Code examples for this board

← Back to the board 🛠 All tutorials