If you have an Android phone or tablet and want to host a USB device such as an Arduino, you’ll need an On-The-Go (OTG) USB cable. You can purchase one online for a few bucks, but if you have a USB cable lying around collecting dust, you can use it to make your own. Read on below to see how.
Step 1
First, you’ll need two donor USB cables — one with a female type A end like you’d find on a USB extension cable, and one with a male micro B end. When you’re finished, you’ll have a cable that plugs into your phone on one side and accepts a standard USB cable on the other.
Cut your two donor cables to expose the red, black, white, and green wires within, and strip the insulation off the tips. Match the wire colors from both sides of your soon-to-be OTG USB cable and solder them together. Insulate the soldered joints from each other using shrink tubing, electrical tape, or hot glue. Be sure to connect the braided shielding as well, which is the uninsulated stranded wire that surrounds the four colored wires.
Step 2
After splicing the two cables together, wrap the junction in electrical tape for protection and strain relief. Since many Android phones are USB OTG devices, meaning they can act as the USB host or slave, you want the phone to be the USB host for this project. You can ensure it acts as such by means of a special sense pin on the micro B connector.
When the sense pin is connected to ground, the USB OTG device attached to the cable enters host mode. If the sense pin is left in its usual disconnected state, the USB OTG device will remain in slave mode.
Step 3
Carefully cut open the micro B end of your spliced cable and solder pins 4 and 5 together as shown in the diagram below. Once that’s done, reassemble the micro B plug and tape or glue it back together to complete your cable.
Step 4
To make sure everything is working as it should, run a test of your cable by connecting one end to your Android phone and the other into Arduino. If set correctly, the Arduino should power up. If not, unplug both ends of your cable and check for short circuits or any loose connections.
Be aware that you won’t be able to test the data connection until you get some code on both the phone and microcontroller.
Source: Makezine
Learn more about Electronic Products Magazine