Android OTG Development Interface
by ajoyraman in Circuits > Electronics
6023 Views, 45 Favorites, 0 Comments
Android OTG Development Interface
![001_CoverPhoto.jpg](/proxy/?url=https://content.instructables.com/F8B/WKL5/J76GEH7S/F8BWKL5J76GEH7S.jpg&filename=001_CoverPhoto.jpg)
![011_OTG_uP Hardware.jpg](/proxy/?url=https://content.instructables.com/F40/Y9BQ/J76GEK36/F40Y9BQJ76GEK36.jpg&filename=011_OTG_uP Hardware.jpg)
![003_PC Mode.jpg](/proxy/?url=https://content.instructables.com/FNE/AHNK/J76GEHFH/FNEAHNKJ76GEHFH.jpg&filename=003_PC Mode.jpg)
![002_Emulator Mode.jpg](/proxy/?url=https://content.instructables.com/FCR/V0H2/J76GEH84/FCRV0H2J76GEH84.jpg&filename=002_Emulator Mode.jpg)
I am developing a micro-controller based hardware which will connect to an Android phone using the On-the-Go (OTG) mode and would be powered by the phone.
The micro-controller is programmed using embedded-c and I have on the bread-board made an arrangement to change over from 'Program Mode' to 'Run' mode. I have used a set of DIP-switches to do this, as the D+/D- in 'USB-Mode' and the Program 'Data/Clock' on the processor use the same pins.
I find this convenient to quickly make changes in the software and immediately check out the functionality of the hardware.
On the Android phone end I found that it is often necessary to change over from the 'PC-Connected-Mode' where the APK program is downloaded from the PC to the device using 'Android Studio IDE' and the 'OTG-Mode' where the phone needs to be connected to the micro-processor hardware.
As the program development is an iterative process using the phone as a 'Hardware Emulator' the number of 'Connect/Disconnect' cycles was becoming excessive and I was very worried about damaging the connector at the phone end. This is very important as the phone is the most expensive hardware in the setup!
I have come up with a simple 'OTG Development Interface' which is presented here wherein the connection at the phone end is made permanently during a development session and the PC/micro-processor can be alternatively connected for 'loading the APK'/ 'executing the application'.
Safety is built-in to the hardware so that +5V from the PC cannot be fed to the Phone when it is in OTG mode.
Hardware
![004_Schematic.jpg](/proxy/?url=https://content.instructables.com/FSU/SFPU/J76GEH86/FSUSFPUJ76GEH86.jpg&filename=004_Schematic.jpg)
![009_Interface Bottom.jpg](/proxy/?url=https://content.instructables.com/FVR/80E0/J76GEHHL/FVR80E0J76GEHHL.jpg&filename=009_Interface Bottom.jpg)
![010_Interface Top.jpg](/proxy/?url=https://content.instructables.com/FHS/J40O/J76GEHHN/FHSJ40OJ76GEHHN.jpg&filename=010_Interface Top.jpg)
![005_JP2 Connected.jpg](/proxy/?url=https://content.instructables.com/F28/XCLU/J76GEH8E/F28XCLUJ76GEH8E.jpg&filename=005_JP2 Connected.jpg)
![006_JP1 APK Mode.jpg](/proxy/?url=https://content.instructables.com/FAA/JAMZ/J76GEI91/FAAJAMZJ76GEI91.jpg&filename=006_JP1 APK Mode.jpg)
![012_jumper Bridge.jpg](/proxy/?url=https://content.instructables.com/FE1/JCWA/J76GEKT5/FE1JCWAJ76GEKT5.jpg&filename=012_jumper Bridge.jpg)
The schematic shows the connections between the USB-Micro-B Plug which connects to the Phone Socket, the USB-A-Socket which connects to the micro-processor OTG hardware and the USB-Micro-B Socket for the PC-USB cable to connect.
The D+, D-, and Gnd lines are interconnected at the corresponding pins on all three connectors.
When JP2 is connected the USB-Sense wire is connected to ground putting the Android phone in OTG-Mode. When JP1 is connected +5V from the PC can be fed to the Android phone which along with D+/D- activates the Phone-PC connection-Mode.
It is not advisable to connect both JP1 & JP2 simultaneously as +5V from the PC /Charger would feed the phone when in OTG-Mode. (+5V can be fed only to Android devices that don't supply power to the micro USB port, but would otherwise be OTG capable.)
This is avoided by not using slide-switches and providing only one removable 'Jumper-Shunt-Bridge' so that the system would be in only one of the two modes.
This is a simple Safety built into the interface.
The pictures show the top/bottom views of the interface and the jumper connections.
While keeping the connection to the phone fixed , using this interface connect/disconnect can be made at the bread-board / PC end or at the Interface connectors as desired.
Getting the Connectors
![007_USB Micro B.jpg](/proxy/?url=https://content.instructables.com/FJ2/59LQ/J76GEH97/FJ259LQJ76GEH97.jpg&filename=007_USB Micro B.jpg)
![007_USB Micro Plug.jpg](/proxy/?url=https://content.instructables.com/F5T/PG40/J76GEH8J/F5TPG40J76GEH8J.jpg&filename=007_USB Micro Plug.jpg)
The USB-A Socket is fairly easily available but I found it difficult to get the Micro-B connectors.
Finally I succeeded in removing one connector from a scrap mobile phone card and the other from a PC-phone cable.
Interestingly the USB-Micro-B Plug from the cable uses only four of the five connections and the sense pin was cut away. I had to dig into the plastic to get at the sense contact. I soldered a wire to this to bring out this pin which is necessary for the OTG-mode.