🛠 Console série : câblage du connecteur 6 broches et pièges DTR/TX-RX
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
- 1 × Arduino Pro Mini (ATmega328P)
- 1 × USB-serial adapter: FTDI Basic (DTR wired, plugs directly onto the header) or CP2102/FTDI cable with 4 wires (VCC, GND, TX, RX)
- 4 × wires if using a custom adapter: VCC→VCC, GND→GND, adapter TX→RXI (pin 1), adapter RX→TO (pin 0)
- PC with a serial monitor (Arduino IDE, PuTTY, screen)
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
- TX/RX not crossed with a custom adapter: same symptoms as a wrong baud rate — "avrdude: stk500_getsync ... not in sync"; the FTDI Basic plugs in directly, a wired cable requires the crossover.
- Sending a configuration string as soon as the port opens: the bootloader intercepts the first bytes after the DTR reset; always wait for the ready message from the board.
- Forgetting a common GND between the adapter and the board: no characters pass through, even if TX/RX are correct.
- Powering VCC via the adapter: the adapter's 5 V goes to VCC (5 V model) — on the 3.3 V model, never send 5 V to VCC, as the VCC pin bypasses the regulator and powers the circuit directly.
- Wrong baud rate on the PC side: unreadable characters scroll by; 57600 corresponds to the factory bootloader's speed.
Other tutorials for this board
Code examples for this board
clignotante.inoArduinobouton-poussoir.inoArduinopwm-fade.inoArduinocapteur-lumiere-ldr.inoArduinoservo-balayage.inoArduinoruban-neopixel.inoArduino