Wednesday, December 14, 2011

Android USB Host Testing.


Since Android 3.1.x (API Level 12), Google introduced an USBManager which is actually a USB host API to talk to usb devices connected to your tablet or phone. It is different to the Android ADK, which requires the other sides have special hardwares and software protocol.

As now your tablet/phone is a complete USB host device, so you can theoretically connect to any USB devices avaliable on the market. But you have to write your own USB driver using USBManager (Java) to talk to the devices.

There is a one example provided by Google called ADB Test, so now you can connect your tablet/phone to another android devices via USB and start debugging. (i.e. adb logcat)

Source code: http://developer.android.com/resources/samples/USB/AdbTest/index.html

I got a Asus Transformer TF101, and a special USB kit which turns the external connector to a USB host connector, so now I can connect my phone to it with the USB cable! Let's see the demo video here:


If you want try it on your tablet/phone, you need to prepare a special usb host adapter if necessary and then download the following from the market:
https://market.android.com/details?id=com.bitartist.usbadb

it is a direct copy of the Google Adb Test,  I put on market just for people to play around.

I have started a little project of interfacing a USB2Serial adapter (based on SiLabs CP210x chipset), so far I can send / receive the data to/from the MCU UART. I hope can finish some basic functions (like setting baud rates) and release it to public later. It is a simple and cheap way to connect your Android devices to your MCU, the only drawback is that you will need a usb host and Android 3.1.x host device.





8 comments:

Anonymous said...

Was looking for sample code to communicate with CP210x. It would be great if you could publish the code even in the current form, it would be great

Bitartist said...

yes, once finished, I would publish the sample code here.

Anonymous said...

Hi, thank you for a very useful post. I'm very interested in accessing the Silabs CP2102 chip. Did you make any progress with that sample project? It would be great if you could publish some samples even if it is still Work In Progress.

Anonymous said...

Found this site looking for a CP210x driver for android. Were you able to implement your test project , if you could publish this, yours will be the only site with that code available.

Anonymous said...

This would be great to interface some GPS receivers with Android tablets. Are you still developing this project?

Bitartist said...

Yes, actually, it works for send/receive , but just hardcoded the baudrate for this moment. I don't have to work on this project recently:(

Anonymous said...

Hi, is your project still alive? This blog still remains the only one that talks about CP210x drivers for android. Would be great to have some good news

Bitartist said...

Someone already made it:
USB2Serial project for android:
https://github.com/mik3y/usb-serial-for-android