🛠 Console série sur l'USB natif (CDC) du S3

ESP32-S3 · debutant · Schéma : IMG-esp32-s3-debutant-3-esp32-s3-console-usb-cdc.svg — Carte ESP32-S3 reliée par un seul câble USB à l'ordinateur, le moniteur série affichant des messages, la mention USB CDC On Boot Enabled visible dans le menu Outils.

Objectives

Master the serial console on ESP32-S3 via native USB. Unlike the classic ESP32, the S3 does not need a USB-to-serial bridge chip: it has both a USB-OTG controller (pins GPIO19/GPIO20) and a USB-Serial/JTAG peripheral. By enabling "USB CDC On Boot: Enabled", the Serial.print command outputs directly through the board's USB port. You will also learn the difference with the legacy UART0 (GPIO43 TX / GPIO44 RX by default) and how to regain access if the port disappears.

Hardware

Complete Code

// Console sur USB natif : outils Arduino -> "USB CDC On Boot: Enabled"
// (sur certaines cartes : "USB Mode: Hardware CDC and JTAG")
unsigned long t0 = millis;
uint32_t n = 0;

void setup {
  Serial.begin(115200);          // flux CDC, pas d'UART materielle ici
  while (!Serial && millis < 5000) {
    // attend que le terminal hote soit branche (max 5 s)
    delay(10);
  }
  Serial.println;
  Serial.println("ESP32-S3 : console sur USB natif (CDC)");
  Serial.printf("Chip: %s, %d coeur(s), %.0f MHz\n",
                "ESP32-S3", portNUM_PROCESSORS,
                (double)getCpuFreqMHz);
}

void loop {
  Serial.printf("[%4.1f s] message n=%u\n", (millis - t0) / 1000.0, ++n);
  if (Serial.available) {      // echo de ce que l'hote envoie
    char c = Serial.read;
    Serial.print("Recu: ");
    Serial.println(c);
  }
  delay(1000);
}

Expected Verification

The IDE serial monitor (or PuTTY/Arduino Serial Monitor at 115200) displays the header followed by one line per second; characters typed on the computer are echoed back. All this with a single USB cable, without an external serial bridge. The Windows Device Manager confirms the presence of a "USB Serial Device" when the board is recognized.

Common Errors

Other tutorials for this board

Code examples for this board

← Back to the board 🛠 All tutorials