Sunday, June 5, 2011

IOIO over OpenAccessory (ADK) Available

About two months ago, I've announced IOIO on this blog. About a month later, in Google I/O, Google announced the OpenAccessory and the Accessory Developer's Kit (ADK), which enables connecting your Android device (version 2.3.4 and higher) to external peripherals. Today, I'm announcing IOIO's support of the OpenAccessory protocol!

This new feature is currently released in Beta mode. Technical information available on the IOIO wiki. The way this works is that IOIO will attempt to communicate with the Android device with the OpenAccessory protocol. When this is not supported, it will seamlessly fall back to ADB. This enables you to connect the same IOIO board to both new and old devices. Your applications can be very easily be ported to the new mode, requiring only a few non-intrusive modifications to your application's metadata.

What is this all about? What is the relation between this new technology, IOIO and the other boards out there? I will try to provide some answers and clear some of the confusion that was caused as result of the proximity of all these announcements.

What is OpenAccessory?

OpenAccessory is a new Android feature, which enables connecting external peripherals to an Android device over a USB connection. This feature exposes a standardized interface on the USB bus, as well as a Java API that enables an Android application to communicate with the accessory on the other end. This feature is supported on Android 2.3.4 and higher. The OpenAccessory protocol allows the Android device to act as either a host or a device on the USB bus (the host mode is only supported on Android 3.x and higher and only on certain devices).
OpenAccessory is a low-level protocol: it features a single full-duplex communication channel between the Android device and the accessory, over which arbitrary bytes can be sent back and forth - much like a UART connection. It leaves to the accessory designer to design the higher-level protocol, i.e. what messages to send and what their meaning is to the Android application and to the accessory.
Read more about OpenAccessory here.

What is ADK?

The Accessory Developer's Kit (ADK) is a reference implementation of an OpenAccessory-enabled board, developed by Google and announced together with OpenAccessory. This board is essentially an Arduino Mega with an on-board USB host shield. It comes with an Arduino-side C++ library, which implements the protocol. Following Google, several vendors have released compatible boards.
The term "ADK" is often used synonymously with "OpenAccessory", i.e. one might say "this new board supports ADK" when they actually mean it supports the OpenAccessory protocol.
In my personal opinion, the ADK has been released mostly for promoting the OpenAccessory protocol and providing a quick-start and demo board, rather than intended to be a consumer product.

How Does OpenAccessory Compare to ADB?

The Android Debug Bridge (ADB) is a debug protocol which existed on every Android device since the early days of Android. Technically, this protocol allows a host connected over USB to open various kinds of communication channels to the Android device. On the Android-side of these communication channels are different services, such as debug, file-system access, Linux shell access. Another note-worthy service (on which IOIO has been based) allows forwarding of the data sent over the channel to a TCP socket. This allows an Android application to listen on a certain port and accept connections coming from the outside world, and do so without the need to modify the OS.
ADB's main advantages over OpenAccessory are:
  • Available on any Android device.
  • Provides useful features, such as file-system access (IOIO uses this for firmware upgrades).
  • More mature, does not suffer from some problems currently existing in OpenAccessory.
  • Simpler to work with on the Android application side - just listen on a TCP socket.
OpenAccessory's main advantages over ADB are:
  • Better throughput and latency.
  • Does not require the user to enable USB debugging.
  • More secure (IOIO takes its own measures to guarantee that the power of ADB cannot be exploited by a malicious firmware).
  • Allows applications to be notified upon connection of the accessory. The user can choose which application to launch when the accessory connects. This might be doable with ADB too, but IOIO doesn't do that.
See Inopia's excellent in-depth comparison here.

How Does IOIO Compare to Other OpenAccessory-Enabled Boards?

  • Supports All Android Versions - since IOIO works with both OpenAccessory and ADB it can communicate with a very large variety of existing Android devices, leveraging OpenAccessory when it exists and leveraging the additional features of ADB when they exist. Other boards, which do not support ADB, are limited to all but the newest Android devices out there.
  • Functionality - IOIO is almost exactly identical to the Arduino Mega in terms of pin counts and functions. The only difference I could spot is in the number of PWM channels (IOIO-9, Mega-16) and TWI channels (IOIO-3, Mega-1).
  • Cost - at $50, IOIO currently seems to be the cheapest available commercial board out there. A close alternative is a DIY version offered here, costing $55 and requires some work.
  • High-Level Software - the other boards out there expect you to write both an Android application and embedded-C code for the board, designing your own communication protocol. IOIO does all that for you, leaving you to write only the Android-side code, while using a high-level Java API for controlling the board's functions.
  • Support Forum and Wiki - IOIO has an active discussion group and an extensive documentation wiki, which continues to grow quickly. The IOIO project is committed to the hobbyist community, and to the hobbyist community only!
  • Size - IOIO is probably the smallest board out there - almost as small as you could get with 48 I/O pins, numerous supply pins and a USB connector. It is much smaller than the ADK board.
  • Bootloader - IOIO's firmware includes a secure bootloader, which enables firmware upgrades to be performed through the Android device.
  • Power Supply - IOIO has an on-board 5V switch-mode regulator capable of delivering up to 1.5A. This allows for simultaneous charging of the Android and powering two standard servos without problem. Some of the other boards will require an external 5V supply to support this use-case. In addition, IOIO has an on-board trimmer which allows limiting the Android's charging current. This is very useful for battery-operated setups, when you don't want the Android device to drain your battery.
  • Open-Source - Unlike some of the other alternatives - the IOIO's hardware, firmware and software are completely open-source with a FreeBSD license (very permissive). This approach has been chosen because I believe this is what works best for the hobbyist community, and allows people to customize the product for their needs, contribute to it, understand it best, compete on its pricing.
In conclusion, despite my obvious bias, I believe IOIO is very competitive with other OpenAccessory-enabled platforms. To be fair, here is another view.


  1. I think there is a typo here :
    "OpenAccessory's main advantages over OpenAccessory are:"

  2. great stuff man, I'm a big fan of IOIO !!!


  3. Hi, May I have a question?
    Can the IOIO board work individually, like when it does not connect to the android device, it acts different from when it connect to the device?
    Or it need to work with the device only

  4. @one-winged angel (hope you find the other wing soon)
    With the stock firmware, IOIO only works when connected to the Android (this is sort of a safety feature - you usually want your device to immediately stop when connection is lost - unless it is a helicopter...).
    However, it is very easy to write firmware that behaves differently. One possible super-simple example for this behavior is the "Blink" firmware, available from the Downloads page. This firmware blinks the on-board LED regardless of the IOIO connection state (in this case, the bootloader will wait for an initial connection before running the app, but this can be easily changed too. Once boot sequence is over, you can disconnect IOIO and it will keep blinking).
    Hope this helps.

  5. Thank you Ytai,
    so you mean that without the android phone, IOIO can not be viewed as a normal microcontroller board that you can download the embedded code ?
    For example, if I want to make a joy stick for android phone when it is connected. and it is disconnected I want it to be just Matrix LED display showing a pattern. If I don't connect the ioio to mobilephone before, I can not get LED display. Is it correct?
    I'm sorry if I asked something stupid, I'm quite new and deciding if I want to buy it.
    Thank you

  6. It can be viewed as a normal micro controller. You develop the code in mplab-x and can leverage the existing code.
    You can either use a programmer (e.g. pickit3, or another IOIO) or use the existing bootloader to install firmware via a phone.
    These are quite advanced use cases.
    If you feel more comfortable with Arduino, you look into openAccesory compatible Arduinos. Note that unlike IOIO, those would only work on Android 2.3.4+

  7. Hey Im planning to start to develop with arduino, but i think im kind of confuse:
    1) Is the arduino mega an upgrade of the arduino uno?
    2) Is the arduino mega ADK the same board that the android ADK, but made it by arduino?
    3) If a buy the arduino mega adk, will i need to learn both java and c++ ?
    4) Is the IOIO board compatible with openaccesory, adk, and android sdk running on eclipse?

    Thanks if you give a quote for my questions

    1. 1) You're asking this in the wrong forum :) Arduino Mega is a version of Arduino that has more pins and features compared to Arduino Uno.
      2) I'm not sure if they are 100% identical, but functionality-wise they are the same, and should be 100% compatible.
      3) Yes. C++ for programming the Arduino and Java for programming the Android. You'd also have to design an implement some sort of communication protocol between them (which may be simple or hard, depending on your application).
      4) IOIO is compatible with OpenAccessory. It is NOT compatible with ADK or Arduino. All of these products work with the Android SDK on Eclipse. For ADK, you'll also need the Arduino IDE.

    2. Hi Ytai,
      I have a question regarding your point 4): I thought that the ADK-Protocol *is* some kind of OpenAccessory. Where is the difference between these? I thought the IOIO is compatible with the ADK (or legacy ADB). Could you please explain me (or link an article) the differences? Or did I missunderstand you?

      Thanks so far!

    3. IOIO uses the same way to talk to the Android as the ADK boards, which is the open accessory protocol.
      It is not compatible with ADK in the sense that you can't run Arduino firmware or use Arduino shields with it.

    4. Ah okay, now I understand want you mean, thanks. Same protocol (oap) and technology (adk) but different implementation and hardware between IOIO and Arduino boards.