Intro to Embedded Rust Part 3: USB Serial Logging and Debugging | DigiKey
In this episode of “Intro to Embedded Rust,” we learn how to add USB serial communication to our projects (specifically for the Raspberry Pi Pico 2). We'll build on the blinking LED project from the previous episode to create a USB CDC (Communications Device Class) serial port, enabling you to send debug messages from your microcontroller to your computer. Print debugging is an essential skill for embedded development, and this tutorial shows you how to implement it in Rust using the usb-device and usbd-serial crates. The written guide for this episode can be found here: https://www.digikey.com/en/maker/tutorials/2026/intro-to-embedded-rust-part-3-usb-serial-logging-and-debugging The GitHub repository containing the Docker image and example code for this series can be found here: https://github.com/ShawnHymel/introduction-to-embedded-rust. Note that you can find my solution to the “read and convert to uppercase” challenge in workspace/apps/usb-serial/src/main.rs. This tutorial walks you through setting up USB communication on the RP2350 chip, covering how to configure the USB peripheral, create a USB device with proper VID/PID identifiers, and implement the CDC serial protocol for serial communication. You'll learn about the UsbBusAllocator for managing USB endpoints and buffers, the SerialPort abstraction for reading and writing serial data, and the UsbDeviceBuilder for device enumeration. We explore important embedded concepts like USB device descriptors, the Communications Device Class standard, and how your Pico 2 appears as a virtual serial port to your operating system. We also demonstrate non-blocking superloop architecture. You'll see how to structure a program that handles multiple tasks concurrently: polling the USB device for incoming data, processing received bytes, and sending timed messages every second. We explain Rust's Result type and match statement for explicit error handling, showing how pattern matching forces you to handle both success and error cases without relying on exceptions. The code also introduces time-based non-blocking operations using the Timer peripheral, demonstrating how to perform periodic tasks without blocking USB communication or other operations in your main loop. This USB serial debugging tutorial provides a practical template for embedded Rust development on the Raspberry Pi Pico 2, suitable for developers transitioning from Arduino, MicroPython, or C/C++ embedded programming. You'll understand how Rust's ownership system and type safety apply to hardware abstraction layers (HAL), how the rp235x-hal crate provides safe interfaces to RP2350 peripherals, and why explicit error handling matters in embedded systems.
Part List
| Image | Manufacturer Part Number | Description | Available Quantity | Price | View Details | |
|---|---|---|---|---|---|---|
![]() | ![]() | SC1631 | RASPBERRY PI PICO 2 RP2350 | 25972 - Immediate | $7.38 | View Details |






