image 8

The code supporting the USB Mass Storage Class of devices has been added to USB Host Shield 2.0 library and is available to download on GitHub.

Mass storage devices include USB Flash drives, memory card readers, external hard drives/CD-ROMs, smartphones/tablets, and some others – almost anything that shows as a drive while connected to a PC (exceptions are digital cameras as well as some phones pretending to be digital cameras). Andrew Kroll (who made this release possible) – thank you very much!

USB Host Shield 2.0 Library Mass Storage Class Of Devices
USB Host Shield 2.0 Library Mass Storage Class Of Devices

Top  10 USB Host Shield 2.0 on Amazon

Bestseller No. 1
ARCELI USB Host Shield for Arduino UNO MEGA 2560 Support Google Android ADK USB HUB
167 Reviews
ARCELI USB Host Shield for Arduino UNO MEGA 2560 Support Google Android ADK USB HUB
  • USB Host Shield for Arduino UNO MEGA 2560
  • Support the Google Android ADK
  • Compatible with Arduino Uno 328
  • Compatible with Arduino Diecimila / Duemilanove 328
  • Compatible with Arduino Mega 1280
Bestseller No. 2
USB Host Shield Compatible for Arduino MEGA 2560 1280 Support Google Android ADK & USB HUB Function
28 Reviews
USB Host Shield Compatible for Arduino MEGA 2560 1280 Support Google Android ADK & USB HUB Function
  • USB Host Shield support the Google Android ADK and Android Phone: G1, Nexus One, Nexus S, Motorola Droid X. (Note:Mobile phone system needs to upgrade Android 2.3.4, Tablet PC needs to upgrade to Android 3.1).
  • Compatible with following hardware: for Arduino Mega 2560 (Recommended); for Arduino Mega 1280; for Arduino Uno 328; for Arduino Diecimila / Duemilanove 328.
  • When achieves the USB HOST function, USB Host Shield can communicate with other USB devices, support USB HUB function as well.
  • The USB power pin have the 3.3Vin and 5Vin pins, which needs to be soldered for the shield to work.
  • Package Included:1 * USB Host Shield
Bestseller No. 3
HiLetgo 2.0 ADK Mini USB Host Shield SLR Development Tool Compatible SPI Interface For Arduino
23 Reviews
HiLetgo 2.0 ADK Mini USB Host Shield SLR Development Tool Compatible SPI Interface For Arduino
  • Interface: SPI
  • Power Supply: DC3.3V
  • Support the Google Android ADK
  • Supporting Android phone
  • After achieve the USB HOST function, you can communicate with other USB devices, and support USB HUB function
Bestseller No. 4
Midzooparts USB Host Shield 2.0 Compatible with arduino for Android ADK Support for UNO MEGA
  • USB Host Shield 2.0 compatible with arduino for Android ADK support For UNO MEGA
Bestseller No. 6
Official Mini USB Host Shield 2.0 for Arduino ADK SLR Development Tool 3 Orders
  • official Mini USB Host Shield 2.0 for Arduino ADK SLR development tool 3 orders
Bestseller No. 9
Lenovo Legion 17' Armored Backpack II, Gaming Laptop Bag, Double-Layered Protection, Dedicated Storage Pockets, GX40V10007, Black
1,406 Reviews
Lenovo Legion 17" Armored Backpack II, Gaming Laptop Bag, Double-Layered Protection, Dedicated Storage Pockets, GX40V10007, Black
  • Spacious interior - the dedicated PC compartment fits gaming laptops up to a whopping 17. 3". Perfectly placed pockets provide quick access to your tools when you need them
  • Unbeatable durability - Protect your favorite gear with an ultra-tough, high-density EVA molded front shield lined with water-resistant PU fabric
  • Unwavering comfort - This laptop backpack comes equipped with back padding, ventilation, and adjustable shoulder and chest straps that provide comfort that never quits
  • Sleek style - With its neat and sleek design, the Legion 17" Armored backpack II beautifully combines gaming performance with style that fits any situation
  • Dedicated gear storage - separate pockets designed to hold your keyboard and palm rest, mouse, headphones, water bottle, and more
Bestseller No. 10
TV Docking Station for Nintendo Switch, WEGWANG Portable TV Dock Station Replacement for Official Nintendo Switch with HDMI and USB 3.0 Port
2,506 Reviews
TV Docking Station for Nintendo Switch, WEGWANG Portable TV Dock Station Replacement for Official Nintendo Switch with HDMI and USB 3.0 Port
  • Ventilation Holes Design & Smart Chip System: Oversized venting on both sides of the switch stand, so don't worry about ventilation holes will be blocked and affect equipment cooling. Built in smart original chip, having Short-circuit Protection, Over Power Protection, Recovery Protection and Overheating Protection. Our switch docking station have professional technical support, after repeated testing, with the highest quality assurance!
  • Replacement For Official Nintendo Switch Dock: This dock is only 82.5g(2.9oz), which is much more portable and lightweight than official switch dock, ideal replacement for taking out anywhere. Same amount of ports for USB controllers and HDMI ports for TV.(IF YOU WANT THE SWITCH DOCK WITH HDMI CABLE, PLEASE SEARCH THE ASIN B08R3T1Y5Z ON AMAZON SEARCH BOX. THE HMDI CABLE IS INCLUDED ON THAT LISTING PAGE.)
  • Never Scratch Your Switch Screen & Overheat: The official dock is a RISK for scratching the screen even with a screen protector, but now WEGWANG solve this problem with unique design. The console sits on top of the unit instead of sliding into the Switch docking station avoiding overheat.
  • One-touch Display Switching: Switch with one-touch button between the host and the TV display interface with 2K HDMI port. Note: To play and charge at the same time, you need a 15V/2.6A power supply (NOT INCLUDED). Three angles allows you to play your Nintendo Switch at the best viewing angle for different environments.
  • Won't Sliding Around: The anti-slip base design prevents it from sliding around or falling over by accident. WHAT YOU GET: One WEGWANG Nintendo Switch Dock Station, One Package Box. And WEGWANG provides 1 year Warranty, 1 month money return guarantee and 24H x 7 email support.

Related Article:   USB Monitor

See also  How To Fix Roku Flashing Black Screen? (7 Easy Fixes!)

At present, the code example, also featuring Andrew’s FAT and extended memory implementation, can only be run on “big” Arduinos such as Mega and Mega 2560. Another FAT implementation, developed by Alex Glushchenko, is being tested – there is a slight possibility that at least some functionality can be demonstrated on a regular UNO board.

On the other hand, the mass storage component can be used without a file system by simply reading/writing physical sectors; this approach can save a lot of memory. The documentation for the mass storage class code is available here.

Many hours have been spent testing the code; it should work with any device which claims to support “mass storage bulk only” transport.

While newer (less than 5 years old) won’t cause any problems, older ones could be finicky. If your device shows odd behavior with this code, please let me know – I will trade it for the good working one.

Enjoy!

HID support for USB Host Shield Library 2.0 released

HID r.2.0 released

HID r.2.0 released

I am pleased to announce that after a long and difficult development period Human Input Device AKA HID class support has been added to USB Host Shield Library r.2.0 and is available on gitHub – I suggest downloading the whole directory since some modifications have been also made to core files to accommodate a new class.

HID devices include popular devices like keyboards, mice, joysticks, game controllers, bar code scanners, RFID and magnetic card readers, digital scales, and UPSes, to name a few.

I previously wrote about interfacing with HID devices here, here, and here. The code examples in these articles were written for the legacy USB Host Shield library and can’t be compiled with the current revision, however, the basic principles are the same – the device is periodically polled by the host and sends back a data block called a report containing changes in device controls (buttons, switches, jog dials, etc.) since the last poll.

See also  How To Trace Coaxial Cable? [Quick And Easy Guide]

Even though different devices have different report formats, for a certain device, the report format is stored in the device in a data structure called report descriptor. Therefore, it is possible to learn about device controls from the device itself by parsing its report descriptor.

There is one special case where the report format is known in advance. Almost all HID keyboards and mice support the so-called boot protocol intended for communication to very simple systems like PC configuration screen when the computer runs from BIOS.

The keyboard boot protocol report consists of 8 bytes containing the state of modifier keys (CTRL, SHIFT, etc.) in the first byte, the second byte being reserved, and up to 6 key scan codes in the rest of the report.

Mouse boot protocol report consists of 3 bytes, the first of which contains the state of left, right, and middle buttons, and the other 2 store X and Y travel since the last poll.

In many cases boot protocol capabilities are more than enough for an Arduino project; for this reason, the boot protocol class is the first to be released. To demonstrate the operations of this class, 2 simple sketches have been developed, one for a mouse, and another for a keyboard.

Sketches are designed for USB Host Shield 2.0 attached to compatible Arduino board. Also, it is recommended to use external power supply while working with HID devices – I’ve seen many devices which would refuse to function when Arduino receives power from its USB port only.

The operation of the mouse sketch is quite simple: any mouse movement and/or button press causes a corresponding callback to be called. Below is the sketch output:

1234567891011121314151617000200dx=2 dy=0000100dx=1 dy=00002FFdx=2 dy=-1020000R Butt Dndx=0 dy=0000000R Butt Up020000R Butt Dn030000L Butt Dn020000L Butt Up

Sketch prints mouse reports in hex and human-readable form. For example, lines 2 and 4 show mouse movement, lines 8 and 9 show the first report when a button was pressed with no movement, the rest is just various button presses/releases.

The keyboard sketch is more advanced. It polls the keyboard, tracks key presses, converts scan codes to ASCII, and also sends output reports to turn keyboard LEDs on/off when CAPS LOCK, Num Lock, or Scroll Lock key is pressed. Here is the output:

See also  How To Make Alexa Stop Saying Ok? (Complete And Easy Guide)
123456789101112131415161718192021222324252627282930313233343536373839404100001A0000000000DN      >1A<ASCII: w0000000000000000UP      >1A<0000080000000000DN      >08<ASCII: e0000000000000000UP      >08<00000B0000000000DN      >0B<ASCII: h00000B0700000000DN      >07<ASCII: d00000B070A090000DN      >0A<ASCII: gDN      >09<ASCII: f0000070A09000000UP      >0B<0000070900000000UP      >0A<000007090B000000DN      >0B<ASCII: h0000000000000000UP      >07<UP      >09<UP      >0B<0000390000000000DN      >39<00003900000000000000000000000000UP      >39<0000390000000000DN      >39<0000000000000000UP      >39<

HID boot devices are quite common, inexpensive, and easy to interface to Arduino using USB Host Shield. Two demo sketches should provide a good example of HID boot class usage as well as serve as templates to incorporate into other projects.

If you still have questions, please ask them in the comments – I will be glad to help. In coming weeks I’m going to write another article or two showing ways to use this new class. Stay tuned!

USB Host Shield library Version 2.0 released

What started as a quick re-factoring effort transformed into a major redevelopment, but finally all pieces fit together tightly and I am pleased to announce that initial release of USB Host Shield library ver.2.0 has been posted to github.

This new version contains several major improvements:

Only 5 Arduino pins are now required for USB Host Shield to function – 3 standard SPI pins (SCK, MISO, MOSI) and 2 remappable pins (SS and INT).

The low-level interface to MAX3421E has been re-designed. Arduino pin manipulation routines have been replaced with mechanisms inspired by Konstantin Chizhov’s C++ AVR pin templates. As a result, low-level transfers became approximately 3.5 times faster.

Also, pin reassignment can be done much easier by passing pin numbers into the MAX3421E template during instantiation.

The high-level interface to USB devices has been re-designed as well. It is now possible to connect a USB hub to the shield and have many devices on the USB bus, up to 7 daisy-chained 8-port hubs plus up to 44 devices connected to hub ports left after daisy-chaining, memory permitting.

Also, a standard mechanism of device initialization/polling/releasing has been added to enumeration.

Several minor code improvements have also been made. NAK_LIMIT is now tied to an endpoint – it is now possible to have NAK_LIMIT set to 1 for the interrupt endpoint and 32000 for the bulk endpoint of the same device simultaneously.

The control transfer function now accepts callback in order to split long chunks of data, if necessary. inTranser() function now is able to return an actual number of bytes received.

USB Host Shield
USB Host Shield

Support for several popular device classes has been added. Device initialization and event handling are now moved to a library specific to the devise class, therefore user application doesn’t need to do this and only needs to process actual device data.

Human Interface Device AKA HID. Keyboards, mice, game controllers, bar code scanners, magnetic cards,s and RFID readers – the list goes on. Initialization, polling, report descriptor parsing, as well as reading, and sending reports are possible.

Asynchronous Serial over USB AKA CDC. Devices of this class provide serial connectivity. For example, newer Arduino boards, such as UNO and Mega 2560 communicate to a PC using a CDC ACM-class device, while older boards, such as Duemilanove, use FTDI FT232 USB-to-serial converter.

3 main types of converters are supported – CDC ACM (newer Arduinos and most modern cell phones), FTDI FT232 (older Arduinos plus a ton of standalone converters ), and Prolific PL2303 (mainly used in USB cables for various cellphones).

Several other device classes are in the works and will be available soon. They include:

  • Mass Storage Devices – Flash Drives, USB sticks, card readers, etc.
  • PTP – a protocol used in digital cameras. The PTP code is being transferred from the current PTP project with minor changes.
  • Android ADK protocol, was recently introduced in versions 3.1 and 2.3.4 of Android OS. Simple lightweight protocol for bi-directional communication with Android phone or tablet.

In addition to that, the USB hub is supported by its own class; however, in order to use it nothing special needs to be done apart from defining an instance of hub class for each hub.

Library code is compatible with current revisions of USB Host Shield, i.e. full-size shield r2.0 and Mini shield r1.1. Older shields can be made compatible with the new library by performing a simple hardware modification.

I will add a section to hardware manual eventually, in the meantime, if you still have an old shield and want to know how to mod it to make it compatible with new library, drop me a line.

It also should be noted that due to extra code needed for multi-device support binaries compiled from this library being larger than the old one – before migrating your existing project make sure it will fit into your Arduino.

A hub_demo directory under examples contains a sketch demonstrating hub functionality. The sketch goes from hub to hub initializing devices and then prints their device and configuration descriptors.

As can be seen in the title picture, I have a 24 port hub, which actually consists of four daisy-chained 7-port hubs, 3 cell phones, a couple of mice, a USB-to-serial converter, Xbee plugged into Explorer board, a digital scale, a pair of RC controllers, digital camera, an RFID reader.

The output of a sketch running this setup can be seen here.

The following lines:

  • USBHub Hub1(&Usb);
  • USBHub Hub2(&Usb);
  • USBHub Hub3(&Usb);
  • USBHub Hub4(&Usb);

create hub instances, if you need more than four (up to 7), add USBHub Hub5(&Usb);, USBHub Hub6(&Usb);, USBHub Hub7(&Usb);. If you need to address more than 16 devices, including hubs, increase USB_NUMDEVICES in Usb.h.

Except for hubs, the sketch doesn’t make any attempts to configure any devices, it can be run with any USB devices which are available.

At present, I only have one other sample sketch in the ACM directory. It is a simple terminal intended to be used with cell phones. I will post details about using it soon. In the meantime, take a look at the code, run sketches, and let me know what you think.

Original Post: https://www.circuitsathome.com/mcu/mass-storage-support-for-usb-host-library-2-0-released

Check out the homepage www.circuitsathome.com

FAQs About

What is usb2 host?

The MAX3421E-based USB Host Shield Library has been updated to version 2.0. HID devices, FTDI, ADK, ACM, PL2303, Bluetooth HID devices, SPP communication, and mass storage devices are all supported. It also works with PS3, PS4, PS5, PS Buzz, Wii, Switch Pro, and Xbox controllers.

What does a USB Host Shield do?

The Arduino USB host shield connects a USB device to the Arduino Board. Simply put, USB host shields enable Arduino boards to function as USB hosts. You can use this USB host shield to connect any USB device to the Arduino boards.

What is a host Shield?

The USB Host Shield is a low-cost development board intended for use in embedded applications that require USB Host functionality. The board supports full/low-speed USB 2.0 operation. The Arduino is the primary target platform, but it can also be used with any other micro equipped with an SPI interface.

Similar Posts