---

Saturday, June 18, 2011

Android Open Accessory without charging the phone

I have been spending some time recently working on Android Open Accessory using an Uno and the Sparkfun USB host shield. I'm including a range of accessories, Geiger counter, ultrasonic distance meter etc. in my soon to be released (well Dec 2011) book Arduino + Android Projects for the Evil genius

Although the feature that the accessory should provide half an amp at 5V to charge the phone is all very well for AC outlet powered accessories, it means battery powered accessories need a big battery.

Or does it?

I decided to do a bit of experimenting with a surplus USB extension lead that came with a USB modem dongle and just extends the USB lead a couple of inches.

Firstly simply cutting the red 5V USB power lead. This stopped the accessory being recognised and the charge indicator on my Nexus One did not indicate any charging (no surprise there).

If, however, I put a 1k resistor in line on the red 5V wire, everything works fine as an accessory, but the phone does not draw anything significant from the accessories battery, allowing it to be powered from a small 9V battery. At least it does if the phone is well charged.

WARNING: This result was derived experimentally. This may well void your phone warranty, if you connect it up like this. It didn't hurt my phone, but do it at your own risk. Also your wire may not use the same color coding as mine did, so red might be the wrong lead for you.

The following sequence of photos shows the construction of the lead.

Carefully cut away some of the outer plastic with a sharp knife on one side and tease out the shielded bundle of wires.


Scrape a gap between the shielding to get at the +5V wire.

Cut the red wire and strip and tin the ends.

Solder the 1k resistor into place. Then wrap it all up with insulating tape. Wrap the part behind the tape carefully, so that there is no chance of the bare leads from either side of the resistor making contact with the shielding wires or foil.


About the Author
These are my books. Click on the image below to find out more about them.

15 comments:

Cefn Hoile said...

Nice work, Simon. Might have to dig into this world myself to be able to create a flight instrument of my own for paragliding, using the Android as a display, and possibly for GPS. It's reassuring to know that you can intervene to stop one battery pointlessly discharging another one.

Cefn Hoile said...

By the way, did you trace a UK supplier for the USB Host Shield boards, or are you shipping from Sparkfun in the US.

Simon Monk said...

Thanks Cefn, Yes I have bought a couple of USB host shields from www.skpang.co.uk

Pete said...

Has anyone tried this with a Nexus S? It did not detect the accessory when using a 1k resistor. I decreased the resistance and it started detecting (and unfortunately charging) the phone when I got under 10 Ohm. How much Voltage do you provide your phone with after the resistance? 5V?

Simon Monk said...

As I say, it only seems to work if the phone is fairly well charged. But it does mean that if the phone decides it wants more, it comes out of accessory mode rather than killing the battery.

Steve Marple said...

The USB standard defines the colour to be used for each wire, so it *should* be red in everyone's lead.

Simon Monk said...

Hi Steve, just been looking at your blog. Good stuff, but why did you move on from using a Mega?

P.S. Hope to see you at some future Lancaster event.

Steve Marple said...

I started developing my Calunium Arduino-clone because I needed more memory than available on the ATmega328 but wanted to retain the ability to make my own boards. The ATmega644P/ATmega1284P are the ideal compromise. I'm still using the Mega - at the moment its at work being used for a commercial product development.

Ytai said...

We found out about this problem in early stages of developing IOIO, as well as the resistor work-around.
However, as you're pointing out, the resistor also causes the VBUS voltage to drop, ultimately causing the Android to stop sensing USB. From experimenting with different Android devices we found that some phones are more sensitive than others (Nexus S being very sensitive for example). That's why on the IOIO we eventually chose a tiny trim-potentiometer, allowing you to manually tweak the current draw to the minimum the Android permits. You could obviously do the same on the cable hack, resulting in a "universal current limiting cable" :)

Simon Monk said...

Hi Ytai, good idea with the variable resistor. Its one of the features I like about IOIO. But, its still not the perfect solution, because if the phone's battery is low, it draws more current and you would really need to change the pot setting.
Ideally, you would need to control the voltage from the microcontroller, so that if the USB connection fails it can up the USB voltage automatically. Maybe an idea for the next IOIO?

DmitryDzz said...

I guess it doesn't work on my HTC Sensation :(
I found that when my phone is charged up to 80%, I need a 16K resistor to start the accessory detection. Unfortunately charging starts too.

EvilGL said...

Do you have any experience with HTC Desire?

I tried with a 1KOhm resistor and the phone still charges.

Then i tried with a variable resistor and the moment the device recognize the board, it also starts charging.

Simon Monk said...

Sorry, no experience of HTC Desire. I think every device is different.

DmitryDzz said...

A smart friend of mine suggested me to divide 5V by 1KOhm ;)
I think that's really hard to charge phone this way. So that is just animation of charging.

Sorry, I fogot to add this comment after my previous comment about HTC Sensation.
I used 10KOhm resistor in my project and I've got 0,5mA "charge" amperage. This amperage doesn't worry me :)

Dmitry Dzakhov

DmitryDzz said...

A smart friend of mine suggested me to divide 5V by 1KOhm ;)
I think that's really hard to charge phone this way. So that is just animation of charging.

Sorry, I fogot to add this comment after my previous comment about HTC Sensation.
I used 10KOhm resistor in my project and I've got 0,5mA "charge" amperage. This amperage doesn't worry me :)