I would like to wake up my desktop computer (Mac or PC) from sleeping using a Raspberry Pi Zero.

Is it possible to get the Zero to wake a computer over a USB connection? I can wake my Mac up using the mouse or keyboard so it seems possible that if I could configure it to send the same signals then I could.

I have read that one can turn the Pi into a 'USB gadget' - this may be the right approach or unnecessary.

  • 1
    \$\begingroup\$ You can wake up on USB events, but that's a PC/software level task. Not a hardware level task. You may get better response on Software or SuperUser stack exchanges. \$\endgroup\$
    – Puffafish
    Aug 30, 2019 at 9:10

2 Answers 2


Bit of background first:

Generally, USB itself is not a bus over which a device can be really woken up if it stopped working completely, because it's a host-polling based bus, i.e. the host PC must inquire the keyboard in regular intervals. If that host is completely shut down, nothing one can do.

However, being a host for a USB keyboard is relatively easy, and since host firmwares need to emulate PS/2 (or Apple desktop bus keyboards) for compatibility reasons, anyway, that was a feature easy to implement: simply let the firmware take over the USB bus, and ask all the attached Human Interface Devices (HIDs) whether they got input every couple milliseconds.

So, all you'd need to do is implement a HID gadget profile on your Pi.

Yes, that works, and it's about the easiest profile to implement.

Whether that is a sensible approach is a different question alltogether: The Raspberry Pi, when it comes to ARM SoC computers, is a relatively power-hungry device, so that it is actually worth the question whether running a Pi 24/7 to wake up a computer is worth it – if that computer is attached to a router via ethernet, for example, that could use magic Wake on LAN packets instead.

  • \$\begingroup\$ Thanks very much for this reply, very informative. The reason i chose the pi is because i am running on a computer in an office so i am unable to set up port forwarding on the router (no access). i suppose thinking about it i could use an arduino leonardo (ATmega32u4 ) to cut down on power usage, althoug that would need a wifi shield... \$\endgroup\$ Aug 30, 2019 at 9:52
  • \$\begingroup\$ I'm really not convinced you're actually saving a lot of energy by powering a pi 24/7 instead of e.g. sending your PC to sleep, letting it wake up every 10 mins, check for a request to stay awake at some URL, and then go back to sleep. But again, not quite sure what you're trying to solve here! \$\endgroup\$ Aug 30, 2019 at 10:05
  • \$\begingroup\$ what i want to do is to be able to login to my work computer from home using a remote desktop software. i can accomplish this fine if the computer is awake but cant if its not. i dont want to leave it on all the time and the method i proposed was just one which came to mind. having the computer wake and check every now and again seems like a decent enough idea although not something i currently know how to do. raspberry pi's dont really use that much power do they? \$\endgroup\$ Aug 30, 2019 at 11:07
  • 1
    \$\begingroup\$ in low-workload usage some 1 to 2 W; you'd need to multiply that with 1.25 to account for the 80% efficiency of a power supply. Different thing, though: is your employer OK with you adding an externally controllable device that only you know which software runs on it 24/7 to your company network? \$\endgroup\$ Aug 30, 2019 at 13:49
  • 1
    \$\begingroup\$ yeah its pretty darn low, self employed so nothing to worry about there. \$\endgroup\$ Aug 30, 2019 at 14:19

Technically yes, it is possible to get the Zero to wake a computer over a USB connection. However, you need to have the Pi-Zero version 1.3, because earlier versions didn't have ID pin connection and didn't have reversible VBUS hardware, although there are hacks that can reverse the USB port in older models.

To get the Zero to wake up a computer, you need to implement the USB HID device class with remote wake-up capability (which includes the remote wake-up itself and correct description of this function in device descriptor). Your host computer should be able to recognize this, and must be configured (in Device Manager) to "allow this device to wake the computer". This option enables the host to send a special USB transaction that arms HID devices for wake-up action before your desktop enters "sleep" state.

You also need to make sure that your desktop computer goes into "S3 Suspend to RAM" state and not lower than that. In lower Sx states the USB VBUS power will be turned OFF, and USB devices won't be able to generate the wake-up event.


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.