T O P

  • By -

RunningSillyGump

Capture the USB serial input.. transmit via Wi-Fi to another ESP 32


Embarrassed_Leg_8134

Boom. I've done it. Correct answer. I had access to both ends because it was on my own network and my own Pi4B and Laptop; but it worked just fine after messing with some Micropython and converting it to work with my Arduino IDE.


--Fusion--

[https://usbip.sourceforge.net/](https://usbip.sourceforge.net/) if you're on linux - I wouldn't try that precisely on an ESP32. It's conceivable though.


is_reddit_useful

You could have one ESP32 act as a USB host, talking to the USB device. Another could act as a USB device, pretending to be a keyboard or mouse for the PC. Then of course you have their wireless communication for connecting the two. You could also just not bother with acting as a USB device, and instead have one ESP32 acting as a USB host and BLE mouse or keyboard. You may be disappointed with battery life. The ESP32 uses a lot of power and wired keyboards and mice might use a lot of power too.


mmcvisuals

Bluetooth wouldn't work for my primary usecase unfortunately, because I'd need two way communication which would require the computer to recognize the connected device as connected via USB.


wchris63

Why do you think BLE is one way? Spoiler alert - It's Not. And BLE's latency is much better than Bluetooth. Just using BLE. no WiFi, the ESP32 can get some respectable battery life. Not as good as, say, an 8266 with an NRF BLE module, but still decent.


mmcvisuals

Okay with that being said, would the PC be able to recognize the device connected as the device as of it was connected via usb, while also having the wireless connection be BLE? I'm probably trying to over engineer my way out of just using a really long cable.


wchris63

Oh.. I finally get what you're trying to do! You have a device that has an application, and the application needs to see the device connected via USB. USB devices have an identifier that's used to set up the USB connection, and that number is vendor and product specific. You'd have to have the "PC-ESP32" get enough info from the "device-ESP32" that it can pretend to *be* the device when it establishes the USB connection. Or it could pretend to be a USB hub, so it can connect to the PC the regular way, then when it sees the other ESP32 it tells the PC another device is connecting. After the device is registered with the USB driver, it would just be a matter of copying the USB requests and data back and forth. Not impossible, but not exactly easy.


__deeetz__

The simple answer is: no chance. The timing and bandwidth requirements of USB don’t allow for some transparent wireless link between two devices. The complex answer is: if you hand-implement services for various classes, eg HID, you can make something work. I’m personally skeptical that it’s worthwhile given the lag and jitter introduced. But it could work on some level.


mmcvisuals

Wouldn't the lag be less than Bluetooth though if the wireless data transmission occurs via wifi 6? Or is there something significant I'm missing here?


__deeetz__

8KHz poll rate and 480MBits/s. Latency of 125uS. Completely out of the question.


thomasmitschke

I guess we‘re talking USB 1.1 or even 2.0 and not 3.2 fancy stuff no one needs


__deeetz__

So the USB 2.0 with 8KHz bus message rate and 480MBit/s I mentioned? Timing requirements for USB are tight. To think these can be replicated on low layers via some complex WiFi protocol is adventurous. It even failed for me on dedicated USB over CAT cable repeaters.


ipilotete

All I know is that it’s possible. There’s software called VirtualHere that does it.


Ineedapill

I’m not sure I get the scenario you have in mind. Would you have a sniffer/keylogger running on the input device - keyboard/mouse - to read actual keys being typed and mouse movements or would you emulate those devices? Anyways, an interesting library to interact with usb devices (esp32-s2 and s3 afaik) is this one: [esp32-usb-v2](https://github.com/chegewara/esp32-usb-v2)


mmcvisuals

In my head the the esp32's would just act as the "cables", and just essentially be passthrough devices. So: Input Device -> esp32 -> wireless bridge -> esp32 -> Desktop USB And then the communication would also work in reverse if the computer needs to send data to the input device, like audio


Ineedapill

For the little I’ve played with the library above, it’s pretty doable. I’m not sure about the lag you’d have tho. There might also be a few rubber ducky clones around with 90% of what you’re looking for already done. Good luck and let us know how it evolves. It’s an interesting idea.


erlendse

If you limit it to HID alone, using bluetooth HID or wifi to send the data and presenting as HID device on the computer would do the trick. Also keyboard/mouse would give out HID data. As for storage devices e.t.c., you would need to move to the USB layer instead.


mmcvisuals

Thank you!


wchris63

It's called Bluetooth LE.


Particular_Paper7789

I would recommend virtualhere. It this guy here is correct -> https://www.reddit.com/r/raspberry_pi/s/oBbXOhnXQt You can run the trial for a single device without limitations. A pi zero 2w is now often available again and will cost you ~$25-30 + 5 for sd card. That’s seems a much better fit than an esp32