3

I'm trying to make a Arduino Leonardo as a Keyboard for an iPad. I was successful with an Arduino UNO. However I'm hoping to use an ATmega 32U4 because of the better HID functionalities and smaller boards like the Beetle.

The problem I'm having is that when I connect the Leonardo to my iPad, the iPad shows an alert saying that the Leonardo is using too much power.

iPad too much power alert

Tried running the board with an external power source. Then I get a different alert: Device not Supported.

enter image description here

At this point I believe that the problem is not necessarily power, but the fact that the Leonardo is announcing itself to the iPad and the iPad does not like it. In the UNO project, through re-flashing, the board acts only as a HID.

Is there a way to make the Leonardo (or other ATmega 32U4 based board) to not advertise itself on the USB port while allowing the HID functionality to operate?

3 Answers 3

6

If indeed the descriptor is the problem then yes you can change it.

In the core file USBCore.h is the line:

#define D_CONFIG(_totalLength,_interfaces) \
    { 9, 2, _totalLength,_interfaces, 1, 0, USB_CONFIG_BUS_POWERED | USB_CONFIG_REMOTE_WAKEUP, USB_CONFIG_POWER_MA(500) }

Just change the 500 to something smaller (it has to be an even number).

However it may be that the Leonardo isn't programmed to support the Boot Protocol for HID. In which case that would require bigger changes to the USB and HID stacks in the core.

7
  • Thanks! To deploy that change into a board, do I need to reprogram the bootlode
    – fsaint
    Commented Aug 6, 2017 at 15:17
  • No, just reupload your sketch.
    – Majenko
    Commented Aug 6, 2017 at 15:17
  • So when reduced from 500 to 100, the iPad does not complain about too much power anymore. Also, now it works like a keyboard! But still will say 'device not supported' alert.
    – fsaint
    Commented Aug 6, 2017 at 19:42
  • Probably needs a boot protocol compatible device then.
    – Majenko
    Commented Aug 6, 2017 at 19:42
  • 2
    Not sure it'd be that easy to disable the CDC/ACM function of the device.
    – Majenko
    Commented Aug 6, 2017 at 20:20
0

i will stress now that i haven't tested this, and if it doesn't work you may have to reflash the bootloader in order to program the arduino again. in the arduino install directory we are looking for the following file:

Arduino\hardware\arduino\avr\cores\arduino\main.cpp

at line 40 (i'm using 1.6.9) we have:

#if defined(USBCON)
    USBDevice.attach();
#endif

in theory if you comment this out the serial port may not be ennumerated, however i don't know if the keyboard functions will still work.

if it does work you should wrap it in an if block so that the serial port shows if a certain pin is pulled high/low whatever your preference. this would enable you to program it as normal.

1
  • Commenting that line did stop the device from enumerating the Arduino, but the Keyboard does not work anymore. And as you mentioned, the Arduino needs re-flashing after to come back to life. Thanks!
    – fsaint
    Commented Aug 21, 2017 at 18:18
0

I have found the solution - your USB > Lightning adapter must has the option for charging.

For example i use Arduino Leonardo connected to IPhone 6 by USB to adapter who has USB nest and charging nest. IPhone shows me info that "This device is not supported.", but all works fine and I can control IPhone by Arduino Leonardo.

1
  • @Majenko's solves the power issue. For me the "This device is not supported" is still a problem. That alter interrupts the initial Keyboard-iPad communication.
    – fsaint
    Commented Dec 23, 2017 at 22:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.