7 Best USB Device Stacks for Microcontrollers
Compare seven USB device stack options for microcontrollers, from Zephyr and FreeRTOS to Arduino and PlatformIO.
On this page
Key takeaways
- Zephyr and FreeRTOS ecosystems offer USB device support with TinyUSB and related stacks.
- Arduino and PlatformIO make USB device classes easy to try on maker boards.
- Espressif's newer ESP32 chips include native USB for direct device connections.
- MicroPython and CircuitPython turn a USB link into a live console and file drive.
Turning a microcontroller into a USB device
A USB device stack lets a microcontroller appear as a keyboard, mouse, serial port, drive, or custom device when plugged into a computer. The stack handles the protocol details, so your firmware only describes what kind of device it should be.
The sources below include the operating systems that bundle USB support, the ecosystems that wrap it in easy classes, and the Python firmwares where USB is the whole point of the experience.
Quick comparison
| Tool | Best for | Starting price | Free plan |
|---|---|---|---|
| Zephyr | Portable USB device classes | Not included | Not included |
| FreeRTOS | USB with TinyUSB pairing | Not included | Not included |
| Arduino | Easy USB device projects | Not included | Not included |
| PlatformIO | Managing USB projects | Not included | Not included |
| Espressif | Native USB on ESP32-S2 and S3 | Not included | Not included |
| MicroPython | USB serial and storage | Not included | Not included |
| CircuitPython | Drag and drop USB devices | Not included | Not included |
The best USB device stacks for microcontrollers
1. Zephyr
- Official site: https://www.zephyrproject.org
- Best for: Portable USB device classes
- Starting price: Not included
- Free plan: Not included
- Pros: Vendor neutral; Many device classes
- Cons: Learning curve; Larger system
Zephyr includes a USB device stack with support for common classes such as serial, mass storage, and HID. Because the stack is vendor neutral, the same device code runs on the many boards and chips Zephyr supports.
For products that need a custom USB device with a maintainable codebase, Zephyr's structure is a good fit. The stack is actively developed and covers both new and classic device roles.
The tradeoff is a real operating system to learn and configure. For teams already using Zephyr, the USB support is a natural extension.
2. FreeRTOS
- Official site: https://www.freertos.org
- Best for: USB with TinyUSB pairing
- Starting price: Not included
- Free plan: Not included
- Pros: Lightweight kernel; Pairs with TinyUSB
- Cons: No built in USB; You assemble the pieces
FreeRTOS itself is a real time kernel and does not ship a USB stack, but it is very commonly paired with TinyUSB, an open source USB device and host stack for microcontrollers. Many projects run TinyUSB tasks on top of FreeRTOS.
That combination gives you the scheduling of an RTOS with a capable, well tested USB stack. Because TinyUSB is open source, it supports a broad set of chips and device classes.
This is an assemble it yourself path compared with an all in one system. For engineers who want control, FreeRTOS plus TinyUSB is a popular and proven pairing.
3. Arduino
- Official site: https://www.arduino.cc
- Best for: Easy USB device projects
- Starting price: Not included
- Free plan: Not included
- Pros: Simple classes; Huge examples
- Cons: Limited to capable boards; Less custom control
Arduino boards with native USB, such as the Leonardo and Micro, can act as keyboards, mice, and serial devices using the built in libraries. A few lines of code turn the board into a USB input device.
The ecosystem includes many examples for HID, MIDI, and serial, which makes USB experiments approachable. The IDE handles the device descriptor work behind the scenes.
Not every Arduino board has native USB, so check the hardware before starting. For classic USB gadget projects, though, Arduino is one of the easiest paths there is.
4. PlatformIO
- Official site: https://platformio.org
- Best for: Managing USB projects
- Starting price: Not included
- Free plan: Not included
- Pros: Many frameworks; Consistent builds
- Cons: Indirect setup; Learning curve
PlatformIO manages the toolchains and libraries for USB projects across Arduino, Zephyr, and other frameworks. Instead of providing its own USB stack, it makes whichever stack you choose easy to build and flash consistently.
For a team that maintains several USB device projects on different boards, that uniformity saves real time. The same project file drives local builds and continuous integration.
PlatformIO adds a layer to learn, but it removes the mismatched toolchain problems that USB projects often hit. It is a strong companion to the stacks themselves.
5. Espressif
- Official site: https://www.espressif.com
- Best for: Native USB on ESP32-S2 and S3
- Starting price: Not included
- Free plan: Not included
- Pros: Built in USB; Active SDK support
- Cons: Newer chips only; Wi-Fi focus overall
Espressif's ESP32-S2 and ESP32-S3 include native USB, and the ESP-IDF supports USB device roles through TinyUSB and related components. That lets an ESP32 board plug straight into a computer as a serial device or other class.
The SDK provides examples for the common device classes, and the newer chips make USB a first class feature alongside Wi-Fi. For a connected gadget that also needs a USB link, this is a tidy solution.
The native USB only exists on the newer ESP32 variants, not the classic ESP32 or ESP8266. Within that range, though, the support is solid and improving.
6. MicroPython
- Official site: https://micropython.org
- Best for: USB serial and storage
- Starting price: Not included
- Free plan: Not included
- Pros: Live REPL; Simple file access
- Cons: Limited class choices; Slower runtime
MicroPython uses USB to present a serial console and a small file system on supported boards. You type into the REPL, edit files, and the board responds over the same USB cable, with no extra tooling.
That makes the USB link central to the whole MicroPython experience. For data logging and automation, copying files and watching output over USB feels effortless.
MicroPython's USB classes are focused on serial and storage rather than exotic device roles. For the common cases, though, it is a clean, immediate workflow.
7. CircuitPython
- Official site: https://circuitpython.org
- Best for: Drag and drop USB devices
- Starting price: Not included
- Free plan: Not included
- Pros: USB drive workflow; Multiple device modes
- Cons: Supported boards only; Less performance
CircuitPython is built around USB, showing the board as a removable drive while also offering serial, MIDI, and HID modes. Copying a Python file onto the drive updates the running program instantly.
The ability to switch between device modes from Python makes CircuitPython a favorite for custom keyboard and input projects. Adafruit documents the USB capabilities clearly.
CircuitPython runs on a curated set of boards and favors simplicity over raw speed. For teaching and USB gadget projects, that focus is exactly the point.
How we chose
We picked the operating systems that bundle or pair with USB stacks, the maker ecosystems that wrap them, and the Python firmwares where USB is central. Zephyr and FreeRTOS with TinyUSB cover structured, portable designs.
Arduino and PlatformIO make USB devices quick to build and manage, while Espressif brings native USB to its newer chips. MicroPython and CircuitPython round out the list with the friendliest USB experiences available.
FAQ
What USB classes can a microcontroller provide?
Common classes include serial, keyboard, mouse, MIDI, mass storage, and custom vendor classes, depending on the stack and chip.
Do I need native USB hardware?
Yes. The chip must have a USB peripheral, or you need an external USB to serial chip, to act as a USB device.
What is TinyUSB?
TinyUSB is an open source USB device and host stack used by many projects, often paired with FreeRTOS or other RTOS kernels.
Which option is easiest for a keyboard project?
CircuitPython and Arduino are the easiest, since both offer HID examples you can modify in a few lines.
Can an ESP32 act as a USB device?
The ESP32-S2 and ESP32-S3 have native USB and can, while the classic ESP32 and ESP8266 need a separate USB to serial chip.