Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 4990

General • Re: Raspberry Pi and Pico: Sending Fast Data over USB Connection Pico to Pi

$
0
0
You have plenty of I/O available for buttons. I wouldn't bother with an external micro. More to build, more to debug, more to maintain.
Using the pico really is necessary. There isn't a lot of space inside the project shell, and I really don't need the wires messier than they already are.

There isn't space for a few extra wires but there is space for a Pico, a USB cable, and extra wires? That doesn't make sense. At least not to me.
The most straightforward way would be to connect as a USB serial port (USB CDC), and use it with C stdio (or whatever).
USB CDC looks like a good option

You sure about that? It's likely to be more work than USB HID.

To use CDC you'll need to:
  • Define a custom message format
  • Configure CDC on Pico
  • Send messages from Pico
  • Modify you Pi code to read serial data from the correct device with the correct settings. Preferably without blocking its other functions
  • Decode messages. Including coping with broken or incomplete ones
For USB HID):
  • Configure Pico as HID keyboard (there are circuit and micropython examples for this)
  • Send a HID report on button change(s)
  • On the Pi modify your code using a library of your choice to respond to keypress/joystick/whichever events. No messing with low level stuff like reading raw keyboard or serial data.
USB HID will also allow you to unit test your code (a custom protocol complicates testing/debugging as either end could be at fault and it may not be obvious which). Or to use a standard USB HID device in place of your custom Pico one.
, but I haven't been able to figure it out previously. :? Is there an easy way to use it with Circuit Python or Micro Python?
Check the official docs and do a web search. The truth is out there.

Full disclosure: I've not done USB HID with circuit/micro python on a Pico. I have done HID keyboard with full fat python on a Pi zero. It's almost trivial: https://github.com/thagrol/pwdgen

Statistics: Posted by thagrol — Fri Jan 24, 2025 11:27 pm



Viewing all articles
Browse latest Browse all 4990

Trending Articles