Tell me more ×
Electrical Engineering Stack Exchange is a question and answer site for electronics and electrical engineering professionals, students, and enthusiasts. It's 100% free, no registration required.

The Android Accessory SDK relies on the accessory having USB host. However, my understanding is that newer versions of Android (3.1, 2.4?) have USB host support in the kernel. And I know many existing Android devices have hardware support for host (most tablets surely, Moto Droid, HTC Droid Incredible, etc.).

So my question is, given an Android device that has USB host, what will be the simplest/cheapest way to interface this with a micro? The first thing that comes to mind is using an FTDI USB->serial chip and a micro with UART. But I don't know if the FTDI drivers can be put on Android devices. Anyway, there's probably a much better solution.

I'd prefer a solution that doesn't require a rooted Android device, but would be interested to hear some of these options too.

share|improve this question
no link right now but I was watching this carefully and they are not planning to make Android support USB OTG or Being a host directly. This means that you really have to use their spec. – Kortuk Jul 12 '11 at 4:30
1  
Wow, that is crazy. Why would they not put usb otg/host into the kernel? Aren't tablet owners going to want to be able to use generic accessories? – Chinasaur Jul 14 '11 at 2:24
1  
Now I'm confused. The Android 3.1 API says explicitly that it supports interaction with both USB accessories (meaning things with host mode) and USB devices (things without host), including things like bulk transport, etc. So isn't this host mode running on the android system? – Chinasaur Jul 14 '11 at 2:37
1  
So it sounds like maybe getting a micro that can emulate a specific kind of USB device may be the easiest way to work with an Android device that has host capability. I don't know much about different standard USB devices; any links for a simple run down of the capabilities of different ones for interacting with the host? – Chinasaur Jul 16 '11 at 2:34
2  
@Chinasaur, Here's a list of all USB device classes: usb.org/developers/devclass_docs#approved Most USB micros have example code for HID (keyboard/mouse) and Mass storage. Perhaps you can use these to your advantage. Also, if you can write up an answer summary, it would be much appreciated. I think this info could be helpful to others wanting to go down this road. – Jon L Jul 29 '11 at 17:00
show 7 more comments

4 Answers

The cheapest way? Use a µC with USB built in. Many of the pic18 and upwards have this. So do many other makes of µC.

The simplest way? As you already state - convert it to RS-232 at TTL levels with some form of conversion chip like the FTDI.

Yes, there could well be problems with drivers for both solutions, but it is more likely the FTDI will be supported out of the box. However, the first solution has the advantage that you can make the µC look like whatever device you want it to look like.

Oh, and as an aside - some of the high end PICs (eg some pic32 chips) have USB host built in as well. Just thought I'd mention it...

share|improve this answer
1  
Why the down-vote? Some constructive criticism would be nice... – Majenko Jul 14 '11 at 20:38

I'm no expert on Android but FTDI released an app note detailing how you can build in driver support for their USB to Serial IC's into the android kernel.

I don't know if this is feasible to do on a production phone, or if any phones have this driver already built in (I doubt it). In my opinion, Google has laid out a good specification for Open Accessory which will most likely be available on this generation of Android devices and the next given that they all update to the newer Android OS versions.

In the Open Accessory case, the phone switches over to a device and the accessory is the host. Implementing an embedded USB Host is a bit more complicated than using an FTDI USB to Serial IC but there are some pretty good application-specific micros out there that have hardware support for the USB stack and there are some examples out there of the Open Accessory protocol implemented on some of these micros. Given that the support is already in the OS for Open Accessory (or will be in the near future for all devices), I think this is the way to go.

share|improve this answer
up vote 4 down vote accepted

Update: I switched this over to community wiki

It looks like Android is going to support USB Host in the kernel. Android 3.1 already has this, I think Android 2.4 will have it back ported, and surely Android 4 will have it. Therefore if you have a micro that can emulate an appropriate USB slave device, you should be able to communicate with Android fairly simply and cheaply as long as your Android device is hardware capable of USB Host. Most older devices (e.g. Droid, Droid Inc) are hardware capable, and new devices should be.

I don't know exactly which USB slave devices are easy to interact with from Android (here's a list of existing device types), but surely keyboard (i.e. HID) is an easy one to try.

There is an AVR library that provides a USB stack: http://fourwalledcubicle.com/LUFA.php. With this you should be able to do keyboard or other device emulation from a USB enabled AVR. Including this in your generic AVR firmware build is not too difficult. As Mihailo points out in the comments, make sure you use an oscillator frequency compatible with USB (8 or 16 MHz). I'm not sure whether it's possible to get this working on standard Arduino hardware.

It looks like the easiest way to approach this may be the new Arduino Leonardo board: http://arduino.cc/blog/2011/09/17/arduino-launches-new-products-in-maker-faire/

I'm sure cheaper/simpler/smaller Leonardo clones will come out soon, or roll your own!

share|improve this answer
ATMega8u2 is the cheapest you can go, ATMega32u4 is like a bigger brother (featured in Leonardo). For a minimal board you literally need 5 passive components to make it working. Also it has a DFU (Device Firmware Upgrade) Bootloader so you just plug it in a USB port for programming - no external programmer required. LUFA comes with lots of example drivers (Keyboard, Mouse, Joystick, ...) and it's dead simple to make and test them (and subsequently tailor them to your needs). Just make sure you use 8 or 16 MHz crystal, otherwise USB won't work. – Mihailo Sep 20 '11 at 8:31
All great points; thanks! By cheaper I mean an Arduino Leonardo compatible will come out cheaper than the official $20. But of course putting it together yourself is probably cheaper still and as you say pretty straightforward. I edited my answer to reflect some of your points. – Chinasaur Sep 20 '11 at 9:09
BTW, is this why Arduino is 16MHz? I always thought that was a weird choice... – Chinasaur Sep 20 '11 at 9:14
Probably it is, I'm not sure, older Arduino (the one I have) had FTDI USB to Serial chip, the newer ones have ATMEGA8U2. I haven't looked at schematics of the new ones, if they are using only one crystal I'd say it is because ATMEGA8U2 requires it. – Mihailo Sep 20 '11 at 14:33

Have you considered Arduino ADK board? It exploits Google ADK to achieve communication with Android.

share|improve this answer
Thanks, but the ADK requires the accessory to implement USB Host (thus it's much more expensive than a standard Arduino/micro). The idea of this question is to avoid implementing USB Host. – Chinasaur Sep 20 '11 at 12:32

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.