How about adding an example like this to "examples/DualRole/HID/" #283
Replies: 4 comments 1 reply
-
this looks great, thank you for sharing this example. I am bit busy with other works, will revieew this later on whenever I could. |
Beta Was this translation helpful? Give feedback.
-
@HisashiKato Incredible work! I found your work today and got it working! Some backstory: Several months ago, I saw David Zhang's desk controller and have wanted to implement something similar. However, I'd like to put a slightly different spin on this idea: I would like to buy cheap USB keypads (numpad), plug them into an RPI Pico W, and send MQTT messages to Home Assistant over Wi-Fi. Unfortunately, there don't seem to be any decent commercial IOT Wi-Fi button pads available on the market. A mass-produced USB numpad would be far cheaper and more robust than whatever I could design and manually build. Today, I almost posted asking for assistance using Pico-PIO-USB [https://docs.micropython.org/en/latest/develop/cmodules.html](as an external C-Library in MicroPython), but decided to search for any Arduino examples first. That's when I found your Adafruit_TinyUSB_Arduino Issue 292 post where you linked to your blog. RP2040搭載 Raspberry Pi Pico 互換ボードと TinyUSB Library for Arduino で、RP2040内蔵のUSBコントローラーをUSBデバイスではなくUSBホストとして使おうとしたら大変だった話. I spent a few hours re-installing the Arduino IDE and the necessary libraries. Next, I tested the RPI Pico W with multicore operation and set up Serial2 with a separate USB UART. Then, I found a USB Type-A female connector and a donor USB cable to create a suitable plug to insert USB devices. Lastly, I found a USB micro-B to USB Type-A female connector and plugged that into the Pico Zero W. The code on your blog worked, but it did not produce any output when I tried to move the devices around.
It was only when I looked closely at your video, that I saw you were running a different sketch. I came here and found it in the attached zip file. I made a few changes and got it working!
This is excellent. My next step is to cut down your code to work exclusively with USB numpads and MQTT to control my smart home devices.. However, I need to find a better way of handling these inputs. Micropython has a MicroPython-Async Library with specific functions for handling pushbutton callbacks for pressed, released, long presses, or double presses this sort of handles mechanical de-bouncing, but what I need is a function to prevent sending the same command within a short time-frame and a method to handle multiple keys pressed simultaneously. I don't know if there is an Arduino library which handles this. Again, excellent work! |
Beta Was this translation helpful? Give feedback.
-
5 hours later I have USB HID working to publish MQTT messages, with Home Assistant performing an action. I added Wi-Fi and MQTT set up information to core 0. Then in
Now when I press the 0 key on my keyboard, the action fires! @HisashiKato thank you so much for putting in the effort to make USB host functional. You've brightened my day! |
Beta Was this translation helpful? Give feedback.
-
I gave up on this as there was no sign that examples like this would be enriched. |
Beta Was this translation helpful? Give feedback.
-
Hello.
I wrote an example sketch to test a USB host using Pico-PIO-USB and Adafruit TinyUSB Library for Arduino.
This is a ZIP file of sketches.
usb_host_test.zip
230331_230951_1_1.mp4
In this video, I'm using Adafruit QT Py RP2040, so I'm using GPIO 28(A1) for USB D+ and GPIO 29(A0) for USB D-.
You can demonstrate USB keyboard, USB mouse and PS4 DUALSHOCK4.
I'm an amateur so I'm not sure if this is correct.
Please verify it, rewrite it if it's wrong, and use it as an example if you like it.
Thank you.
(This sentence was translated from Japanese to English using a translation site)
Beta Was this translation helpful? Give feedback.
All reactions