Making an iPhone Headphone Breakout Switch
Background
An iPhone user can use the Apple wired headphone switch to perform several actions, including ending a phone call. This project makes an electrical breakout, allowing another switch or a programmatically controlled relay to perform these actions. This can be used for automated testing of iOS apps that make phone calls.
The project could use an actual headphone or a fake headphone. I prefer an actual headphone, the earphones and microphone can still function. Also it may be more compatible with phone hardware and software.
Please note if you do this you could accidentally damage the phone or yourself. If you are careful I think the risks are low, but no warranty!
Headphone plug contacts and iPhone interpretation
The headphone plug has 4 contacts.
In order from the plug tip to the plug base, they are: - right audio output - left audio output - ground - microphone input
The phone interprets a resistance of roughly 5 kohms between the microphone input and ground as a microphone. Clicking the center switch on the headphone cord momentarily shorts the microphone input to ground.
Accessing the switch contacts
First approach: tap directly into switch
I didn't expose switch contacts. I felt even if I did get to the contacts, they would be too small to solder to easily. So I tried another approach.
Second approach: fake headphone
I got a headphone extension cord, cut off one end and attempted to solder some of the wires. The wires were very fine and it was difficult to mechanically strip the insulation. Soldering didn't work, too contaminated. I made a fake headphone using a screw terminal strip and a 5 kohm resistor from microphone input to ground.
After starting a phone call, manually shorting the microphone input to ground ended the call.
Third approach: breakout box and extension cable
Finally I realized the switch can go between the headphone plug and the phone jack. The breakout box connects an Apple wired headphone to a 4 conductor headphone extension cable. No need to cut into the headphone. Much easier! The breakout box exposes the microphone contact (farthest from the headphone plug tip) and the ground contact (second farthest from the headphone plug tip) to a coaxial jack. An external switch or programmatically controlled relay may plug in to the breaout box jack.References
Using a Raspberry Pi to end an iPhone phone call
iPhone Headset Wiring Diagrams
iPad / iPhone / iPod Touch Microphone Adapter Wiring Diagram
https://www.blackcatsystems.com/ipad/iPad_iPhone_iPod_Touch_Microphone_Wiring.html
Phone connector (audio) / PDAs and mobile phones / TRRS / CTIA / Apple
https://en.wikipedia.org/wiki/Phone_connector_(audio)
3.5 mm Headset: Accessory Specification. Android (iPhone uses CTIA pinout)
https://source.android.com/devices/accessories/headset/plug-headset-spec
Vetco Electronics
Parts list (partial)
Plastic enclosure, translucent blue, 60 mm x 35 mm x 20 mm, Hammond Mfg. 1551HTBU
https://www.hammondmfg.com/dwg9TBU.htm
Extension cable, 3.5 mm 4 conductor male to 3.5 mm 4 conductor male, length 6 feet, LKG Philmore MediaStar No. 71-1432
Coaxial splitter, 1 female to 2 males, (female unused)