I am looking for a way to communicate with a control-board (u can consider it a sensor device) using USB cable. My sensor device supports usb but I think android does not have a way for that.
Can that be possible through Bluetooth dongle?
Is there any Android device available which supports USB host.
USB host has been "hacked" into a lot of android phones, but it's not very user friendly and weird cabling is needed along with a power supply as the phone won't power a usb device.
Some of the "first generation" android tables apparently had USB host on some models.
I've seen pictures of a Xoom connected directly (via a short OTG cable) to a thumb drive that it appears to be powering and reading from, apparently it was unofficial software.
As for your other questions, yes, you can use bluetooth if you get a bluetooth modem for your embedded device. Or you can use wifi. Some of the phones have low voltage debug serial ports. Or you can build a modem / DTMF control interface to connect to the headphone jack...
Related
is it possible to screencast from an android phone with either slimport or mhl support to a laptop with the usual usb charging cable of the phone?
No.
First, "the usual usb charging cable" does not have the extra pins used by MHL or SlimPort.
Second, only a laptop with MHL, SlimPort, or HDMI input could receive a signal, even if you had the right cable. You can get some HDMI input devices that work with a laptop for recording purposes (BlackMagic has one IIRC). I am not aware of any similar hardware for native MHL or SlimPort, though stuff could exist.
In the various tutorials for building an Android accessory that uses a USB connection, the first step is to "Select a hardware platform that can support USB host mode." Most of these tutorials claim that that means obtaining a device that is running > Android 3.1 (or one that is rooted, or a tablet, etc.).
In my testing, it seems that, for a phone to support USB host mode, it not only has to be running > Android 3.1, but must also supply power over the USB cable. Can anyone confirm or deny this?
Most tablets seem to supply power over USB, but many phones do NOT. I can't find any place that will directly state that the phone must supply power over USB in order to be able to run an accessory as they all seem to loosely state that anything running >3.1 will work (as long as, at least, the device you're connecting to the phone supplies power). However, in all USB libraries that I've tested, I can make a connection to my USB device just fine from my tablet (which DOES supply power over USB), but I can't get any of them to work with my phone (which does NOT supply power over USB). Both are running > Android 3.1.
Note that I'm not trying to power my accessory over USB. My accessory has its own 5v power source and can even supply power over USB. I just want to build an app that will allow my phone to be able to connect to it, change it's settings, receive data, etc., but I can't get my phone to recognize if/when the device is connected. I don't know if that's because of my phone's unpowered USB, or if it's because of another problem with my phone and/or software. Unfortunately, I don't have another >3.1 phone to test with.
As a side note, the device I'm connecting to is an FTDI/Arduino board that I'm working on which, again, connects to the (powered) tablet just fine, but the (unpowered) phone claims that no USB devices are connected (even though the FTDI board supplies its own power).
Your Android Device needs to have OTG Hardware built in, you can not add it to your phone, most high end smartphones have OTG built in, Samsung Galaxy series does, this allows connection with external USB slave devices, you do need a USB Cable that is OTG which connects pin 5 to GND, this enables the OTG and then supplies power to the device, Like USB Flash memory, if you want to connect an Arduino, you will need an external power source.
As a side note, the device I'm connecting to is an FTDI/Arduino board that I'm working on >which, again, connects to the (powered) tablet just fine, but the (unpowered) phone claims >that no USB devices are connected (even though the FTDI board supplies its own power).
This leads me to believe that your tablet is OTG, and you phone is not.
Well, considering your target area, you might not want risk frying your device before starting to understand the internal pin structure of USB connectors.
I suggest that you use a low-cost non-brand unit. I just discovered this while researching how to direct-solder a +5V DC power source on my broken tablet's PCB, so old that its damaged micro USB port can't be replaced. Normally, an in-market, low-cost, phone-sized Android device (various non-brand products, most of China manufacture) has a very low-power battery attached; no OTG option to play with. It's just getting connected with a PC/USB host to get power for charge and communication over USB/ADB. Almost all of the units I've bought above 7" display size, support even USB 2.x drive as external storage, meaning that OTG is enabled by default.
Try with some other devices from your friends/family/collegues -- just to connect an OTG cable and maybe an USB drive with a built-in LED for easier identification without the PC/Controller device -- if you have enough "test subjects) and they trust you to connect a storage device.
I want to build a device with sensors (either with an Arduino or a homemade circuit with a microcontroller) and I want to send data from it to an Android device via an USB cable. What is the library required to connect devices via USB? Is there any documentation I could read for it? The problem is that whenever I search for this I only get results about the ADK and their board, not for other devices.
Are there things I should know beforehand? I'm not new to either field, but it's my first project with the two connected.
Thank you.
The first thing to check is if your Android device is equipped with USB host interface. In such case you can connect a regular USB device to your Android and use this API to communicate with the device.
However, typical Android device (virtually every mobile phone) is only equipped with USB device interface, for connecting to PC or another USB host. In such case you have to use the Android's USB Accessory support. The most important idea behind Android Open Accessory protocol is that it swaps (logically) USB device and USB host roles. It's the USB host that looks for the device with particular vendor/product ID, selects particular USB protocol interface, and then simply uses the in/out bulk endpoints found to communicate - pretty smart, isn't it?
To build Android Open Accessory compatible device you then need a CPU with USB host interface. If you want to use Arduino, this shield is probably a good starting point, given its firmware implements Android Open Accessory Protocol already. There are some example applications as well.
This works great on my Nexus7 which is connected over the OTG to Arduino Mega.
Android USB host serial driver library for CDC, FTDI, Arduino and other devices.
Hope it helps!
You have two solution
1: Your Arduino board act as a USB host and power the Android device.
With this solution you have to implement and USB Host stack on your Arduino board and must implement Android Open Accessory Protocol. Your Arduino board must power the Android device. Then you app must use the USB Accessory API to communicate with your board.
Avantage:
work with almost all Android Devices (no need for an USB Host port on Android device)
Disavantage:
The device board is more complicated (must provide power for both devices)
Firmware is more complicated (must implement USB Accessory mode)
2. your Arduino board act as a USB device and the Android device powers
you board.
With this solution your do not have to implement a specific USB protocol. Your board will act as a standard USB device. Since you act as a device you can power your board directly from the USB cable (the Android device will power itself and your baord). To communicate with your board you will use the USB host API of Android.
Avantage:
the device board is very simple
the firmware is simple and easier to debug (you can even test it with you PC)
Disavantage:
Works only with Android devices that have an USB Host port
On most device you will need a specific cable or adapter (ex :otg usb host cable)
I have experience with solution 2, and it works pretty well. All source code for the Android source is available from the link below. I have verified that it works with sensor devices from the company where I work on the following Android devices:
Samsung Galaxy S3
Acer Iconia tab a200
Asus Tranformer Pad TF300T
But it should work on most tablets and recent phones you can see this post if you want look at our experience.
I would like to use Android phones as a way to do some processing and visualization of a sensor that would be attached to the USB port on the phone. The sensor would plug into the micro/mini USB, and then I would need to read the incoming data from the USB serial port.
Is this possible? I have heard of people using Android to steer robots and other applications, but I have never seen Android being used as a host for a USB sensor. I can't seem to find any official documentation on the subject either, but it seems like it would be a very useful tool. Any thoughts, links, or information on this matter? Thanks.
What you're looking for is USB Host support.
There's an open issue in Android's issue tracker here for it:
http://code.google.com/p/android/issues/detail?id=738&colspec=ID%20Type%20Status%20Owner%20Summary%20Stars
and it's actually ranked 7th, in terms of "stars" (think votes, by the people), at 1110 stars. You can log in and star it yourself, both to vote for it, and to receive email updates.
There was also work on a patch back in February, 2010:
http://groups.google.com/group/android-kernel/browse_thread/thread/c8471573d7553331
and there's info on using a USB keyboard here:
http://www.tombom.co.uk/blog/?p=124
Perhaps you can find something for your sensor there?
This is cool =):
http://www.technologyreview.com/biomedicine/25286/?a=fb
Cheers,
Victor
should be possible, look up android.hardware.usb.UsbDevice # http://developer.android.com/reference/android/hardware/usb/UsbDevice.html
This support has been added since Android 3.1.
Look at http://developer.android.com/guide/topics/connectivity/usb/index.html
This guy has modded his Nexus One to work as a USB host and has done several cool things.
He uses a USB keyboard and runs a movie from his USB stick. Then he runs a webcam through the phone and displays it on the computer and even runs an entire desktop-based Linux distro from his phone onto his computer monitor.
Pretty amazing stuff.
http://sven.killig.de/android/N1/2.2/usb_host/
The USB defines two type of equipment 1 usb host 2usb device .A device can only be attached to a host,no host to host or device to device connection.,in the beginning usb hosts were computers to which a usb device is attached.but with increase in popularity of usb interface a number of equipments come as usb host ie you can attach your pendrive and other usb device to it.In the starting mobile phones were manufactured as usb device ie you can attach your phone to usb host only typically a computer.but there also revolution come in now we have phone which can act as host and device when it is working as host we can attatch printer to it and when it work as device it can be attatched to a computer.only high end phone has this support.low end phones are still usb devices.
so we have two options
phone in usb host mode and your senser as usb device(you will need microcontroller that can act as usb device for this purpose-eg pic 18f2550 microcontroller);
your phone as device and your senser circuit as usb host here you will need high end microcontrollers that can act as usb host
in both cases there involves coding at both phone and senser circuit microcontroller
i dont know anything about phone side coding but i think this helps you to get a direction to what to do.
Have a look at You Are Here GPS.
https://play.google.com/store/apps/details?id=com.agbooth.usbgps
What would be the best way to access the USB as a serial port on an Android device (HTC Magic)?
I am thinking about an OBD-II interface. Can I do this on a standard phone or more likely will I need a modified firmware?
According to this post, Matt Porter presented a review of Android at the Embedded Linux Conference Europe. I mention this mostly because of the example used to describe the current state of Android.
"Just one more practical example: You cannot even plug a USB drive to an android system, since /dev/sd* is not an expected device name in their hardcoded hotplug management.
Executive summary: Android is a screwed, hard-coded, non-portable abomination."
I'm sure someone's working on it, but I'm afraid for now you're out of luck unless you're willing to go low-level and edit the OS.
PSFreedom (project to jailbrack Playstation 3) has list of controllers which support usb host mode which then translate to supported Android devices.
My own expirience is that usb host works on HTC Dream/G1 without problems.
For OBD-II I would suggest bluetooth ODB-II dongle which side-stepps problem with usb host adapter.
Depending on the USB chip in your particular phone, it may be possible to rebuild the kernel to support USB Host mode or USB On-The-Go (Host + Gadget modes) instead of the normal USB Gadget mode. I've found some people speculating that it could be possible on the HTC Dream. Assuming you could reconfigure the USB port in Host mode a USB to serial, ODB-II, or CAN should be doable.
From what I can tell Android is Linux of some sort, to have USB device which would apear as serial port, you should write a driver for that device. I don't know much about OBD-II interface but i am guesing they use some sort of USB driver for windows, same is for android, not mentioning the application to handle the driver.
I don't think the current Android devices can act as a USB host only as a USB device when attached to a host. So using the USB port as a serial port is not likely.
Get a hostmode kernel for your device and you can use python for android and the pyserial library to talk to the serial over USB. I did this with Huawei Ideos U8150 (here is the post) for a loopback test.