What is USB OTG and when would an embedded device need it?
USB OTG (On-The-Go) is a supplement to the USB specification that allows a single USB port to function as either a host or a device, with the role determined dynamically. Standard USB has rigid roles: a device is always a device and a host is always a host. OTG relaxes this constraint, enabling two OTG-capable devices to negotiate which one acts as the host for a given session.
The role negotiation uses the ID pin on the USB micro-AB or Type-C connector. When a cable with a micro-A plug is inserted (ID pin grounded), the port assumes the host role and supplies VBUS power. When a micro-B plug is inserted (ID pin floating), the port assumes the device role. OTG also defines the Host Negotiation Protocol (HNP), which allows the two connected devices to swap roles without physically disconnecting — for example, a digital camera that initially connects as a device to a PC can switch to host mode to talk to a printer directly. The Session Request Protocol (SRP) allows a device to request that the host turn on VBUS, enabling power-saving scenarios where VBUS is not continuously supplied.
An embedded device needs OTG in these scenarios: (1) A device that must connect to both PCs and peripherals — a handheld data terminal that acts as a USB device when docked with a PC (for data sync) but acts as a USB host when connected to a barcode scanner or printer in the field. (2) Direct device-to-device communication — two embedded devices sharing data without a PC intermediary, such as a camera printing directly to a PictBridge printer. (3) Debug and manufacturing versatility — a product that normally connects as a device to user PCs but switches to host mode on the factory floor to read test configuration from a USB flash drive.
The implementation cost is significant: the MCU needs an OTG-capable USB peripheral (not just device-mode), firmware must include both a device stack and a host stack (doubling the USB code footprint), and the hardware must include VBUS power supply circuitry with current limiting and overcurrent protection. For most embedded products, pure device mode is sufficient, and OTG is overkill. OTG is most common in Android smartphones, tablets, and feature-rich industrial handhelds.
Source: USB Q&A
