🛠 Console série : câblage du connecteur 6 broches et pièges DTR/TX-RX

Arduino Pro Mini · intermediaire · Schéma : IMG-pro-mini-intermediaire-5-promini-console-serie-ftdi.svg — Arduino Pro Mini reliée à un adaptateur USB-série par le connecteur 6 broches, croisement TX/RX, capacité de 100 nF sur la ligne DTR/reset qui avale les premiers octets

Objectives

Master the Pro Mini's sole communication channel: the single hardware UART (pins 0 RX / 1 TX) connected to the 6-pin programming header. We will build a mini command console and understand the board's two legendary pitfalls: the TX↔RX crossover when wiring a custom adapter (CP2102, another Arduino), and the DTR auto-reset — one pin of the header is connected to the reset line via a 100 nF capacitor, so opening the port resets the board and the bootloader swallows the first bytes.

Hardware

Complete Code

// Mini-console serie : commande 'l' = LED, 'v' = valeur analogique
const uint8_t LED = LED_BUILTIN;

void setup {
  Serial.begin(57600);
  pinMode(LED, OUTPUT);
  // Patiente ~2 s : laisse passer le reset DTR + la fenetre du bootloader
  uint32_t t0 = millis;
  while (millis - t0 < 2000) { while (Serial.available) Serial.read; }
  Serial.println(F("Pro Mini prete. Tapez l ou v."));
}

void loop {
  if (Serial.available) {
    char c = Serial.read;
    if (c == 'l') { digitalWrite(LED, !digitalRead(LED)); Serial.println(F("LED toggle")); }
    else if (c == 'v') { Serial.println(analogRead(A0)); }
    while (Serial.available) Serial.read;   // vide le reste de la ligne
  }
}

Expected Verification

After opening the serial monitor at 57600 baud, the message "Pro Mini ready" appears approximately 2 seconds later: this is the trace of the automatic reset triggered by the 100 nF capacitor on DTR. The 'l' and 'v' commands respond immediately. By sending text BEFORE the bootloader finishes, we observe that the bytes disappear — the pitfall is observable and documented. With a simple FTDI cable (no DTR), there is no automatic reset: you must press the reset button just before uploading.

Common Errors

Other tutorials for this board

Code examples for this board

← Back to the board 🛠 All tutorials