Pi Zero as a universal USB stick
Multitool

© Lead Image © besjunior; 123rf.com
In just a few simple steps, you can turn a Pi Zero into a universal USB flash drive that emulates storage, a serial port, Ethernet, and more.
Instead of taking along a separate USB gadget for every task, you can turn a Pi Zero into a universal device that provides storage, a network interface, and additional functions. This project relies on a rarely used feature of the Pi Zero: Its USB port supports USB On-The-Go (OTG). If you connect the small-board computer (SBC) to another computer, the Raspberry Pi logs in as a lower-level device (gadget).
Normally gadget mode [1] is undesirable. If you want to connect a memory stick to the Pi Zero, you need a special OTG cable; otherwise, it will not work (see the "How OTG Works" box). Conversely, plugging a normal cable into the USB port triggers the desired behavior.
In Figure 1, the USB cable is plugged into the left-hand USB port and is used both to supply power and exchange data. If you want to reproduce the project without much effort, just from the software point of view, you can skip the next steps.
[...]
Buy this article as PDF
(incl. VAT)