[HID Keyboard on Photon] Waking a connected device

Hello World!
(BTW, this is my first post)
I have been experimenting with a system that uses the photon’s HID keyboard to wake a computer (Windows 10 Pro 64x). I have tried initialising the keyboard with STARTUP(Keyboard.begin()); and creating a function that presses a key (and lights the onboard led for debugging) when an event is published or a function is called via IFTTT. Around the web, people seem to say that for a keypress from a HID keyboard to wake a computer, you must use the “power management” tab of the device inside the Device Manager. My computer’s regular keyboard has this tab, but my photon does not have it. I think that this tab/setting is at the root of my problem. I have also tried pressing the power key through the photon (0x66 inside this table, shown as KEY_POWER). Please let me know how I can change the power management settings of the HID keyboard or circumvent this issue.

Benjamin :grinning:

Any ideas?

Hi @Yellowjaguar5,

Hmm, it sounds like you probably need to offer slightly different HID/USB settings to the computer when registering as an input device. Can you share your code, and we can try to lookup what the right flag might be?



Hello @Dave,
Thanks for your response. I’ve put this project on the back-burner for awhile and I haven’t tested this code recently, but it is below. My main problem, as outlined above, seems to be that my Photon does not have the "power management"tab inside the device manager. Please let me know what you think.


int wakeUp(String r) {
Keyboard.press(0x66); //Power button
Particle.publish("Awoken.", r, 60, PRIVATE); 

void setup() {
Particle.function("wakeUp", wakeUp);

void loop() {

Awesome, thanks!

So here’s the source file in firmware that tells the operating system what kind of HID device it is:

I found this thread that also talks about this problem:


It sounds like maybe we want to add some system control or other descriptors to the USB HID device to make this functionality possible? I think @avtolstoy knows way more about this functionality, any thoughts?



Just enabling Sleep/Wakeup controls in HID descriptor will allow us to wake up PC only from certain states (see https://msdn.microsoft.com/en-us/library/windows/desktop/aa373229(v=vs.85).aspx for a list of power states).

Apart from that we also need to enable “Remote Wakeup” feature in USB configuration descriptor, handle SUSPEND requests from the host and when suspended, correctly perform Remote Wakeup sequence:

It is a nice feature to have, but looks a bit more involved than just editing some USB descriptor :slight_smile: I have created an issue on github and put it on my backlog: https://github.com/spark/firmware/issues/1293


@avtolstoy just to clarify the USB Device suspend is separate from the host machines power states. the USB Device Suspend state is specifically for the USB host controller. The USB host controller also needs to support suspending USB devices. Most host controllers don’t have usb suspend enabled. Computers are able to enter S3 sleep with an external keyboard/mouse attached and kb/mouses typically don’t enter a USB Suspend.

@Yellowjaguar5 What this means is that It should work by changing the device descriptor and that the photon should be able to wake up a host machine from an S3 Sleep state.