Arduino Due and ADK

Hi everyone!

I hope someone can offer some guidance ... I am trying to run the Arduino Due ADK sample sketch from the Arduino Studio 1.5. My Setup is:

I cannot get the sample to work. Do I need a special cable (OTG)? Can something else be the reason?

Thanks, Tomaz

Did you cut two standard A to micro B cables in half and connect the micro B halves to each other? Then you have a B to B cable which does not work. You need a micro A to Micro B cable. The difference is that in the micro A end a fifth "ID" pin is connected to ground so that an otg capable device (here the due) can sense that it should start acting as a host. If it saw the B end of the cable with ID pin unconnected it would start acting as a device.

There are tutorials around there showing how you can open the plasic plug and connect the the ID pin to the adjacent GND pin, but that is a kludge. Best is to find a suitable cable.

The B to B cable could work too if you pull the the ID pin low from the due board, but someone from the developers should advise whether provisions are made to do this. The pin mapping mentions the ID pin is connected to PB11 on the sam, but is not broken out. Maybe it can be pulled down from software?

That is exactly what I have tried. Thank for pointing me in the right direction. I'll get an OTG cable and try it out.

If you get it working, do please report back -- Details would help future attempt-ers like me! Really looking forward to trying out ADK with the Due.

I have bought a few cables similar to these http://www.amazon.com/SANOXY-Female-On-The-Go-Adapter-Samsung/dp/B005GI2VMG/ for 1USD more or less and I used it to connect a few USB devices to the Due including my Nexus phone.

I know David cuartielles tried it with the Samsung tabled and he was able to try the ADK protocol on it.

so it's working if you have the right cable :slight_smile:

m

I tried the ADK sample with the OTG cable with no luck.

The phone starts charging, but nothing else happens. The app on the phone states: No USB device found. And the Arduino Code does not go into if(adk.isReady()) { ... } section.

what code are you using?
m

The sample sketch for ADK from Arduino IDE 1.5 and the APK mentioned in the sketch.

I have the Due working with ADK using both the example sketch and an application I wrote originally for the Mega ADK. The example sketch was just to compile and upload, then the phone would pop up a window on connection, giving me the option to open the URL given by the accessory code.
I used a simple OTG cable connected to a normal USB charging cable to connect the Due to the phone.

It only worked on my HTC Desire S with CyanogenMod on it (Android 2.3.7 I think), the Google phone with Android 4 just started charging.

I'm having some trouble in my application too, spontaneous packet loss that I haven't had the time to figure out yet..

I'll try to get my hands on an Android 2.3.* phone and test it. Maybe this could be the reason?

It never occurred to me to try all of them before, but here goes:

Manufacturer Name Android State
HTC Desire S 2.3.7, CyanogenMod 7.1 Works
Asus Transformer Prime TF201 4.1.1 Works
Samsung Galaxy Tab 7" 4.1.1, CyanogenMod nightly Only charging
Samsung Galaxy Tab 2 10.1" 4.0.4 Works
Samsung Galaxy Note 2 4.1.1 Only charging
Google/Samsung Galaxy Nexus 4.? Only charging

EDIT: I don't think it's an Android version issue. I've heard the manufacturers can choose to disable the ADK feature (of course they can). I just never thought they would. Why?

Only tried Samsung Galaxy S (i9000)

  • MIUI (Android version 4.1.2)
  • CyanogenMod 9 (Android version 4.0.4)
  • CyanogenMod 7.2 (Android version 2.3.7)

None of them worked. Can anyone confirm a working ADK mode on Galaxy S on any firmware? Unfortunately I don't have access to any other Android device at the moment ...

Edit: the following command on the phone returns android.hardware.usb.accessory
pm list feature | grep accessory

Does the phone get power from the Due, or nothing? How do you power the Due?
I think it might be a power problem because my Desire S doesn't connect (only charge) when I'm powering the Due over computer USB while charging another phone from the same USB hub.

Another power problem: the USB host port doesn't seem to power up at all when I'm running the Due on 12V external power. Is there a call I need to make to enable the USB host power?
And it gets better: while the host port appears to be dead, the programming port is powered; I can charge my phone over it! It's not supposed to power the programming port, right?

...the programming port is powered; I can charge my phone over it! It's not supposed to power the programming port, right?

It should not even be possible to make such a connection: the usb spec only defines these cables for this use:

  1. micro B plug to standard A plug (the regular pc to phone cable).
  2. micro A plug to standard A receptacle (what massimo referred to)
  3. micro A plug to micro B plug (never seen this for sale)

You can plug cable 1 into cable 2, then you end up with the same thing as cable 3. So you always end up with an A plug on one end and a B plug on the other. The B plug goes in the phone. The A plug has a rectangular section and should only fit in the native usb port (micro AB connector) of the due. It should not fit in the programming port (micro B connector, trapezium shaped section)

So how did you make the connection?

  • did you put the A end in the (otg capable?) phone?
  • do you have a non std cable? (on ebay I saw cables that look like standard A receptacle to micro B shaped plug, but it is difficult to tell from the pictures)
  • does the due have a micro AB connector (rectangular shape) for the programming port? (I am still waiting for my due, so I can't see for myself)

I use a cable like this one on the Due side: http://www.ebay.com/itm/Micro-USB-Host-OTG-Cable-W-USB-power-Samsung-phone-i9100-i9300-i9220-9250-/150928276246?_trksid=p2047675.m1850&_trkparms=aid%3D222002%26algo%3DSIC.FIT%26ao%3D1%26asc%3D11%26meid%3D3299974227435379446%26pid%3D100011%26prg%3D1005%26rk%3D1%26sd%3D110931117836%26
It plugs into either the programming port or the native port. On the other end I use a normal USB charging cable (#1 in your list).

Is it simply because I'm using the wrong cable? But the host port powers up when the programming port is connected to the PC!

EDIT: The special cable acts like a normal OTG cable with the option of external power supply (not used in this case)

The description of the cable on the e-bay store is really weird.

It is a non standard cable, but you reported it works well with some of your phones, when connected to the due's native port. From this I deduce the ID pin inside the micro B plug is connected to ground making it actually a working micro A plug but with the wrong B (trapezium) shape.

Because of the wrong shape you can also insert it into the programming port. But the latter ignores completely the ID pin. So this makes you connected two usb devices. Nothing should happen in this case, it should cause no harm, but you are right that neither of the devices should source power.

I did some more testing and actually got it to work ... kind of :frowning:

I have the Galaxy S (i9000) with the CyanogenMod 9 (Android version 4.0.4). The setup works if I power the Due over the USB connection and does not work, if I power it via the power jack. Is that by design?

However, the operation is inconsistent, sometimes the enumerates the devices and gets to adk.IsReady() == 1 and most of the time it does not. I've tried to printout the status of the usb_getUsbTaskState function and get different readouts (USB_STATE_RUNNING, USB_STATE_ERROR, USB_DETACHED_SUBSTATE_WAIT_FOR_DEVICE) when plugging the phone in and out.

Sometimes it even goes to USB_STATE_RUNNING and then straight to USB_DETACHED_SUBSTATE_WAIT_FOR_DEVICE. It could be a problem with the phone, since things get better (but not ideal) after the reboot of the phone. Unfortunately I don't have any other device to try it with.

Hi i'm new Arduino Due dev :stuck_out_tongue:

Someone may link me some ADK2012 example or tutorial (sketch + Android Project)

Thanks

Whitewater I have the exact same problem. Some times I get it to connected state and can transfer data successfully but then other times it just doesn't work.
I haven't figured out what's wrong yet. I've had varying degrees of success on different devices. One sketch would work fine with bi-directional communication on one device but only unidirectional on the other. Another sketch would work on both. Today I only had one successful run out of perhaps ten or fifteen attempts with different very simple sketches.
I always lose packets when I try sending them them too fast from the Due, like three in a row without any time between.

And the power is weird, isn't it? Of course it should power the USB port even if it's running on an external power source!

OK, I hope this can help figure it out.
Part of the problem, at least with the Note II, is timing. The error I get when debugging the USB host code is a timeout (error code 0xFF) on one of the USB packets. This doesn't happen if (for instance) I output a whole lot of serial data to slow the sketch down. It is not enough to add a delay() in the main loop, since the whole thing fails if we delay() too much as well. Adding a delay(50) between each call to Usb.Task() and a few delay(100) at strategic places inside USBHost::Task() makes it work pretty reliably. I haven't had the time to make it work well yet or I would post code.

Another issue is the fact that the USB code stops working if you soft-reset the Due, such as by opening the serial console after a sketch has started running. This can be worked around by uploading the sketch, then unplugging the Due and as fast as humanly possible after plugging it in, you open the debug console. I guess this works because you can actually soft-reset the Due before the USB initialization takes place, and therefore it doesn't try to initialize it twice.

If you have the phone connected to the Due and your sketch either crashes or your code is timed wrong, you might confuse the USB stack on the Android. This is only solved by rebooting. So if it stops working, you might get it running again by simply rebooting the Android. I power-cycle the Due between every run.

I ran a modified version of the ADK2012 sketch and library, compiled with the ADK2012 version of the IDE. This powered up the USB port even when running on external power, so there's nothing wrong with the hardware. There has to be a mistake somewhere in the library, I just don't have enough knowledge to find it!