Hi Guys,
I reciently recieved my Arduino Giga R1 Wifi board. I have been trying to find an example of one that uses a keyboard connected to the USB - A. Do any of you have any pojects?
Hi @williamnumismatics . There is a library here:
The library is in the alpha development phase, so maybe not very polished or well supported. For this reason, it is not available for installation from the Arduino IDE Library Manager . I'll provide instructions for installing it with Arduino IDE in case you would like to try it:
Click the following link to open the library's GitHub repository homepage in your web browser:
https://github.com/arduino-libraries/USBHostGiga
Click the "Code ▾ " button you see on that page.
Select Download ZIP from the menu.
A download of the ZIP file of the library will start.
Wait for the download to finish.
Select Sketch > Include library > Add .ZIP Library from the Arduino IDE menus.
The "Select the zip file containing the library you'd like to add " dialog will open.
Select the downloaded file from the dialog.
Click the "Open " button.
The dialog will close.
Wait for the installation process to finish, as indicated by a notification at the bottom right corner of the Arduino IDE window:
ⓘ Successfully installed library from ...
You will now find a sketch demonstrating the library usage under the IDE's File > Examples > USBHostGiga-master > KeyboardGiga menu.
There is another more well-polished library for the GIGA R1 WiFi USB host functionality named "Arduino_USBHostMbed5 ". There is some information about the usability of that library with keyboards in the "USBHostGiga " library's readme:
https://github.com/arduino-libraries/USBHostGiga#readme
This library has been created to overcome the limitations of GitHub - arduino-libraries/Arduino_USBHostMbed5 when it's time to talk with USB Low Speed devices like keyboards and mice.
In case you are interested in using the "Arduino_USBHostMbed5 " library instead of the "USBHostGiga " library, there is some discussion about that here:
As I mentioned in the other thread:
I was curious about how hard it would be to support some different USB Objects like Mouse and Keyboards using the Arduino_USBHostMbed5 library. There is some support in the library USBHostGIGA. I am assuming you cannot use both of these libraries within a single sketch.
support USBLS (low speed) devices within Arduino_USBHostMbed5. I have a version that is at least somewhat working. It is a fork/branch based off of @BobTheDog fork/branch that is associa…
and more here:
opened 02:11PM - 11 Nov 23 UTC
There are several devices like keyboards, which run in USB Low Speed (1.5MBps) a… nd are not properly being handled.
For example, I have a Dell keyboard plugged in. I believe this one came with my newer computer I purchased in the last couple of years.
If I run the KeyboardGiga example sketch from the USBHostGiga library it receives, the keystrokes and prints them out in the Serial monitor.
If I instead run a similar test using this library it does not.
```
/*
USBHost Keyboard test
The circuit:
- Arduino GIGA
This example code is in the public domain.
*/
#include <Arduino_USBHostMbed5.h>
#include <USBHostHID/USBHostKeyboard.h>
REDIRECT_STDOUT_TO(Serial)
USBHostKeyboard kbd;
// If you are using a Portenta Machine Control uncomment the following line
// mbed::DigitalOut otg(PB_14, 0);
void setup()
{
Serial.begin(115200);
while (!Serial) {}
Serial.println("Starting Keyboard test...");
// Enable the USBHost
pinMode(PA_15, OUTPUT);
digitalWrite(PA_15, HIGH);
// if you are using a Max Carrier uncomment the following line
// start_hub();
kbd.attach(&kbd_key_cb);
kbd.attach(&kbd_keycode_cb);
while (!kbd.connect()) {
Serial.println("No keyboard connected");
delay(5000);
}
}
void loop()
{
delay(1000);
}
void kbd_key_cb(uint8_t key) {
Serial.print("Key pressed: ");
Serial.print(key, HEX);
Serial.print("(");
if ((key >= ' ') && (key <= '~')) Serial.write(key);
Serial.println(")");
}
void kbd_keycode_cb(uint8_t keycode, uint8_t mod) {
Serial.print("Keycode: ");
Serial.print(keycode, HEX);
Serial.print(" mod: ");
Serial.println(mod, HEX);
}
```
I added debug output to the keyboard class... So I know it is being called. Debug shows:
```
Starting Keyboard test...
No keyboard connected
got device
intf_class: 3
intf_subclass: 1
intf_protocol: 1
intf_nb: 0
intf_class: 3
intf_subclass: 0
intf_protocol: 0
ret: 0
after enumerate
```
The input code for the Serial class is not receiving any data.
I have a Logic Analyzer attached and it is showing the device is sending data:

And using my USB Analyzers for the Saleae, we see the following messages:
<html xmlns:v="urn:schemas-microsoft-com:vml"
xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:x="urn:schemas-microsoft-com:office:excel"
xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta name=ProgId content=Excel.Sheet>
<meta name=Generator content="Microsoft Excel 15">
<link id=Main-File rel=Main-File
href="file:///C:/Users/kurte/AppData/Local/Temp/msohtmlclip1/01/clip.htm">
<link rel=File-List
href="file:///C:/Users/kurte/AppData/Local/Temp/msohtmlclip1/01/clip_filelist.xml">
<style>
<!--table
{mso-displayed-decimal-separator:"\.";
mso-displayed-thousand-separator:"\,";}
@page
{margin:.75in .7in .75in .7in;
mso-header-margin:.3in;
mso-footer-margin:.3in;}
tr
{mso-height-source:auto;}
col
{mso-width-source:auto;}
br
{mso-data-placement:same-cell;}
td
{padding-top:1px;
padding-right:1px;
padding-left:1px;
mso-ignore:padding;
color:black;
font-size:11.0pt;
font-weight:400;
font-style:normal;
text-decoration:none;
font-family:Calibri, sans-serif;
mso-font-charset:0;
mso-number-format:General;
text-align:general;
vertical-align:bottom;
border:none;
mso-background-source:auto;
mso-pattern:auto;
mso-protection:locked visible;
white-space:nowrap;
mso-rotate:0;}
-->
</style>
</head>
<body link="#0563C1" vlink="#954F72">
0.832053362 | SETUP | 0x0 | 0x0 | [GET_DESCRIPTOR - DEVICE #:0 I:0x0 L:0x8] | 0x80 0x6 0x0 0x1 0x0 0x0 0x8 0x0 |
-- | -- | -- | -- | -- | -- | --
0.832366214 | IN | 0x0 | 0x0 | | 0x12 0x1 0x10 0x1 0x0 0x0 0x0 0x8 |
0.832567682 | SETUP | 0x0 | 0x0 | SET_ADDRESS I:0x0 L:0x0] | 0x0 0x5 0x1 0x0 0x0 0x0 0x0 0x0 |
0.83507364 | SETUP | 0x0 | 0x1 | [GET_DESCRIPTOR - DEVICE #:0 I:0x0 L:0x8] | 0x80 0x6 0x0 0x1 0x0 0x0 0x8 0x0 |
0.835433222 | IN | 0x0 | 0x1 | | 0x12 0x1 0x10 0x1 0x0 0x0 0x0 0x8 |
5.247817658 | SETUP | 0x0 | 0x1 | [GET_DESCRIPTOR - DEVICE #:0 I:0x0 L:0x12] | 0x80 0x6 0x0 0x1 0x0 0x0 0x12 0x0 |
5.248132034 | IN | 0x0 | 0x1 | | 0x12 0x1 0x10 0x1 0x0 0x0 0x0 0x8 |
5.248332872 | IN | 0x0 | 0x1 | | 0xca 0x4 0x27 0x0 0x18 0x1 0x1 0x2 |
5.24848434 | IN | 0x0 | 0x1 | | 0x0 0x1 | | | |
5.248818002 | SETUP | 0x0 | 0x1 | [GET_DESCRIPTOR - CONFIG #:0 I:0x0 L:0x9] | 0x80 0x6 0x0 0x2 0x0 0x0 0x9 0x0 |
5.249177614 | IN | 0x0 | 0x1 | | 0x9 0x2 0x3b 0x0 0x2 0x1 0x0 0xa0 |
5.249328152 | IN | 0x0 | 0x1 | | 0x32 | | | |
5.24949202 | SETUP | 0x0 | 0x1 | [GET_DESCRIPTOR - CONFIG #:0 I:0x0 L:0x3b] | 0x80 0x6 0x0 0x2 0x0 0x0 0x3b 0x0 |
5.249817728 | IN | 0x0 | 0x1 | | 0x9 0x2 0x3b 0x0 0x2 0x1 0x0 0xa0 |
5.250017522 | IN | 0x0 | 0x1 | | 0x32 0x9 0x4 0x0 0x0 0x1 0x3 0x1 |
5.250218148 | IN | 0x0 | 0x1 | | 0x1 0x0 0x9 0x21 0x10 0x1 0x0 0x1 |
5.250416976 | IN | 0x0 | 0x1 | | 0x22 0x41 0x0 0x7 0x5 0x81 0x3 0x8 |
5.25081862 | IN | 0x0 | 0x1 | | 0x0 0x18 0x9 0x4 0x1 0x0 0x1 0x3 |
5.251016772 | IN | 0x0 | 0x1 | | 0x0 0x0 0x0 0x9 0x21 0x10 0x1 0x0 |
5.251216778 | IN | 0x0 | 0x1 | | 0x1 0x22 0x9f 0x0 0x7 0x5 0x82 0x3 |
5.25141592 | IN | 0x0 | 0x1 | | 0x8 0x0 0xa | | |
5.257467042 | SETUP | 0x0 | 0x1 | [SET_CONFIGURATION I:0x0 L:0x0] | 0x0 0x9 0x1 0x0 0x0 0x0 0x0 0x0 |
5.762888028 | IN | 0x1 | 0x1 | | 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 |
5.85990304 | IN | 0x1 | 0x1 | | 0x0 0x0 0x38 0x0 0x0 0x0 0x0 0x0 |
5.952923144 | IN | 0x1 | 0x1 | | 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 |
6.079945542 | IN | 0x1 | 0x1 | | 0x0 0x0 0x38 0x0 0x0 0x0 0x0 0x0 |
6.228969228 | IN | 0x1 | 0x1 | | 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 |
6.351984988 | IN | 0x1 | 0x1 | | 0x0 0x0 0x38 0x0 0x0 0x0 0x0 0x0 |
6.476997196 | IN | 0x1 | 0x1 | | 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 |
6.59402179 | IN | 0x1 | 0x1 | | 0x0 0x0 0x38 0x0 0x0 0x0 0x0 0x0 |
6.71103967 | IN | 0x1 | 0x1 | | 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 |
6.816071866 | IN | 0x1 | 0x1 | | 0x0 0x0 0x10 0x0 0x0 0x0 0x0 0x0 |
7.007111472 | IN | 0x1 | 0x1 | | 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 |
</body>
</html>
For more information about this device, I ran my sketch which tries to print out information about the device, Currently up at:
https://github.com/KurtE/GIGA_USBHostMBed5_devices/tree/main/examples/GIGA_USBHost_DeviceInfo
```
*** starting Device information sketch ***
Device:0x2400c714
VID: 4CA, PID: 27
Manufacturer: Lite-On Technology Corp.
Product: USB Multimedia Keyboard
Speed: 0
Size of configuration Descriptor: 59
Configuration Descriptor
2400E8D0 - 09 02 3B 00 02 01 00 A0 32 09 04 00 00 01 03 01 : ..;..... 2.......
2400E8E0 - 01 00 09 21 10 01 00 01 22 41 00 07 05 81 03 08 : ...!.... "A......
2400E8F0 - 00 18 09 04 01 00 01 03 00 00 00 09 21 10 01 00 : ........ ....!...
2400E900 - 01 22 9F 00 07 05 82 03 08 00 0A : ."...... ...
Config:
wTotalLength: 59
bNumInterfaces: 2
bConfigurationValue: 1
iConfiguration: 0
bmAttributes: 160
bMaxPower: 50
****************************************
** Interface level **
bInterfaceNumber: 0
bAlternateSetting: 0
Number of endpoints: 1
bInterfaceClass: 3
bInterfaceSubClass: 1
HID (BOOT)
bInterfaceProtocol: 1
Keyboard
iInterface: 0
HID Descriptor size: 65
Endpoint: 81 In
Attrributes: 3 Interrupt
Size: 8
Interval: 24
>>>>> USBDumperDevice::getHIDDesc(0) called <<<<<
2400E918 - 05 01 09 06 A1 01 05 07 19 E0 29 E7 15 00 25 01 : ........ ..)...%.
2400E928 - 95 08 75 01 81 02 95 08 75 01 81 01 05 08 19 01 : ..u..... u.......
2400E938 - 29 03 95 03 75 01 91 02 95 01 75 05 91 01 05 07 : )...u... ..u.....
2400E948 - 19 00 2A FF 00 15 00 26 FF 00 95 06 75 08 81 00 : ..*....& ....u...
2400E958 - C0 : .
HID Report Descriptor (0x2400e918) size: 65
05 01 // Usage Page(1) - Generic Desktop
09 06 // Usage(6) -(Keyboard)
A1 01 // Collection(1) top Usage(10000)
05 07 // Usage Page(7) - Keycode
19 E0 // Usage Minimum(e0) - (Left Control)
29 E7 // Usage Maximum(e7) - (Right GUI)
15 00 // Logical Minimum(0)
25 01 // Logical maximum(1)
95 08 // Report Count(8)
75 01 // Report Size(1)
81 02 // Input(2) // (Data, Variable, Absolute)
95 08 // Report Count(8)
75 01 // Report Size(1)
81 01 // Input(1) // (Constant, Array, Absolute)
05 08 // Usage Page(8) - LEDs
19 01 // Usage Minimum(1) -
29 03 // Usage Maximum(3) -
95 03 // Report Count(3)
75 01 // Report Size(1)
91 02 // Output(2) // (Data, Variable, Absolute)
95 01 // Report Count(1)
75 05 // Report Size(5)
91 01 // Output(1) // (Constant, Array, Absolute)
05 07 // Usage Page(7) - Keycode
19 00 // Usage Minimum(0) - (Keycode 0)
2A FF 00 // Usage Maximum(ff) - (Keycode 255)
15 00 // Logical Minimum(0)
26 FF 00 // Logical maximum(ff)
95 06 // Report Count(6)
75 08 // Report Size(8)
81 00 // Input(0) // (Data, Array, Absolute)
C0 // End Collection
****************************************
** Interface level **
bInterfaceNumber: 1
bAlternateSetting: 0
Number of endpoints: 1
bInterfaceClass: 3
bInterfaceSubClass: 0
HID
bInterfaceProtocol: 0
None
iInterface: 0
HID Descriptor size: 159
Endpoint: 82 In
Attrributes: 3 Interrupt
Size: 8
Interval: 10
>>>>> USBDumperDevice::getHIDDesc(1) called <<<<<
2400E918 - 05 01 09 80 A1 01 85 01 05 01 19 81 29 88 15 00 : ........ ....)...
2400E928 - 25 01 95 08 75 01 81 02 C0 05 0C 09 01 A1 01 85 : %...u... ........
2400E938 - 02 15 00 25 01 0A 83 01 0A CD 00 0A B7 00 0A E9 : ...%.... ........
2400E948 - 00 0A EA 00 0A E2 00 0A B6 00 0A B5 00 0A 8A 01 : ........ ........
2400E958 - 0A 92 01 0A 94 01 0A 21 02 0A 23 02 0A 24 02 0A : .......! ..#..$..
2400E968 - 25 02 0A 26 02 0A 27 02 0A 2A 02 95 12 75 01 81 : %..&..'. .*...u..
2400E978 - 02 95 01 75 06 81 01 C0 05 09 09 01 A1 01 85 03 : ...u.... ........
2400E988 - 15 00 25 01 0A 2C 00 0A 18 00 0A 20 00 0A 1F 00 : ..%..,.. ... ....
2400E998 - 0A 1C 00 0A 3D 00 0A 41 00 0A 42 00 0A 43 00 0A : ....=..A ..B..C..
2400E9A8 - 46 00 95 0A 75 01 81 02 95 01 75 06 81 01 C0 : F...u... ..u....
HID Report Descriptor (0x2400e918) size: 159
05 01 // Usage Page(1) - Generic Desktop
09 80 // Usage(80) -(?)
A1 01 // Collection(1) top Usage(10080)
85 01 // Report ID(1)
05 01 // Usage Page(1) - Generic Desktop
19 81 // Usage Minimum(81) - (System Power Down)
29 88 // Usage Maximum(88) - (?)
15 00 // Logical Minimum(0)
25 01 // Logical maximum(1)
95 08 // Report Count(8)
75 01 // Report Size(1)
81 02 // Input(2) // (Data, Variable, Absolute)
C0 // End Collection
05 0C // Usage Page(c) - Consumer
09 01 // Usage(1) -(Consumer Controls)
A1 01 // Collection(1) top Usage(c0000)
85 02 // Report ID(2)
15 00 // Logical Minimum(0)
25 01 // Logical maximum(1)
0A 83 01 // Usage(183) -(AL Consumer Control Configuration)
0A CD 00 // Usage(cd) -(Pause/Continue)
0A B7 00 // Usage(b7) -(Stop)
0A E9 00 // Usage(e9) -(Volume Up)
0A EA 00 // Usage(ea) -(Volume Down)
0A E2 00 // Usage(e2) -(Mute)
0A B6 00 // Usage(b6) -(Scan Previous Track)
0A B5 00 // Usage(b5) -(Scan Next Track)
0A 8A 01 // Usage(18a) -(AL Email Reader)
0A 92 01 // Usage(192) -(AL Calculator)
0A 94 01 // Usage(194) -(AL Local Machine Browser)
0A 21 02 // Usage(221) -(AC Search)
0A 23 02 // Usage(223) -(AC Home)
0A 24 02 // Usage(224) -(AC Back)
0A 25 02 // Usage(225) -(AC Forward)
0A 26 02 // Usage(226) -(AC Stop)
0A 27 02 // Usage(227) -(AC Refresh)
0A 2A 02 // Usage(22a) -(AC Bookmarks)
95 12 // Report Count(12)
75 01 // Report Size(1)
81 02 // Input(2) // (Data, Variable, Absolute)
95 01 // Report Count(1)
75 06 // Report Size(6)
81 01 // Input(1) // (Constant, Array, Absolute)
C0 // End Collection
05 09 // Usage Page(9) - Button
09 01 // Usage(1) - (BUTTON 1)
A1 01 // Collection(1) top Usage(90000)
85 03 // Report ID(3)
15 00 // Logical Minimum(0)
25 01 // Logical maximum(1)
0A 2C 00 // Usage(2c) - (BUTTON 44)
0A 18 00 // Usage(18) - (BUTTON 24)
0A 20 00 // Usage(20) - (BUTTON 32)
0A 1F 00 // Usage(1f) - (BUTTON 31)
0A 1C 00 // Usage(1c) - (BUTTON 28)
0A 3D 00 // Usage(3d) - (BUTTON 61)
0A 41 00 // Usage(41) - (BUTTON 65)
0A 42 00 // Usage(42) - (BUTTON 66)
0A 43 00 // Usage(43) - (BUTTON 67)
0A 46 00 // Usage(46) - (BUTTON 70)
95 0A // Report Count(a)
75 01 // Report Size(1)
81 02 // Input(2) // (Data, Variable, Absolute)
95 01 // Report Count(1)
75 06 // Report Size(6)
81 01 // Input(1) // (Constant, Array, Absolute)
C0 // End Collection
parseInterface nb:0
bInterfaceClass = 3
bInterfaceSubClass = 1
HID (BOOT)
bProtocol = 1
Keyboard
useEndpoint(0, 3, 2)
parseInterface nb:1
bInterfaceClass = 3
bInterfaceSubClass = 0
HID
bProtocol = 0
None
New Debug device: VID:04ca PID:0027 [dev: 0x2400c714 - intf: 0]
USB host device(4ca:27) connected
Manufacturer: Lite-On Technology Corp.
Product: USB Multimedia Keyboard
```
Note: I tried to print out the speed of the device, but the method appears to always return false... From quick guessing I think should be HIGH for low speed? Would have hoped there were at least three values (LS, FS, HS), but it also appears like this library does not support High speed...
pert
Split this topic
January 20, 2025, 8:21pm
4