ESP32-S3 USB host interface to keyboard
ESP32-S3 USB host interface to keyboard
I need to have the ESP32-S3 act as a USB host so I can plug a keyboard into it.
Thus far I have not been able to find out any information on how to do this.
Would someone please point me in the right direction.
The examples are quite limited for host applications.
Thus far I have not been able to find out any information on how to do this.
Would someone please point me in the right direction.
The examples are quite limited for host applications.
Re: ESP32-S3 USB host interface to keyboard
Hi @username
ESP-IDF currently doesn't have support for Host Side HID class yet. We do have Host HID support planned, but I can't give you a definite timeline on when it will be supported (earliest possible is release v5.0).
If you need a quick way to talk to a particular Mouse/Keyboard specifically, you can probably try writing your own bare-bones HID class for now using the USB Host Library API.
We do have a HCD test case that reads some values from a mouse, but the enumeration and configuration of the device are hard coded
ESP-IDF currently doesn't have support for Host Side HID class yet. We do have Host HID support planned, but I can't give you a definite timeline on when it will be supported (earliest possible is release v5.0).
If you need a quick way to talk to a particular Mouse/Keyboard specifically, you can probably try writing your own bare-bones HID class for now using the USB Host Library API.
We do have a HCD test case that reads some values from a mouse, but the enumeration and configuration of the device are hard coded
Re: ESP32-S3 USB host interface to keyboard
If you want to know more of the details required to write your own code for this, have a look the book “USB by example” by John Hyde. Amongst others it explains how HID devices work on a driver level, USB descriptor’s, HID reports etc. I used this years ago to write HID and other devices.
Another writer which might be helpful here is Jan Axelson.
Both are well recommended.
Together with the ESP IDF examples I believe it is possible to write a keyboard client. Mind you, if any of the terms above are unfamiliar, you may want to think twice about doing this. If you’re not already slightly familiar with the USB protocol I advise against it.
Another writer which might be helpful here is Jan Axelson.
Both are well recommended.
Together with the ESP IDF examples I believe it is possible to write a keyboard client. Mind you, if any of the terms above are unfamiliar, you may want to think twice about doing this. If you’re not already slightly familiar with the USB protocol I advise against it.
Re: ESP32-S3 USB host interface to keyboard
Thanks guys for the info, every little bit helps.
I have not done anything USB related before, so I have to start my steep hill climb.
New hire at a company with PIC33 fanboys. Many products cant ship because we cannot get Microchip parts until 2023!!
I have converted most products over to ESP32, but there is one that uses a USB keyboard. So I have to give it a shot.
I just found out today that Teensy 4.1 has many host examples.
https://github.com/PaulStoffregen/USBHost_t36
I don't want to go with Teensy 4.1, but maybe their USB Host examples will shed some light. I sure hope Espressif starts making the same similar examples very soon.
I have not done anything USB related before, so I have to start my steep hill climb.
New hire at a company with PIC33 fanboys. Many products cant ship because we cannot get Microchip parts until 2023!!
I have converted most products over to ESP32, but there is one that uses a USB keyboard. So I have to give it a shot.
I just found out today that Teensy 4.1 has many host examples.
https://github.com/PaulStoffregen/USBHost_t36
I don't want to go with Teensy 4.1, but maybe their USB Host examples will shed some light. I sure hope Espressif starts making the same similar examples very soon.
Re: ESP32-S3 USB host interface to keyboard
https://github.com/tobozo/ESP32-USB-Sof ... y_USB_Test
and maybe some example how to start with USB host on S2/S3 (may be a bit outdated)
https://github.com/chegewara/esp32-usb-host
and maybe some example how to start with USB host on S2/S3 (may be a bit outdated)
https://github.com/chegewara/esp32-usb-host
Re: ESP32-S3 USB host interface to keyboard
Thanks, check it out tomorrow.
I tried the usb_host_lib example.
https://github.com/espressif/esp-idf/tr ... b_host_lib
When I plug the keyboard in I do get all its info.
I figured the hardest part is making the connection to the USB device. But since this example is doing that already, shouldn't it be easy just to get signaled when there is a key press ?
I tried the usb_host_lib example.
https://github.com/espressif/esp-idf/tr ... b_host_lib
When I plug the keyboard in I do get all its info.
I figured the hardest part is making the connection to the USB device. But since this example is doing that already, shouldn't it be easy just to get signaled when there is a key press ?
Re: ESP32-S3 USB host interface to keyboard
Actually its the hardest part (in keyboard case not that hard). After connecting it is not that hard to get all info, its enough to use example as you said and it can be the same code for all USB devices.
From now you have to know configuration, endpoints etc. Then you have to claim interfaces/endpoints. Next thing is to start listening on all IN endpoints (1 in case of keyboard). And at the end you have to know received bytes meaning, which may be different for different keyboards, but usually it is 9 bytes, i think, with specific meanings.
In general there is a lot to learn before you start using USB unless you find device driver you like.
Re: ESP32-S3 USB host interface to keyboard
okedoke. Thanks for the clarification.
Re: ESP32-S3 USB host interface to keyboard
FWIW, Using the Teensy 4.1 board with USBHost_t36 Lib and my USB keyboard and it worked great.
https://github.com/PaulStoffregen/USBHost_t36
Of course his functions are not the same as ours, so difficult for me to translate.
I have read the USB Host docs https://docs.espressif.com/projects/esp ... l#usb-host, and it was clear as mud to me. I have never been able to learn from API references alone. Examples are the way I learn.
So.... I have searched and searched and have not been able to find anyone using an ESP32-S3 as a host to a USB device other than a USB pendrive.
Has anyone come across anything ?
Espressif, do you have any ideas when you might start adding more host examples to examples/peripherals/usb/host/ folder ?
https://github.com/PaulStoffregen/USBHost_t36
Of course his functions are not the same as ours, so difficult for me to translate.
I have read the USB Host docs https://docs.espressif.com/projects/esp ... l#usb-host, and it was clear as mud to me. I have never been able to learn from API references alone. Examples are the way I learn.
So.... I have searched and searched and have not been able to find anyone using an ESP32-S3 as a host to a USB device other than a USB pendrive.
Has anyone come across anything ?
Espressif, do you have any ideas when you might start adding more host examples to examples/peripherals/usb/host/ folder ?
Re: ESP32-S3 USB host interface to keyboard
I bought 3 books and going through them. Some things are getting clear but getting stuck on ESP-IDF order of things.
Thus far (if I understand the order)
#1) usb_host_install()
#2) usb_host_client_register()
#3) usb_host_device_open()
#4) usb_host_device_info()
#5) usb_host_get_device_descriptor()
#6) usb_host_get_active_config_descriptor()
Is my next step to use usb_host_interface_claim() ?
Thus far (if I understand the order)
#1) usb_host_install()
#2) usb_host_client_register()
#3) usb_host_device_open()
#4) usb_host_device_info()
#5) usb_host_get_device_descriptor()
#6) usb_host_get_active_config_descriptor()
Is my next step to use usb_host_interface_claim() ?
Who is online
Users browsing this forum: No registered users and 110 guests