13
votes

Is there a good tutorial for using an Arduino with an Android where the Android device is the USB host? (The Android device has OS version 3.1 (Honeycomb) or later). The only host program on the developer site is the missile launcher, which seems far simpler than interfacing with an Arduino would be.

Specifics: I'm trying to make an Asus Transformer host an Arduino Uno, but since there is very little information on how the Android host mode works, I'm lost on where to start. I just need the Android to be able to read data values out of the Arduino's memory. The Arduino is being used to count the frequency of a signal, that value then needs to be passed to the Android. If I've missed some simple way of doing this, feel free to let me know.

(There is a lot of information floating around about using the ADK to make the Arduino the host, but with the Transformer, that isn't an option - see Stack Overflow question Is it possible to get the Android ADK working on an ASUS Eee Pad Transformer running 3.1?.

The information doesn't really need to be Transformer or Uno specific, I just can't seem to find examples of people using the new host mode on their tablets.

4
On the long shot... maybe it's possible to implement the Android Debug Bridge Protocol on the Arduino side. The Arduino could then send data using a forwarded UDP or TCP port which is received by a Socket inside the application. This way the device stays in USB slave mode which is available to old devices as well.dronus
@dronus - the downside to the ADK/ADB method even for a tablet perhaps not expecting bus power is that the accessory requires a more expensive USB host interface.Chris Stratton

4 Answers

2
votes

We got FTDI communcations working, without a kernel driver, using this code: http://android.serverbox.ch/?p=370

Note that the Samsung Galaxy Tab 10.1 seems to lack the proper USB code to even detect USB devices (aside from mouse, keyboard, hub, and storage, which are detected by the OS and not passed to applications).

However, we got this working on an Acer A500.

2
votes

The arduino uno drops the FTDI or similar usb-rs232 chip used on previous designs in favor of a re-programmable USB interface based on the LUFA stack.

With a normal linux you would use USB CDC drivers - so a question would be if the honeycomb tablet ships with these.

The Honeycomb USB host support seems to provide a means of writing low-level usb drivers in 3rd party userspace android applications, so presumably if the functionality is not already in the kernel it could be added in userspace.

Another idea would be to change the LUFA installation on the arduino, reconfiguring it to one of the many other modes supported by the LUFA project so that it looks like something an unmodified honeycomb tablet already knows how to talk to, such as a mass storage drive, or a keyboard, or a mouse, etc. You might however need root-level access on the honeycomb tablet if you want to do low-level (especially write) access to this system peripheral.

1
votes

If you just want to find some examples of applications that use the USB Host functionality, your best bet is to use something like google's codesearch tool, and search for some of the usb host specific classes/permissions/intents

For example, a search for android.hardware.usb.action.USB_DEVICE_ATTACHED brings up the following applications:

0
votes

As the Arduino is using a USB to RS232 converter chip, the host mode USB port usually needs a kernel module driver for the serial driver implementation. Usually a FTDI chip is used, the module might be named ftdi_sio. So on the low level, if USB host mode is enabled, the system will maybe provide a /dev/ttyUSB0 device using this module. But this is useless i think as it is hidden from the application unless it is running on a rooted device. So the high level ADK abstraction is the way to go i think.