🛠 Avoir une console série sur une carte sans pont USB (UART0)
Objectives
A minimalist RP2040 board (Zero, bridgeless Pico-clone) has no dedicated USB-to-serial chip: the MicroPython REPL or printf go through the RP2040's native USB. But when USB is occupied (HID device mode, battery power) or the USB pins are not soldered, the solution is UART: the RP2040 has two UARTs routable to any GPIO (RP2040 datasheet). You will wire up a USB↔TTL adapter and get an independent debug console.
Hardware
- 1 × generic RP2040 board
- 1 × USB↔UART TTL adapter (FTDI Friend, CP2102, CH340…) set to 3.3 V if selectable — the RP2040 uses 3.3 V logic
- 3 × wires: GP0 (TX0) → RX of the adapter, GP1 (RX0) → TX, GND ↔ GND (the two grounds must be connected!)
- Do not connect the adapter's VCC to the board's VSYS/3V3 if it is already powered by another source
Complete code
# main.py — REPL et print sur UART0 (GP0=TX, GP1=RX), 115200 bauds
from machine import UART, Pin
import time
# Sur le port rp2, l'UART0 matériel est déjà écouté par le REPL :
# un simple reset suffit souvent à obtenir le REPL sur GP0/GP1.
# Pour un flux applicatif dédié :
uart = UART(0, baudrate=115200, tx=Pin(0), rx=Pin(1))
uart.write('Carte RP2040 prete (UART0 115200 8N1)\r\n')
compteur = 0
while True:
compteur += 1
uart.write('tick %d\r\n' % compteur)
if uart.any: # données reçues du PC
data = uart.read
uart.write('recu: %s\r\n' % data.decode(errors='replace'))
time.sleep_ms(500)
Expected verification
In your serial terminal (115200 8N1, picocom, PuTTY, Thonny), the tick N lines scroll by; a typed character is echoed back. Then open the MicroPython REPL on this UART (Ctrl-C): import machine works — you have a full shell without USB. The rp2 port's UART REPL runs at 115200 by default (MicroPython RP2 quickref).
Common errors
- TX connected to TX instead of crossing: TX to RX, the adapter listens while the board speaks.
- Forgetting the common ground: nothing, or garbled characters.
- 5 V adapter on a 3.3 V pin: the RP2040 is not 5 V tolerant, check the logic level before wiring — risk of damage.
- Wrong serial port on the PC: on Linux
ttyUSB0/ttyACM0, on Windows the adapter's COM port (Device Manager). - Confusing the application UART and the REPL: both share UART0; if your script monopolizes the UART, the REPL stops responding — release the bus (
uart.deinit). - GP0/GP1 pins already used by your setup: the RP2040's UART is mappable to any GPIO, choose other pins (
UART(1, tx=Pin(4), rx=Pin(5))).
Other tutorials for this board
- Piloter la LED RGB embarquée WS2812 d'une carte RP2040 générique
- Jouer une mélodie avec un buzzer passif et le PWM
- Afficher sur un OLED I2C SSD1306 et déboguer le bus
- Logger sur carte microSD en SPI (mode carte)
- Interruptions GPIO et alarmes matérielles avec le Pico SDK
- Transformer la carte en clavier USB HID avec TinyUSB
Code examples for this board
clignotante.pyPythonbouton-interruption.pyPythonpwm-servo.pyPythonlecture-adc.pyPythonneopixel.pyPythonoled-i2c.pyPython