Android 3.1 devices have USB host mode. Here's how to use it.

With the coming of Android 3.1 you finally have the option of using the device as a USB host. This may be through a USB OTG (On-the-Go) adaptor, but nonetheless it’s a feature which was sorely missed until now. [Manuel] put together a guide on using Android as a USB host. As you can see, his example hardware is an Arduino board but this is applicable with just about any device.

The tutorial implements a test app for the Android device where a slider will set the brightness of the Arduino’s on-board LED. The Arduino sketch is nothing special, it just reads data received on the UART. This means that it doesn’t care if it’s connected to an Android, PC, OSX, or Linux system, it goes about its business until the RX interrupt updates the data variable.

This will greatly simplify a lot of projects we’ve seen, such as this message scrolling belt buckle. That used extra hardware to make the Arduino the host, a step that is now necessary.

Comments

  1. Foxdie says:

    Just feel I need to point out, 2.x has had this for certain devices for a while now, my SGS2 for example has had it since the day it was released in the UK when I bought it.

    Nonetheless, it’s a useful feature to have 🙂

  2. Aaron says:

    ITYM ‘a step that is now unnecessary’?

  3. tz says:

    If you have a tablet it is usually easier, and the Toshiba Thrive (and maybe some others) have a full size USB port, and accepts keyboards, mice, and game controllers directly.

    More things have been discovered by the people at:

    http://www.thriveforums.org

    Including a supported ethernet chip – yes, a hardwired network! And you can use either prolific or FTDI USB serial adapters with the Slick USB app. You can probably alter the USB call as in the arduino example to talk to nearly any USB serial chip.

    Unrooted the Thrive does exFAT, rooted it does NTFS and probably more.

  4. Pilotgeek says:

    My android 1.6 device had USB host capability. This is new?

    • Garbz says:

      For Android in general yes it is. *Some* devices have had USB Host mode enabled for a long time. Most didn’t and it wasn’t an official feature of Android.

  5. Gdogg says:

    Yeah the Asus Transformer Prime has it when you use the keyboard dock.

  6. MS3FGX says:

    While this article isn’t inaccurate, we’ve had Android 3.1 for quite some time now. The tone here suggests this is a new development.

    I think Mike was trying to convey with this post that Android 3.1 and above support USB host, which includes the Galaxy Nexus running Android 4.0.

  7. jordan says:

    “That used extra hardware to make the Arduino the host, a step that is now necessary.”

    *unnecessary

  8. adamoutler says:

    android 3.1 was the first. it was backported to 2.3.6. that guy is using 4.0. however, its been an option for longer than that. just official in 2.3.6

  9. jimbob says:

    that’s hackaday, on top of the latest and greatest cutting edge news !

  10. BlueCoder says:

    What I want is two ports to be both a USB host and a client. Programmable USB filter anyone?

  11. Winston says:

    I think the main thing here (correct me if I’m wrong) is that having a USB host port on earlier android devices is “normal” if not in the USofA. Americans always get the shaft. We can’t even get Benny Hill any more.

    • Garbz says:

      No. Android phone handsets which support USB Host mode natively out of the box are few and far between internationally as well.

      Yes there are some devices which support it, but it has only been a native feature of Android since version 3.1. After 3.1 was released some manufacturers backported it to new firmwares.

  12. Zae says:

    Really? HackADay, you realize that there’s already controversy over 5.x Jellybean right? and 4.0 just came out… and 3.x was the tablet-only closed source… Could you guys get an Android-educated editor on staff to prevent looking like this article was sitting around on wordpress since May 2011?

  13. xorpunk says:

    As others have pointed out, this dates back to 1.0 even. Why? Cause it’s Linux on an Arm device. If your device doesn’t work it can probably be made to work with kernel building.

    • Garbz says:

      Others would be wrong. Specific manufactures have coded a USB host feature in specific phones since Android 1.0. It has not been a standard feature of Android until recently.

      Also saying you can just build the kernel is wrong too. Android has about as much in common with the Linux kernel as a dolphin to a shark. They both swim in the see and that’s about it. Building a kernel for a phone is not even remotely a trivial exercise. Android may be open source but the version that ships with most phones is anything but, and filled with many proprietary drivers. Heck Android doesn’t even have open source drivers for CDMA telephony.

      And that’s without even looking at a system service to handle a USB device.

      • Pilotgeek says:

        Well, I’ve successfully run Debian off an Android kernel. That seems close enough to Linux for my liking. Sure, the environment is different (typically no GNU stuff), but it literally IS the Linux kernel.

        I also have an Archos 5 IT, which is Android 1.6 and supports USB host. It was released far before android 3.1. Sure, it wasn’t standard to have USB host pre 3.1, but people can and have built custom kernels and extensions for Android devices. So please, stop ranting about something you don’t know about, k? Thanks =)

      • xorpunk says:

        It’s worth noting I’ve done everything you’re assuming is “wrong” many times. You can easily build from repositories and blobs for any Android device..

        I *HAVE* seen some where it was hard to get baseband blobs, but once you have them you can build an image.

        Host mode has been there since 1.0, if any devices didn’t have it, it’s only because of kernel or driver options; mostly binary driver(blob) support in my experience..

  14. Nolan says:

    Looking forward to hearing more…

  15. JJones says:

    USB host capability is great to have for portable devices. I used my N800 ( with Debian) to burn dvd’s when I was travelling in far off places in 2009 and had filled up my sd cards. Used a usb keyboard a bit more often.

  16. connie says:

    I don’t understand why so many people here are like “this is old”, “I can hook up my mouse”, “I already did this with my custom built kernel” etc.

    Surely, USB host capability has been around for some Android devices, and with proper hacking ie. rooting, libusb porting, JNI-glue you can actually talk to USB devices from within your Android app.

    But this post is about Android 3.1+, where there is an USB Host API available. Maybe [Mike] didn’t stress that enough (although it says 3.1 in the title).

    This means that you can create your own Android app like always and use Java code to talk to USB devices. No hacking/rooting/losing your warranty etc. required. A stock tablet or phone with Android 3.1+ and USB host functionality is all you need.

    The above mentioned guide actually reads “Android USB Host + Arduino: How to communicate without rooting your Android Tablet or Phone”. It also shows you how to investigate and communicate with USB-serial converters such as the Arduino ATMega8u2 through the Android USB host API.

  17. Dave H. says:

    I’m looking for some help with using an Android smartphone as a USB host. I’ve done quite a bit of driver-level Linux development, but I’m totally new to Android.

    I currently am working with a portable x86 system with quite a few custom USB slave devices that already have firmware and Linux drivers written. In addition, many of these devices are connected via USB hubs and rely on the usbserial driver.

    I would like to replace the x86 computer with some commercial Android smartphone.

    Originally, I had planned on using our docking station as the USB host for all devices including the phone. This article has me wondering if the phone itself could serve as the USB host. I don’t want to be endlessly hacking things that might or might not work. I want a fairly proven solution that would support multiple USB hubs as well as standard Linux drivers like usbserial. (I know FTDI already has an Android version of the USB driver.)

    So, what would be the limitations (specifically of the USB host capability) of an Android phone versus a docking station running a standard Linux USB stack?

    Much thanks in advance,
    Dave …

Speak Your Mind

*

Related Hacks in android hacks

  • Visible Kitteh project keeps mice out of the house
  • Android app review: ADSdroid gives you every datasheet, ever
  • Full Linux distro on a Nook color
  • A simple project to get you started with the Android ADK
  • Android on your netbook