There are 5 wires in the USB OTG interface: 2 are used to transfer data (D+, D-); 1 is the power wire (VBUS); 1 is the ground wire (GND), and 1 is the ID wire. ID wire --- to be used to identify the different cable endpoints, mini-A plug (i.e., A peripheral) in the ID pin ground, mini-B plug (i.e., B peripheral) in the ID pin floating. pin is floating. When the OTG device detects a grounded ID pin, it indicates that the default is device A (host), while a device that detects a floating ID pin is considered to be device B (peripheral).
The principle of OTG detection is:
The USB OTG standard is fully compatible with the USB 2.0 standard, with the addition of power management (power saving) features, which allow a device to operate both as a host and as a peripheral (dual-purpose OTG).USB OTG technology allows for the transmission of data from device to device when there is no host. For example, digital cameras can be directly connected to printers and print photos, and cell phones can directly transfer data to each other, thus expanding the range of applications of USB technology. In OTG, the initial host device is called A device and the peripheral device is called B device. In other words, the phone can be both a peripheral and a host to transfer data, the available cable connection to determine the initial role (determined by the state of the ID line).