Undetectable USB Mouse Jiggler to Prevent Screensaver

Goal: Prevent the screensaver activation temporarily without modifying the system settings by jiggling the mouse periodically with an inexpensive USB hardware mouse jiggler.
Mouse jiggler from an ATtiny85 Digistump
Mouse jiggler from an ATtiny85 Digistump

During the day I’d like to see Slack messages and real-time updates on various platforms, but in the evening I’d like the screensaver to run as intended. If I edit the system settings twice a day then I’m bound to forget one state or another.

A sample of what’s available on Amazon for USB mouse jigglers is below.

Mouse Jiggle search results on Amazon
Mouse Jiggle search results on Amazon

For USD $2 you can have the same thing with minimal effort, and you can highly customize it.

Hardware – ATtiny85 Digistump

Purchase a very simple ATtiny85 Digistump from Adafruit or AliExpress.

ATtiny85 Digistumps are readily available
ATtiny85 Digistumps are readily available

Here I’ve just ordered one and it came in a mylar anti-static bag.

New ATtiny85 Digistump
New ATtiny85 Digistump

Programmer – Arduino IDE

Install Arduino 1.8.5, not any of the newer versions as they have known connectivity bugs.

Add the Digistump boards like so using //digistump.com/package_digistump_index.json in the board managers URL.

Arduino ATtiny85 Digistump boards manager
Arduino ATtiny85 Digistump boards manager

Install the AVR boards.

Install the Arduino IDE Digistump AVR boards
Install the Arduino IDE Digistump AVR boards

Select the Digispark board and programmer as shown below.

Select the Digispark board and programmer
Select the Digispark board and programmer

Software – Arduino Sketch for Digistump

Here is a very simple sketch to jiggle the mouse ever thirty seconds:

Here is the same sketch except during jiggle the on-board LED will blink.

Use DigiMouse.delay() and not just delay or else the USB device will fail and Windows will display the “device malfunctioned” message. If you use an Arduino board like the Arduino Leonard, then you can use the native Mouse.h and normal delays.

Click the upload icon and wait for the message to plug in the Digispark. When plugged in, within a few seconds the sketch will upload. The device will be detected as a DigiKey USB device.

Mouse jiggler sketch for Arduino IDE
Mouse jiggler sketch for Arduino IDE

Advanced

If you prefer the USB mouse jiggler to look like a real mouse to most computers, then you can edit the usbconfig.h deep in the Digistump hardware folder. You do not need to recompile the bootloader.

Digispark mouse usbconfig.h location
Digispark mouse usbconfig.h location

Edit the following file in Windows,

and find the following section:

By visiting devicehunt.com you can find the vendor ID and device ID of any USB you want the Digistump to masquerade as. The relevant constants are USB_CFG_VENDOR_ID and USB_CFG_DEVICE_ID.

Tip: Remember to reverse the values you find. For example, if the vendor ID is 12EF, then set the constant to #define USB_CFG_VENDOR_ID 0xef, 0x12.

For example, the ATtiny85 is detected as a Dell mouse in the screenshot below.

Dell mouse emulation
Dell mouse emulation

Results

ATtiny85 Digistump mouse jiggler
ATtiny85 Digistump mouse jiggler

Here we were able to acquire an inexpensive USB AVR board (ATtiny85), install Arduino IDE to Windows, add some AVR board drivers, write a very simple mouse jiggler script, modify the USB “manufacturer”, and upload the code to the ATtiny85 Digistump. Every thirty seconds the mouse will jiggle. This can be extended to any Arduino board (e.g. Arduino Leonard), though this is by far the most cost-effective.

Success: For less than USD $2 and only 15 minutes of effort we now have a USB mouse jiggler to keep the screensaver off while plugged in.

References and Inspiration