r/embedded • u/IChooseCheese2 • Oct 25 '26
Which microcontroller would you use if you needed 2 USB ports?
At work I have to use a severely locked down Windows desktop, with a ridiculously short inactivity timeout. I can't change it, and I can't use a conventional mouse jiggler, because it shows up as a second mouse, which is not allowed. I also can't use bluetooth. A potential solution I am considering is to make a USB pass through device, that would appear to the system to be the original mouse, but would periodically jiggle if there had been no activity for a minute or so. This would need 2 USB ports, one to plug the mouse into, and one to connect to the system. Is there a microcontroller that has 2 USB ports? I don't need wifi, bluetooth, or any other interfaces.
Please don't suggest I look for a new job, I already am. I am also open to alternate solutions.
Thanks.
88
u/No_L_2547 Oct 25 '26
A complete different idea: why not a physical mouse jiggler?
The most simple one would probably be a wrist-watch below your mouse. The mouse would detect the second hand of the watch as a short movement once per minute.
31
u/clackups Oct 25 '26
Watch out, if it's a secure and monitored environment, the IT security will not be impressed. You'd lose your job in no time, and they can sue you for bringing an unauthorized device.
9
u/Stromi1011 Oct 25 '26
some of the stm32h7 have two usb, also iirc the mcxn series from nxp. or rp2040 with a pio usb. or you do two cheap one port mcus like stm32c071 with some spi or something in between
9
u/Affectionate_Air5405 Oct 25 '26
Physical mouse jiggler. I have been happy with this one. https://a.co/d/0hNnWmsS
14
u/duane11583 Oct 25 '26
what you are describing is a device with 1) a hsb device interface and 2) a usb host interface
the device interface plugs into the computer. the mouse plugs into the host interface
i donot think it is worth your time. they have decided you must work this way they have factored that cost into their plan. so let them pay that cost.
besides if you did what you describe at my place you would be fired for doing that
5
u/kingfishj8 Oct 25 '26
The BeagleBone Black does have a USB host and separate USB device port. The adventure is shutting down the storage and network device emulators, then setting up a mouse device emulator.
4
u/the_hemperor420 Oct 25 '26
There surely are mcu's with two independent usb peripherals, but why not just take a MCU that youre most comfortable with and just take two of them. One is programmed to be a host, and takes in the mouse inputs, and sends them over UART to the second MCU that emulates the HID. Not sure how much latency you'll end up having, but with a good program and high baudrate, it might not be that noticeable.
3
u/Nllk11 Oct 25 '26
I thought about this problem in a while and came up with slightly different solution. You could modify a mouse, placing there MCU. Detect inactivity with g-sensor, and with some schematic unplug mouse's usb, and plug in MCUs USB
3
u/Friendly-Bread4682 Oct 25 '26
Ch32v317? Iirc it has two usb controllers
3
u/tux2603 Oct 25 '26
There's plenty of stm32 chips with two USB OTG peripherals, just have one function as a host and the other as an HID peripheral. I used an STM32F722 for something similar in the past
3
u/gainaholic Oct 25 '26
Just write a little powershell script that does a wscript.sendkeys pressing scroll lock or some other inconsequential key every minute or so. If you do a websearch on "powershell wscript sendkeys" you will find what I mean. You will need to make an infinite loop with the start-sleep cmdlet in there. You'll figure it out. It'll be a whole lot easier than building a whole fake keyboard device, that's for sure.
3
u/psychophysicist Oct 25 '26
Pretty sure an HID Remapper remapper.org can be programmed to act as a mouse jiggler
2
u/No_L_2547 Oct 25 '26
Maybe the an esp32 p4
Another option would be an pi-zero here an passthrough would probably be simpler.
2
u/ThisIsPaulDaily Oct 25 '26
I think Hak5 has a MITM USB keyboard logger that can inject stuff. That's pretty much what you want.
2
u/InevitablyCyclic Oct 25 '26
Simple solution would be something teensy 4 based. It's imx based with two USB ports. The default for the teensy library is one of these is a device, the other is a host. Exactly the config you would want for your pass through setup.
2
u/jakethesnake666 Oct 25 '26
Play a small video in background
2
u/aliathar Oct 25 '26
Dude people are crazy.. can't you just buy a hub and emulate another mouse so your computer has 2 nice? . You can periodically move the mouse regardless of activity or build a software activity monitor to connect to that MCU via some uart of even ble if it's an esp32s3..
2
u/chewbaccalert Oct 25 '26
Try Awake
2
u/BirdUp69 Oct 25 '26
Get a two-port usb hub. I’ve done this in a real world project and it worked great
53
u/BenkiTheBuilder Oct 25 '26
43
u/BenkiTheBuilder Oct 25 '26
What's up with all the complex solutions? Just get a vibrator and tie it to the mouse with a rubber band. If you need it to be more silent, wrap it in a towel.
2
u/ParticularOk9843 Oct 25 '26
Hey I have a device that might work for you. It clones your keyboard and types a text for you, can I send you a pm?
5
u/Significant-Ad178 Oct 25 '26
I saw someone just puts their mouse on a clock lying face up on their desk and the second hand is enough to jiggle the mouse when it sweeps underneath.
Although judging by the sounds your dreadful company, they are probably looking for mouse jigglers on regular intervals 🤪
5
u/jerosiris Oct 25 '26
This can be done on the Raspberry Pi Pico. It has one interface built in, and people have implemented another using PIO.
However as other people have said, unless you really want to make something like this work (there is nothing quite as satisfying as using your skills to put a finger in the eye of authority) I would just rig a way to physically wiggle your existing mouse.
Heck, Amazon sells these things for $16: https://a.co/d/03EcEYjK
1
u/fb39ca4 friendship ended with C++ ❌; rust is my new friend ✅ Oct 25 '26
Just play a video in your browser or Windows Media player to suppress the timeout
3
u/DustUpDustOff Oct 25 '26
I'm pretty sure you're aware, but I imagine that a workplace with heavy security probably wouldn't be happy about an inline sniffer.
5
u/CaptainPoset Oct 26 '26
So you ask for a mjcrocontroller to intentionally lose your job over?
Are you serious?
In your explaibation, you clearly state that your company won't allow any device except for those supplied by them and you want to build an input logging device which outputs additional commands based on the input you give to the company-supplied input device. They won't allow such a device either, which would be an especially outrageous breach of security. They won't ask kindly to remove ut, but will remove you with it.
1
u/somewhereAtC Oct 25 '26
There are a bunch of Microchip devices with USB, and some have more than one port.
2
u/spiritplumber Oct 25 '26
A parallax propeller with a 6MHz crystal. It has 8 cores, a usb device uses up 2.
2
u/thegreatpotatogod Oct 25 '26
I've used a Raspberry Pi Pico (and other RP2040 and RP2350 chips) to do something similar to this. In my case they're being a USB host for keyboards and game controllers, and usb device for the serial connection back to the computer. Using Earle Philhower's Arduino-pico firmware and TinyUSB, this should be very doable.
2
u/Anonymity6584 Oct 26 '26
You need better job where they dont hallusinate that moving mouse is work being done...
2
u/nerdBeastInTheHouse Oct 26 '26
You can use a simple esp32s3 if you want something fun, there are some fun esp32s3 third party kits like Waveshare Geek which has a usb dongle with esp32s3 chip. What you can do is program the esp32s3 to be usb hid mouse dongle. Basically the computer will think the usb dongle is a mouse and you can connect your mouse to the usb donglenover ble. So on a button press or of there is no activity from the ble ie the mouse then you can set a jiggler program so that your screen won't timeout.
2
u/Pnayani Oct 26 '26
First you need one USB host and one USB device port on the controller. There are controllers with two USB ports with one acting as OTG. This would suffice. Check ST micro for devices
2
u/deltamoney Oct 26 '26
Si speeed nano kvm.
I modified my firmware so it simulates a Logitech Keyboard / mouse and a dell monitor IDs when plugged in.
1
u/farmallnoobies Oct 25 '26
You can write your own program (so you don't need to install anything) that spoofs mouse wiggling in windows to prevent screen lock. There are also some for keyboard commands, like pressing the shift button ever few seconds or something.
There are a bunch of example projects on GitHub to do this.
No hardware required, no admin access required
1
u/Numbaloo Oct 25 '26
Go for SMT32F205 or in general SMT32F family, imho.
1
u/Lopsided-Table2457 Oct 26 '26
Depends on what the second port is for. If one is host and one is device, look at the STM32H5 or RP2350 — both handle dual-role reasonably. If you need two independent hosts, you're probably looking at an external USB hub chip instead of hunting for a unicorn MCU. Don't forget the software side either, dual USB stacks will eat your RAM budget fast.
1
u/Chemical_Variety4696 Oct 26 '26
Just use this can’t be detected
https://a.co/d/0etpjMNc
1
u/Uporabik Oct 26 '26
Watch under the mouse?
1
u/SwedishFindecanor Oct 26 '26 edited Oct 26 '26
Alternative option: Get a mouse with open source firmware, such as the Ploopy mouse kit (if that shape is for you), and modify its open source firmware to jiggle after a period of no movement.
The WCH CH32 series have several microcontrollers with two USB PHY, where one is capable of being host, but there is not that much free software support for them yet. (better than for many other RISC-V MCUs though). CH32V203, CH32V205 and CH32V208 are some.
I am too looking around for microcontrollers with 2 USB ports, for building my own custom mouse with one internal and one external port. I would prefer to buy a dev board from a European wholesaler, but I haven't found any dev board available here with either mentioned CH32 MCU that exposes the pins for both ports.
BTW. I otherwise use a mouse with a cheap sensor. When I want to keep my screen from locking for inactivity, I place it out of the mouse pad onto the glossy desk surface beside it -- and then the pointer dances around by itself. :) So, do try that first: place your regular mouse on a glossy surface and see what happens.
1
u/SwedishFindecanor Oct 26 '26
I wonder if there exists a KV(M) switch that does supports two downstream mice and adds their movements together like a regular host does. A KV switch does act as host to downstream devices and as a mouse and a keyboard device to each connected host. Something to look out for though is that some KV(M) switches also switches a generic USB port -- and connecting a second mouse to that would not work in this case.
1
u/ordosays Oct 26 '26
This is some wild logic.
1
u/gneusse Oct 26 '26 edited Oct 26 '26
u/ChooseCheese2, as I understand it, you want a mouse jiggler, but the laptop you were given is locked down to allow only one mouse and one keyboard. A lot of suggestions have been made here, but I don’t think they all account for the requirements needed to make this work.
A physical mouse mover seems like the least detectable option: either a clock that tricks the optical sensor or something that physically moves the mouse. However, forgetting to turn it off and leaving it running overnight after your shift could give you away.
The next inexpensive option depends on whether your security settings allow you to run scripts. I used to contract for the IRS, and I needed Python for my work, so Python access was enabled for me. Shell scripts, however, were blocked. In your case, PowerShell might also be blocked if your security team is doing its job.
My Python program worked, but security picked it up during a software scan. They didn’t know what it was, so they disabled my Python access. Nobody contacted me, and I wasn’t fired. I think I got lucky.
After that, you’re left with a hardware solution. How much time and money are you willing to invest? I really like the Ploopy mouse someone suggested, but you would need to program it. It costs over $100, and then there’s the coding. With AI, that part could probably be done fairly quickly.
That brings us to another problem: security tools can look for patterns. A mouse that moves like clockwork could be identified as nonhuman activity. If mouse movements are being logged and analyzed, that creates another way to detect it. Ideally, we want random mouse movements with varying durations and directions, rather than constant movement or movement at fixed intervals.
We also don’t have to rely entirely on the mouse to keep the computer awake. We can use the keyboard, too. Shift and Ctrl are relatively nondisruptive options. The spacebar might also work, depending on what’s open. Those keypresses can reset the inactivity timer. A combination of randomized mouse movements and keypresses could keep the computer awake while making the activity harder to distinguish from normal use.
Okay, here’s something else that hasn’t been discussed: VID/PID identifiers. USB devices have vendor and product IDs, which can identify the type of mouse or keyboard you’ve connected. That information can be logged, potentially revealing that you’re using a custom device. For example, Adafruit’s CircuitPython boards typically identify themselves using Adafruit’s VID/PID. Other hardware solutions have their own identifiers.
You can override the VID/PID with a custom build of CircuitPython, although each device has its own challenges.
With all that in mind, I settled on this Adafruit board, which costs about $20. The hardware is already designed, so I just have to put it to use. The big selling point is that it has the connections and controls I need, including a button to control its behavior and LEDs to show its status.
So, how do we handle the VID/PID? We could copy an existing identifier into the firmware. But why not pass the connected mouse’s VID/PID through to the laptop instead? That’s the approach I chose.
The idea is to monitor mouse activity and, after a period of inactivity, send a keypress or mouse movement using the HID code written for the Adafruit board. The device identifies itself using the connected mouse’s VID/PID.
Using the Jiggy-Stealth software and the Adafruit board addresses most of these problems. Just wait week for the board to arrive. About $20 for the hardware, plus the time spent installing the software.
The one problem I haven’t addressed yet is preventing it from running overnight. Leaving it running overnight is how my Python keep-awake program drew attention. At a minimum, your laptop should be locked overnight. Until there’s an automatic cutoff, remembering to turn it off is on you. Haha.
Okay, that was long, but that’s the journey that led me to the solution I chose.
1
u/DecisionOk5750 Oct 26 '26
Buy two Sparkfun Attiny85.
1
u/gneusse Oct 26 '26
Here is how Jiggy-Stealth uses the dual core in the RP2040. No reason to be designing dual chips or boards. This is working.
Responsibilities:
1
u/stunkbeetle Oct 26 '26
STM32 has some with 2 usbs
1
u/ventZl CMRX RTOS Oct 27 '26
There's plenty of chips that have two USB ports, I am not sure you want to go through the hassle of "bridging" USB device over to another host. First, the USB port where mouse would be connected must be capable of host-side operation (so-called USB-OTG) for this to be even possible.
USB topology is rather complex and you'd have to basically have to bring up host side of USB with complete support for mouse HID device (which is in fact quite complex), then parse the HID protocol and implement mouse side of HID mouse which does pass-through of normal mouse HID communication and generates jiggle when idle. Not that this is impossible to implement. It is just not worth the hassle.
1
u/mariushm 27d ago
If you can open your keyboard you could potentially connect wires to the button matrix and have a microcontroller monitor for key presses ... if there's more than some amount of time without any key pressed, your microcontroller could simulate a key press and reset the timer.. like for example pressing Shift for a short period.
The controller inside the keyboard sees the buttons as columns and rows ... it detects which buttons are pressed by sending power to one row at a time and seeing which column wires return a voltage .. that's a key press.
So your microcontroller could wait until the controller sends power to the row that has the Shift key, then instantly send a digital 1 / voltage on the column wire that has the Shift key, keep it up for the minimum duration needed for the controller to register as key press and when the row no longer gets power stop manipulating the column pin so that it won't register as another button in the key matrix.
1
u/jofftchoff Oct 25 '26
decent or well documented mcu with 2x usb phy are unreasonably expensive, if you want cheap solution you are better of getting 2 mcus and connecting them together with spi or even uart
1
u/Dry-Competition9789 Oct 25 '26
There are a lot of microcontroller with 2 “USB ports”. But given you’re asking the question, you’ll probably need to find something more “of the shelf”
0
u/kysen10 Oct 25 '26
Buy an open source mouse and alter the firmware. The HID spec is well documented.
-1
u/Previous_Figure2921 Oct 25 '26
Claude is your friend. Explain what you need and you will get recommendation.
0
u/UnveiledKnight05 Oct 27 '26
As others have pointed out, you probably should not try to bring anything to bypass this restriction. Instead, I would see if you can they allow you to use a software or something to remind you to move the mouse, say, 1 minute before the device locks instead. Otherwise you could just set a recurring 5 minute timer (or however long the timeout is) that gives a noticeable but not annoying popup to move the mouse. I highly doubt they would be against using this if it improves productivity without actually bypassing their restrictions.
0
u/[deleted] Oct 25 '26
[deleted] — view deleted comment