I’m trying to set up an Android Open Accessory environment with no success. I’m using the PIC32MX250F128D controller on my board, I’ve implemented a Firmware that works in USB Host mode and handles all the Android Open Accessory Protocol. I have also an Android App to detect any external hardware plugged in the USB conector. The problem is that I’m not getting any USB “physical answer” from the tablet. From the USB 2.0 Standard (and from this document as well https://source.android.com/accessories/aoa.html ) The Accessory (the external hardware), acting as a USB Host, should wait for a 100miliseconds signal from the USB Device (Android Device, tablet, smartphones, etc..). That’s the very first step on the USB Phy Standard. What might be happening is that the USB on the Tablet side is acting as a Host and also waiting for this signal from an external Hardware. Is there any android configuration that enables USB open accessory, or something like that? Also, How can I know in which mode the USB in android is operating, or what is the "normal" mode USBHost or USBDevice?
Finally I've got it solved :). I wasn't able to detect any hardware signal, the hardware signal is either D+ or D- pin set to high and the other to low. If D+ is set to high the USB Device operates in full-speed mode, otherwise in low speed mode. I've found out that Android works in host or device mode looking at the cable plugged in. My cable was telling android to operate as host, so I didn't receive any Device Attach signal from Android.
Related
I was developing a tablet application for controlling a circuit but now i stuck here somewhere.. there are a few options that i think about what to do after this stage. I need 2 usb ports , one for a usb serial converter (namely pl-2303) and other one is a standart flash drive. I tried to use a hub connected to an OTG cable with no luck. When i plug only one of my devices to OTG port they all work but when i plug 2 of them to hub system freeze or doesn't mount my flash drive. I tried 3 different hubs they are not working. Sometimes i made this setup running with an sd card reader instead of flash and a digitus converter instead of pl-2303. Then i though this can be an issue with the USB 1.1 - 2.0 specifications because pl-2303 is a USB 1.1 device and the rest is 2.0.
After i realize the realtek wifi module in the tablet is also mounted to a USB port i removed the module to check if i can connect one of my devices to that port. But as usual the wifi driver of the system is controlling this port , so when i try to power up the port, system checks if it can find the realtek module and when it cant detect realtek wireless module just shuts down the port back. While this happens i can see my device is connected to system for a few seconds before the driver shut it down.
So this is the all story. I just need this 2 device to work together. I am waiting for your opinions
The tablet is a ATM 7021 processor based cheap tablet.
Thanks in advance.
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 am working on a project which involves communication between a android device and arduino. The final assembly of the project would be a box-like structure with only the android device's screen being visible (the remaining sides would be enclosed) . Space is Important; i'd like the apparatus to be as small as possible & using minimum cables.
Communication with the arduino has been established using usb host apis.
Now; the android tablet and arduino are connected through:
USB OTG cable on the Android tablet (micro-usb male & usb female)
Mini-usb to usb on arduino (USB male & mini-usb male)
The problem: I want the android tablet to charge itself through the connection.
Currently the arduino powers itself from the android tablet. However; finally the tablet and arduino will be connected for hours together; and that'll drain out the battery. The arduino board will be getting power from an external source. I'd like the tablet to draw power from arduino. This is working when the Tablet is switched off; however the tablet stops charging itself and begins discharging as soon as it is turned on.
This is probably because the tablet goes in the Host mode (as USB HOST) and the arduino as the device/accessory. Usually in such connections, the host sends the power and the accessory charges itself. Can this be the other way around??
My understanding is that in these kinds of connections Host Negotiation Protocol (HNP) is implemented first to determine the host. Is it possible to forcibly make arduino host and the tablet an accessory? and in such a case will proper communication be possible?
Alternatively, is it possible to enable and disable host mode from within an android app?
The main purpose is to be able to draw power from usb otg cable (I'm trying to avoid using additional cables)
Please if anyone can provide assistance , it would be appreciated.
Thanx a lot in advance :)
Your device will not be able to draw power while connected as the Host.
You should look into the Android Open Accessory(AOA) Protocol, though you need the proper hardware to connect to.
AOA allows the tablet to be connected as a USB accessory which will allow it to draw power and charge, but it also lets the Android device behave as if it were a host sending the commands to the connected hardware.
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 have a general and quick question and since you can never get a hold of a developer at Google, I thought I would post the question here...
Can anyone tell me, if we want to use our phones to connect via USB to a missile launcher made by dream cheeky As suggested on the USB or ADK section of the developer's website, would we still need and Arduino board or a board that Google presented at Google I/O 2011?
I guess I am asking, in short, can we directly hook our phones to another device via USB, and compile a program via eclipse or with the ADK to have it run? or will we still need a board in between the phone and the device we want to connect USB...
Thanks in advance,
Richard
In ADK, the Android device acts as a USB Device and the Android accessory acts as a USB Host. When an Android accessory is attached to the Android device, the Android devices switches to "accessory mode (as described in ADK)". If your Android device has USB host already, still it will switch to accessory mode and acts as USB Device instead of USB Host. Actually, the motivation behind ADK is to make each Android device to work with any Android accessory. Accessory mode eliminates the need for USB host, since only few devices has USB host feature (It is costly).
So, if you want to work with ADK, you need an development card with USB host.
you do not need an ADK board if the device that you are connecting to your Android device is acting as the USB Device and your Android device is acting as the USB Host. This is the case with the Dream Cheeky USB missile launcher. You can connect a missile launcher directly to the device and control it. USB Host is only supported on Android 3.1 devices and later.