Live data from Hacker News

Ask HN: Advice for creating a USB device linking 2 computers

news.ycombinator.com

1–10 of 46 posts

Ask HN: Advice for creating a USB device linking 2 computers

#1
I want to build a little device that connects two computers together via usb, and send keystrokes from one to the other.

(I would use it to use a laptop keyboard on a headless computers).

I am looking for an easy solution, it does not have to be the cheapest.

ChatGPT points me to Arduino, but as far as I can see, there's no arduino with 2 usb ports. It also points me to Raspery pi zero, but that's a computer, not a microcontroller, so not sure if it's suitable.

If anyone with experience can give me some pointers, it would be greatly appreciated!

Re: Ask HN: Advice for creating a USB device linking 2 computers

#3

Sounds like a cool project, but you may find that using SSH or RealVNC to be a bit easier and cheaper. ChatGPT isn't wrong - this sounds like what you need: https://pypi.org/project/zero-hid/ .

Thanks for your thoughts. I agree that using software would be easier, but I wanted to do it in hardware in this specific case.

I am unfamiliar with Raspberry pi, but if my understanding is correct, it's running a real os. So I would need to send it a command to actually shut down every time I want to remove the usb device. More generally, having a general purpose OS on the little device seems overkill for that use case, no?

Re: Ask HN: Advice for creating a USB device linking 2 computers

#4
post #3

Sounds like a cool project, but you may find that using SSH or RealVNC to be a bit easier and cheaper. ChatGPT isn't wrong - this sounds like what you need: https://pypi.org/project/zero-hid/ .

Thanks for your thoughts. I agree that using software would be easier, but I wanted to do it in hardware in this specific case. I am unfamiliar with Raspberry pi, but if my understanding is correct, it's running a real os. So I would need to send it a command to actually shut down every time I want to remove the usb device. More generally, having a general purpose OS on the little device seems overkill for that use c…

It usually runs a Debian based image. And you would probably just have to reboot the script, or write a wrapper around the keyboard functions.

But yes, it's overkill for an overkill solution. Buying another keyboard may be easier.

Re: Ask HN: Advice for creating a USB device linking 2 computers

#5
post #3

Sounds like a cool project, but you may find that using SSH or RealVNC to be a bit easier and cheaper. ChatGPT isn't wrong - this sounds like what you need: https://pypi.org/project/zero-hid/ .

Thanks for your thoughts. I agree that using software would be easier, but I wanted to do it in hardware in this specific case. I am unfamiliar with Raspberry pi, but if my understanding is correct, it's running a real os. So I would need to send it a command to actually shut down every time I want to remove the usb device. More generally, having a general purpose OS on the little device seems overkill for that use c…

I'm confused, why do you want hardware and what do you want the hardware to do? And, why not use a USB keyboard?

You could use an rpi pico. It has a usb port and there is a software hack to bit bang a second usb port, iirc.

Re: Ask HN: Advice for creating a USB device linking 2 computers

#6
Get two microcontrollers with USBD peripheral and connect them using SPI or UART. Write two firmwares for these microcontrollers. Probably two Raspberry Pi Picos would be the easiest way to implement that project.

You also might want to use optical isolators between these microcontrollers, instead of wiring them directly. Just connecting grounds might be wrong, because different computers might have different grounds.

Re: Ask HN: Advice for creating a USB device linking 2 computers

#8
post #3

Earlier quoted context omitted.

Thanks for your thoughts. I agree that using software would be easier, but I wanted to do it in hardware in this specific case. I am unfamiliar with Raspberry pi, but if my understanding is correct, it's running a real os. So I would need to send it a command to actually shut down every time I want to remove the usb device. More generally, having a general purpose OS on the little device seems overkill for that use c…

I'm confused, why do you want hardware and what do you want the hardware to do? And, why not use a USB keyboard? You could use an rpi pico. It has a usb port and there is a software hack to bit bang a second usb port, iirc.

I am wondering if connecting over USB is an XY problem.

Re: Ask HN: Advice for creating a USB device linking 2 computers

#9
There are ST Micro parts with two USB ports that can can both be devices. I'm not sure the implications of powering them both at once. Look at STM32F407/417.

It might be simpler to get 2 microcontrollers and establish a communication link between them. Something like Arduino (Nano or even smaller third party boards), or Teensy would be suitable for this kind of setup.

Re: Ask HN: Advice for creating a USB device linking 2 computers

#10
Raspberry Pi definitely works! I have a project you can take a look at; you'll have to modify it slightly since you want a keyboard rather than a joystick, but they're both HID so the majority of it should work pretty much out of the box: https://github.com/saulrh/composite-joystick.
Post reply on HN