USB flash drives are everywhere. They’re cheap, they hold gigabytes, and every computer knows what to do with them. Until now, though, using them in Arduino projects took a lot of work. Want your board to show up on your PC as a drive? Want to plug a USB stick into your board and log data to it? Either way, you usually had to dig through USB stacks, SCSI commands and filesystem internals.
TinyMSC takes care of that. It’s an open-source Arduino library that implements USB Mass Storage (the “USB stick” protocol) in both directions.
Two roles, one library
🖥️ Device mode: your board is the USB stick
Plug your board into a PC, Mac or Linux machine and it appears as an ordinary drive. No drivers or special software are needed. What sits behind the drive is up to you:
- a RAM disk for quick, temporary file exchange
- an SD card, so you can pull logged data off a device without opening the case
- a remote disk over the network (NBD), exported to the PC as if it were local
- your own storage, if you provide a simple block driver
So a data logger can just appear as a drive. A configuration file can be edited in Notepad. A firmware asset can be updated with drag and drop.
💾 Host mode: your board is the computer
Turn it around: plug a USB flash drive into your board and read and write files on it. You don’t need an SD card slot, and you don’t need to fiddle with tiny cards.
- FAT12/16/32 and exFAT, which is what nearly every stick ships with
- ext2/3/4, for drives formatted on Linux
- Hot-plug safe: unplugging or swapping a drive is handled cleanly
- USB hubs, for more than one drive at a time
- On ESP32 and RP2040, a mounted drive becomes a normal Arduino
fs::FS, so code you already have for files keeps working
USB sticks cost little, hold a lot, and are much harder to lose than a microSD card. They also plug straight into any laptop to read the results.
Runs on the boards you already have
| Board | Host | Device |
|---|---|---|
| ESP32-S2 / S3 / P4 | ✅ | ✅ |
| Raspberry Pi RP2040 | ✅ | ✅ |
| STM32 (F4/F7 OTG_FS) | ✅ (small patch) | ✅ |
| SAMD21 / SAMD51, nRF52840 | ✅ via MAX3421E shield | ✅ |
| Classic ESP32, ESP32-C3/C6/H2 | ✅ via MAX3421E shield | – |
If your board has no USB host port of its own, a low-cost MAX3421E host shield adds one.
Designed to stay small and focused
TinyMSC does one job: the USB part. The filesystems come from two companion libraries, TinyFATFS (FAT/exFAT) and TinyEXT4 (ext2/3/4). All three use the same block driver interface. In practice this means:
- A storage backend you write once works for USB export, for SD cards and for network disks.
- A USB stick in host mode works just like an SD card driver, so your filesystem code doesn’t need to change.
- One include is all you need. The library picks the host and/or device classes that match your board and the USB mode you selected.
What you could build
- 📈 Plug-and-read data loggers: plug the board into a laptop and copy the CSV files off.
- 🎵 Audio and media players that play music straight from a USB stick
- ⚙️ Field-updatable devices: drop a new config file onto the “drive” and you’re done
- 🌐 Network storage bridges: a remote disk shows up as local USB storage
- 🐧 Embedded tools that read Linux-formatted drives with ext4 support
- 🗂️ Multi-drive setups behind a USB hub
Get started in minutes
TinyMSC comes with ready-to-run examples for both directions. They cover RAM disks, SD card export, listing files on FAT and ext4 sticks, reading and writing files, raw block access, hubs and MAX3421E shields. Choose the USB mode in your board’s Tools menu, open an example and upload it.
- 📦 GitHub: https://github.com/pschatzmann/TinyMSC
- 📖 Wiki & quick starts: https://github.com/pschatzmann/TinyMSC/wiki
- 🔧 Companion libraries: TinyFATFS · TinyEXT4
TinyMSC is MIT licensed, so you’re free to use it in hobby projects and in commercial products.
Give it a try, star the repo if it helps you, and open an issue to tell us what you built or which board you’d like supported next.
0 Comments