DIY Hands Free Kit

May 10th, 2011 by Strawp

A few years back I came up with the CarPC as a cheapass hacky way of getting MP3 playback integrated into my unspectacular car. Since then, the world of mobile has moved on a whole lot and the laptop stashed in my boot actually pales in comparison with the features (and power) of my Desire Z Android phone. Plus, I’m already syncing music with my phone, like I used to with my car PC and with Google Navigation I have a powerful satnav solution already at hand. All I really needed at this juncture was some kind of hands free setup.

Bluetooth control?

Grom Audio, who made the CD autochanger interface that I used for my car PC also make an autochanger interface which extends with a bluetooth module. This seemed like an unnecessary expense however – I already had the Car2PC autochanger interface which still acts as a high quality stereo input even without the USB control via the car head unit.

The official HTC headset

The headset that came with my phone has an integrated mic with three buttons: answer call/play/pause, next track and previous track. Wouldn’t it be cool if someone had worked out what the circuit inside that thing was? I googled around a while but in the end, one of my friends pointed me to George Smart’s Wiki, where he’d already sacrificed his headset and worked out a circuit diagram. This was massively useful, and given that the circuit consisted of a few cheap components, I thought I’d see

if I could give it a go and make a working copy.

Circuit prototype

If, like me you haven’t done any electronics since you were at school, it’s a good idea before you start soldering to get a prototype board. This is the Lego of electronics – you can stick components into the board without solder and switch things around if needed. I got the smallest prototype board I could find from Maplin for a couple of quid and had a circuit which gave the right resistances fairly quickly. The idea was to produce something I could plug my phone into on one end and would have stereo output and a mic connection so that any generic mic with a 3.5mm plug could be used with it. In addition to the components list on George’s wiki I needed an extra 3.5mm microphone socket, a 3.5mm stereo socket, a 3.5mm 4-pole plug (for connecting to the phone).

Now, it turns out the connecting to the phone part was problematic. The audio connection on HTC phones is pretty much the same as an iPhone. It’s compatible with a standard stereo heaphone connection (3.5mm 3-pole plug) but it has a third “control” ring on the plug which is used to carry the signal for the microphone. Shorting this signal (with the play button) sends the signal to the device to play music and the next/previous buttons simply send approximate voltage signals down the wire by varying the resistance slightly. In order for the controls to work I needed a 4-pole plug. You can get 3.5mm 4-pole plugs from Maplins, but holy crap are they fiddly to solder. I spent a couple of really frustrating hours trying to get four lots of wire to stick to the really unhelpful contact surface on the plug I bought. These were not designed for people whose GCSE in Technology a distant memory.

In the end I gave up and managed to find a much more solder-friendly 4-pole socket on eBay and got a pre-made male-to-male 4-pole plug cable (which you can even pick up in HMV these days).

Two resistances and a microphone

Here’s the part where I’m glad I used a prototype board first. I selected a reasonable looking tie-clip mic online that would handle calls and voice commands for the phone and plugged it into the circuit. Suddenly, the “next track” button didn’t work. What had transpired was that by adding what was effectively a 1.4 kilo-ohm resistor to the circuit in┬áparallel, I’d lowered the effective resistance when I pressed the next track button. This meant the phone interpreted it as “previous track”. To work around this, I needed to raise the resistance on the “next track” button. If you are trying this and get the problem, my method was to measure resistance across the mic with a multimeter, then using the resistors in parallel equation plug in the target resistance on the control wire (560 ohms) and the value of the other parallel resistor on the circuit. With a little help from ElectroDroid, this gave me a new resistor value to plug in (1 kilo-ohm, I think I went for) which then made all the buttons work with the mic attached.

Constructing the device

I guessed an approximate size for the circuitry, buttons and sockets and got a small project box from Maplin. For my first attempt at this, I figured I’d make life easy for myself and just put all the connections on top so tha

t I could work on cutting the holes to the right shape and getting everything to fit in, then I could just pop the circuit board into the box and screw the lid down.´╗┐

The photo is what I ended up with. From the left, the interface is:

  • Stereo audio out (to the car audio system)
  • 4-pole 3.5mm stereo audio and control I/O (the phone)
  • 3.5mm 2-pole mic socket (goes to tie-clip mic, which is going above the door frame in my car)
  • Previous track button
  • Play/answer button
  • Next track button

Seamless automobile integration AKA “The part with the duct tape”

So that’s all the bits working. Now to find a space in my car that I can fit this where it’s in easy reach, won’t get in the way and can be secured easily. In the end I went for the space just in front of my gear stick, mounting it next to the 12v power socket, over the top of the ash tray. The stereo cable for the car audio actually goes through the back of the car and plugs into the Grom Audio CD autochanger emulator. The mic cable is taped around the dash up the side of the windscreen and sits near the top of the door, in clear audible range. The phone is held in a generic phone mount on the top of the dashboard and plugged in to the 12v power (converted for the phone of course).

I might neaten it up. I probably won’t.

Extending the controls

Having the standard audio controls, plus the ability to take calls is all well and good, but what about being able to do other useful stuff with those 3 buttons? I’ve previously blogged an example of using Tasker with the Headset Button Controller app, so I won’t labour the point, but suffice to say with these two little gems you can pretty much tie or automate any Android task you need to with only 3 buttons at your disposal. I keep my Tasker profile checked into SVN if you want to borrow bits of code, and I’m changing it all the time but here’s some of the things I’ve used this setup for:

  • Press a button to activate voice commands (“navigate to cambridge”, “call home”, “listen to beastie boys” etc)
  • “Love” the currently playing track
  • Automatically start playing music when headset and power is attached (poor man’s dock mode)
  • Automatically read out incoming texts using text-to-speech
  • Announce callers using text-to-speech
  • Re-read the last text message
  • Call a specific person using a button press
  • Launch navigation to a specific place with a button press (i.e. the “oh shit, I’m lost” button)
  • Lock onto heat signatures and engage stinger missiles

So there we go. That’s the kind of car setup that you’re only just starting to see in new cars at the moment (at time of writing, ahem) and for complete pocket money.

2 Responses to “DIY Hands Free Kit”

  1. Gulraiz Says:

    Great work. I am really impressed. I am a biker and own a HTC desire hd and I have been looking for this kind of setup which I can use with my gloves on. Would you be kind enough to make me one of these tiny boxes please and save me from burning my self with the solder.

  2. Strawp Says:

    Sorry, I’m not going to be making and selling these. I don’t want to be responsible for the quality of my own soldering!