By Hein du Plessis

2011-08-03 14:43:23 8 Comments

Apparently with Android 2.3.4 and 3.1 one can now access USB accessories.

I have a Ardupilot Mega (based on Arduino) board with a USB cable connected to my laptop, and I can connect to it using a simple serial communications program over COM7 and 115,200 baud. This allows me into the command-line interface, and I can issue commands and get logs.

Is it possible to write an Android app that will communicate over USB to my Ardupilot Mega board?

I've seen many similar threads, but most of them were pre-USB host.


@Jakub Turcovsky 2019-09-04 08:26:53

Unfortunately the library from mik3y's answer (see here: mik3y/usb-serial-for-android) seems to be long dead. It has many problems and waiting pull requests. Also the LGPL licence prevents anybody to fork it and maintain it.

But don't lose your hope, there's a working replacement and it's under the MIT licence. felHR85/UsbSerial.

EDIT: I found a maintained fork of mik3y's library. But the licence or readme is not updated, so I suppose the owner doesn't have a connection to mik3y and simply took it and improved it. I hope he won't get into any trouble because of the licence, because we need this library. See kai-morich/usb-serial-for-android

EDIT2: It seems that all of these libraries are maintained again, mik3y joined forces with kai-morich and they're working together now.

@mik3y 2012-07-07 00:11:30

usb-serial-for-android is my open source library written for exactly this need. It supports FTDI and CDC-ACM usb serial devices using Android's USB host support; no root or ADK necessary. It can talk most Arduinos.

The project is still in its early days, but the basic support has worked well enough for several projects. There is also a discussion list where you can get help.

@Machado 2015-05-28 14:04:40

Is there any source code example that works with CDC/ACM devices?

@Glenn Maynard 2016-02-04 22:44:00

Unfortunately, the LGPL license makes it unusuable for most projects.

@Kishan 2018-03-25 12:33:17

this is the one i was looking for. Thanks a ton. However i have a question. Can it send files too?

@Steven_BDawg 2012-08-30 17:34:28

I am currently using the library in my own app, however I think you can get away with just the app that slick has on the market. There are two free apps and one is the "pro" version of one of the free ones; search slick usb in Google Play.

It does use HOST mode and you can change the baud rate to whatever you need.

@Jaroslav Záruba 2017-06-22 06:50:01

unfortunately the link is dead

@SlickDev 2011-09-07 17:07:43

You can check out the library described in Slick USB 2 Serial Library.

It enables common USB-to-serial adapters to work with Android devices that have USB host mode without needing to root.

@Rachael 2015-09-30 21:33:43

the link posted is broken.

@Zoot 2011-08-03 16:01:20

Maybe. Check out the Android Open Accessories announcement on the Android Developers Blog. The Arduino Mega ADK is compatible. Not sure about the Ardupilot Mega.

From their page:

The Android 3.1 platform (also backported to Android 2.3.4) introduces Android Open Accessory support, which allows external USB hardware (an Android USB accessory) to interact with an Android-powered device in a special "accessory" mode. When an Android-powered powered device is in accessory mode, the connected accessory acts as the USB host (powers the bus and enumerates devices) and the Android-powered device acts as the USB device. Android USB accessories are specifically designed to attach to Android-powered devices and adhere to a simple protocol (Android accessory protocol) that allows them to detect Android-powered devices that support accessory mode. Accessories must also provide 500mA at 5V for charging power. Many previously released Android-powered devices are only capable of acting as a USB device and cannot initiate connections with external USB devices. Android Open Accessory support overcomes this limitation and allows you to build accessories that can interact with an assortment of Android-powered devices by allowing the accessory to initiate the connection.

Note: Accessory mode is ultimately dependent on the device's hardware and not all devices will support accessory mode. Devices that support accessory mode can be filtered using a "uses-feature" element in your corresponding application's Android manifest. For more information, see the USB Accessory Developer Guide.

The following list of distributers are currently producing Android Open Accessory compatible development boards:

The Arduino Store provides the Arduino Mega ADK (in EU nations or non-EU nations) that is based on the ATmega2560 and supports the ADK firmware. DIY Drones provides an Arduino-compatible board geared towards RC (radio controlled) and UAV (unmanned aerial vehicle) enthusiasts. Microchip provides a PIC based USB microcontroller board. Modern Device provides an Arduino-compatible board that supports the ADK firmware. RT Corp provides an Arduino-compatible board based on the Android ADK board design. Seeed Studio provides an Arduino-compatible board that supports the ADK firmware. SparkFun's IOIO board now has beta support for the ADK firmware.

@Hein du Plessis 2011-08-03 19:34:14

Yes ssaw that but that turns the android device into a usb accesory,and the Arduino board needs to play host,requiring an adapter etc.. I'm sure there is an easy way just to get the serials comms up in usb host mode.

Related Questions

Sponsored Content

111 Answered Questions

52 Answered Questions

[SOLVED] Is there a unique Android device ID?

30 Answered Questions

[SOLVED] What is 'Context' on Android?

39 Answered Questions

[SOLVED] How can I access my localhost from my Android device?

  • 2011-01-24 08:27:52
  • gath
  • 708798 View
  • 579 Score
  • 39 Answer
  • Tags:   android

23 Answered Questions

[SOLVED] Is there a way to run Python on Android?

52 Answered Questions

11 Answered Questions

[SOLVED] Proper use cases for Android UserManager.isUserAGoat()?

1 Answered Questions

Sponsored Content