Does the USB Host Shield work on Arduino Mega 2560..?

Does the USB Host Shield work on Arduino Mega 2560…? There seems to be much confusion on the internet about this. It does seem to work on Arduino Uno, but I haven’t tested this; I have only Mega 2560 R3 now. I’ve searched Google and read many posts from others that cannot get it to work on Mega 2560. I am old professional electronics nerd, but somewhat new to Arduino world, and I’ve become burned out on this and need some direction to go in.

My setup:

  • Mega 2560 R3

  • Sparkfun USB Host Shield 09947 (new version)

  • external power to 9V port to supply proper 5V to USB VCC

  • latest Arduino IDE v1.8.13

  • USB Host libraries v2.0 from Circuits@Home

  • jumper wire from D7 to RST as many have recommended

  • move SPI connections to appropriate pins due to different pinouts between Uno and Mega 2560

I run the USB Host example sketch “board_qc”, which compiles & uploads fine. Then it’s supposed to query the board and return list of information. But it only goes so far and returns the following messages:

USB Host Shield Quality Control Routine

Reading REVISION register… Die revision invalid. Value returned: 00

Unrecoverable error - test halted!! 0x55 pattern is transmitted via SPI

Press RESET to restart test.

I get no further than this. I’ve tried various generic USB keyboards, and old generic 4MB USB flash drive, but nothing happens with any of them.

Help?

Ok, after working on this for days, I have my answer. And I can answer it myself…

No, the Sparkfun USB Host board does NOT work on the Arduino Mega 2560.

BUT…this is only the case when the USB board is piggy-backed directly onto the Mega.

Here’s why: the Mega header pinouts are different. On the Uno (and various other boards), the SPI interface is available on pins D10-D13. However, on the Mega they are moved to D50-D53.

But it’s not as simple as moving all four connections. If you’re using Oleg’s USB Host Shield Libraries Rev 2.0, you only move three of them. Also, there’s the known issue with the Sparkfun board where D7 needs to be jumpered to RST. I verified all of this by un-plugging the USB shield from my Mega, and then using jumper wires to make the connections.

Here’s the correct wiring pattern:

HOST <—> MEGA

3.3V <—> 3.3V

GND <—> GND

VIN <—> VIN

D7 <—> RST

D9 <—> D9

D10 <—> D10

D11 <—> D51

D12 <—> D50

D13 <—> D52

Now, with the above connection pattern, any of the example sketches from Oleg’s libraries will run correctly. I verified this, in particular with the test-sketches board_qc and USBHIDBootKbd. With the latter, I was able to plug in a USB keyboard and see the scan codes in the Serial Monitor window.

Regarding external power: it depends on your project For instance, the USB keyboard I used worked fine, as did a USB flash drive, because these devices each have tiny power requirements. However, if you try to plug in a 2.5" external USB hard drive, it’s probably not going to work unless you use the external power connector.

I found other boards that DO and DON’T work with the Mega. Once I finally figured out the problem, I came to the realization that there are two classes of USB Host Boards:

  • those which use the ICSP header for the SPI connection (Oleg’s official boards, SainSmart, etc)

  • those which do not (Sparkfun, Keyestudio, etc)

Why is this important? The ICSP header mirrors the SPI pins on all Arduino boards except the little ones. This is true even on the Mega and Due. The SPI pins move from D10-D13 to D50-53 on the Mega, and on the Due…it gets confusing. But on both boards the ICSP header remains in the same place. So those USB Host boards which use the ICSP header for SPI will (should?) work with ANY Arduino board.