ESP32-S2 playing with the mouse

Last Updated on 12 June 2023 by Suffocation

A friend was complaining to me the other day. He's now working from home and fears his employer is tracking his computer data. Since the computer switches to standby mode after a few minutes, he came up with the idea of repeatedly moving the mouse to prevent this. His wireless mouse even reaches the toilet, he told me, and he expressed his gratitude to manufacturers of such mice.

Now the acquaintance is not only a good one, but also a civil servant, and as is well known, they need their midday nap. Tying the mouse to the cat (does anyone see the irony) or letting it run along on a record player isn't quite perfect.

As I was putting the children to bed in the evening, my thoughts wandered in this direction. It occurred to me ESP32-S2 to memory, which has the capability to emulate a HID (Human Interface Device), i.e. a mouse or keyboard.

Thus, a new project was born – to emulate a mouse that would then intervene when you were inactive. Of course, software emulation on the computer would also be conceivable, but most company computers are secured against the installation of external software.

Facts

  • Simply plug the FAKE mouse into the USB port.
  • Mouse activates after 3 minutes of inactivity. It wasn't possible, no feedback from the computer
  • The mouse stops as soon as the user does something again. Same reason as above
  • The mouse movements should be random in pace and time intervals.

Selected Hardware

LILYGO EP32 S2 V1.1

Alternatives

LILYGO T8 ESP32-S2 Display V1.1

Areas of application

  • Funny mouse movements on the screen
  • Liberation from the yoke of employers.
  • The lives of civil servants (An apology to civil servants who have to work hard for their money)

Views

Photos are available at LILYGO EP32 S2 V1.1.

Programming

Libraries

The two required libraries, USB.h and USBHIDMouse.h, are included in the ESP32 library from version 2.0 onwards.

Test programme

ESP32-S2 – Choose a controller

Demos are available in the example projects below.

ESP32-S2 – Beispielprogramme

I used the MouseButtonControl example as a basis for my endeavours and created my own:

Install the firmware and set the DIP switches to HID mode (OTG).

Lilygo ESP32-S2 - Switch to OTG.

Problems

The mouse is not keeping the computer alive.

Possibly the time between movements is too short, so the computer still goes into standby mode.

Simply increase the value for the delay. Feel free to set it to 2000 as well, then you'll see the mouse jump.

Miscellaneous

Track Own Mouse Movements

Stefan (see comments) suggests integrating the circuitry into the mouse. On the one hand, mouse movements could then be tracked, and on the other hand, with clever wiring, OTG capability would not even be necessary.

Alternatively, a USB port that's passed through might be an option, an Arduino clone with a Host Shield. The original mouse connected to the Host Shield and the mouse data simply forwarded to the computer. If the mouse pauses, the Arduino clone takes over.

Conclusion

The programme was quickly written and works, I will hand it over for user testing in the coming days.

Related Posts

Sources

https://github.com/espressif/arduino-esp32 (Library for looking up USB and Mouse libraries)

https://ericdraken.com/usb-mouse-jiggler/ He has done a similar project with a different board.

https://github.com/seife/marble_fx

https://github.com/seife/marble_fx_digistump

6 thoughts on “ESP32-S2 das Spiel mit der Mouse

  1. Indeed, I use a mouse jiggler, though one based on an Arduino micro. While I understand the locking of the screen after a short period in the office to prevent unauthorised access to confidential data when one is away from their desk, it is rather annoying to have to log back in after practically every longer phone call, other conversation, visit to the coffee machine, the toilet, etc.
    This makes sense for data security in the office – but surely not for a single person working from home.
    The idea of only operating the mouse jiggler when needed doesn't sound bad. How about operating the mouse or keyboard with a PS/2 connector on the controller, and converting that to USB or BT HID? There are already projects for that. If there's no input for 2 minutes, then the mouse jiggler could step in, and any real movement would deactivate it again until the next timeout...

  2. I was hoping to find a hint here for using the ESP32-C3 as a HID, unfortunately, it just seemed like clickbait (that would fit someone helping an employee shirk their duties) as the article only mentions the S3, with which HID is no problem.
    It would be nice if the title were corrected

    1. Heading is corrected. However, I was still very annoyed about the clickbait accusation, do you perhaps tend to make snap judgments? Courteous interaction is different!

  3. I do find it more than a little concerning to have such employees, but the HR department also knows all the tricks, don't worry. You can find such devices on every corner since remote working became a thing. They're called mouse jigglers. https://amzn.to/3UiKn70 Simple, effective, affordable.

  4. Hello Stefan,
    Thank you for your comment, indeed a Tiny is sufficient for that. To test the OTG function of the ESP is a nice toy, and for him who only has a hammer, the whole world is a nail ;).
    As a cheap example, I also referred to the Tiny in the sources:
    https://ericdraken.com/usb-mouse-jiggler/
    I have now also included your links in the sources.

    I've also ordered a few of the Tiny boards and wanted to test this again with an Atmel and cheaper.
    https://de.aliexpress.com/item/32409396629.html?gatewayAdapt=glo2deu&spm=a2g0o.order_list.0.0.21ef5c5fL9oQ38

    I like the idea with the mouse, I've added it under miscellaneous.

    Hello
    Stefan

  5. For this, an ESP32-S2 is complete overkill. An Arduino Leonardo clone (e.g. „CJMCU Beetle“ for a very suitable form factor) or even a Digispark (ATTiny85) would suffice.

    The best thing would be to build that into the mouse, so that after you've finished using the mouse, it keeps jiggling for another 30 minutes, and then stops if the official happens to oversleep whilst having their lunch nap… 😉 Example: https://github.com/seife/marble_fx and https://github.com/seife/marble_fx_digistump

    BTW: The title mentions ESP32-C3, but the text ESP32-S2..?

Leave a Reply

Your email address will not be published. Required fields are marked *