1

I want to wake up a PC via a USB-connected Arduino. When using a Pro Micro (Leonardo) I can do it, as its HID interface can wake up a PC. That is, in the Device Manager, under "Keyboards", the relevant HID device under "Power Management" has an "Allow this device to wake-up the PC" checkbox.

enter image description here

However, I need to use an Uno for this project. There's a hack (see link below) which flashes the ATMega16U2 on an Uno to act as a HID keyboard. It works fine, but this HID keyboard on a flashed Uno does NOT have the "Allow this device to wake up the PC" checkbox, i.e. I can't wake up my PC. I tried, the PC doesn't wake up. I know I can use an Ethernet shield on an Arduino to send a Wake up on LAN packet, but I don't want to add any shields, if I don't have to. Any advice how to do this?

EDIT: I was pointed to 2 libraries, NicoHood and LUFA (links below) to code a HID keyboard for the ATMega16U2 on an Arduino Uno. The problem is that acquainting myself with the subject and (either) library, would take several days, which is why I'd prefer to find an already-compiled simple HID device that does what I want. If I can't find one, I have a "dumb" solution: since the Leonardo can wake up a PC, I can hook it up to the PC, power the Uno (with my code) off the Leonardo, link one digital pin between the Uno and the Leonardo, so that the Uno can trigger a USB keystroke on the Leonardo. This is kludgy, since it uses the Leonardo just to send one USB keystroke to wake up the PC, but it would work.

LUFA

NicoHook Keyboard API

HoodLoader

Relevant links:

Arduino Uno as a USB HID Interface

Wake a touchscreen using a Pro Micro

6
  • I don't think it's that simple. I think the device driver has to have the wake-up ability coded in, i.e. be able to send out the relevant message
    – MrSparkly
    Commented Aug 7, 2018 at 20:56
  • 2
    The HID library by NicoHood uses a special bootloader in the 16U2, github.com/NicoHood/HID It can send media keys and the power key.
    – Jot
    Commented Aug 7, 2018 at 22:14
  • Thanks. I'll try to get in touch with the author, as I'm not sure what the minimal required setup would be.
    – MrSparkly
    Commented Aug 7, 2018 at 23:30
  • Try a different USB port.
    – Gerben
    Commented Aug 8, 2018 at 9:42
  • Can you explain the reason why you need to use UNO?
    – MichaelT
    Commented Aug 8, 2018 at 22:35

2 Answers 2

1

Got it working: my Uno can now wake up a PC. I followed the HoodLoader wiki and I used the HID-Bridge sketches (below). It took about 2-3 hrs.

HoodLoader

HID-Bridge

0

I spent way too much time trying to get this to work with arduino ide. None of the OS settings seemed to work. I then tried using Adafruit's circuitpython. I assume the circuitpython HID library includes the right juju to let the mouse movement wake the pc. Changing nothing in OS ( windows and ubuntu) it worked.

You will need to add the adafruit_hid library to your CIRCUITPY usb library folder.

The code is then pretty trivial - pir connected to 3v power and sensor pin to D10.

# move the mouse when pir detects motion 
# blink led and move mouse
#this wakes my pc when i enter the room
#may want to sleep a bit after waking it so mouse is not constantly moving...  

import time
import board
import usb_hid
 
from digitalio import DigitalInOut, Direction
from adafruit_hid.mouse import Mouse

led = DigitalInOut(board.LED_INVERTED) 
led.direction = Direction.OUTPUT
sensor_pin = DigitalInOut(board.D10)
sensor_pin.direction = Direction.INPUT
mouse = Mouse(usb_hid.devices)

while True:

    led.value = False
    time.sleep(0.5)

    if sensor_pin.value is True:
        mouse.move(x=10,y=10)
        led.value = True
        time.sleep(0.5)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.