4

I have an Arduino Pro Micro mimicking as a HID, connected to a PC.

The PC BIOS is configured to wake from keyboard events - it is switched on by hitting a key on the regular keyboard. This is a wanted feature and should stay.

Unfortunately, it also wakes when the Arduino sends HID events, which is understandable and pretty obvious, but to be avoided.

Is there something in the USB protocoll, or even in the Arduino HID libraries, that lets me tell the chip to either not wake up the host (unlikely, I guess); or so that I can detect when the PC has shut down, so I can tell the Arduino to go sleeping as well until the PC wakes up again?

EDIT: I am using the "HID-project" USB library (HID 2.4.3) from https://github.com/NicoHood/HID.

AnoE
  • 141
  • 2
  • You should be able to detect if the host is sleeping. Which USB library are you using? – Gerben Jun 07 '17 at 20:41
  • @Gerben, I use the library at https://github.com/NicoHood/HID . – AnoE Jun 07 '17 at 20:49
  • you can simply disable the "wake on keyboard" feature of your pc, if that helps – dandavis Jun 08 '17 at 06:27
  • No, @dandavis, I would like just this one device to "behave". – AnoE Jun 08 '17 at 06:50
  • maybe there is a key or two that doesn't wake up the pc. i always used pause to wake, but one laptop i had ignored that and a few other keys. it might also be possible to interrogate the locks without toggling, which hopefully wouldn't wake the PC. i think it's possible because i thought i've plugged in a keyboard to a sleeping PC, had the caps lock light come on, but still had to press space to actually wake up the PC... Also, i wonder if those lock interrogations would time out were the PC sleeping; a way to detect sleep. – dandavis Jun 08 '17 at 06:57
  • There are many doubtful points in here. Your PC is powering USB ports when sleep or completely shut down? And why you send HID events with your Arduino if you don't want to do? – user30878 Feb 14 '18 at 07:43
  • @user30878, it's nothing mysterious. PCs powering USB ports when off is pretty standard (else, "wake on USB" would be hard to implement); and my device must send HID events (it is a HID device). This questions asks about selectively avoiding the "wake on USB/HID" functionality for a single device by either telling the PC so (which is likely impossible as we are talking about BIOS/close to hardware-level functionality), or having the device detect when the PC is sleeping (more hopeful, but nobody came forth with a suggestion, and I didn't find anything about it anywhere else). – AnoE Feb 14 '18 at 09:56
  • Ok but do you need send HID events always (continuously)? – user30878 Feb 14 '18 at 10:05
  • Unfortunately, yes. The device sends HID events when some analog input changes; this can happen if someone bumps against the table or something like that. – AnoE Feb 14 '18 at 10:19
  • We need to know your exact aim. You can send sleep command to your pro mini with PC just before sleeping. You want to don't wake up the PC from hid but your hid device is always active. It's meaningless – user30878 Feb 16 '18 at 17:27
  • @user30878, I'm sorry if my question offends you. I believe it is pretty meaningful and precisely formulated. If you know a way to send a sleep command form the PC to the device, I'm all ears - just keep in mind that there is no dedicated OS driver for it, as it uses the default HID protocol. – AnoE Feb 16 '18 at 21:45
  • Yes you can send commands to your pro mini from PC easily. You can use virtual serial com ports with c#, c, Java etc... And you look like already know Arduino programming. But you maybe will need a push button or something like that for waking up the pro mini again. – user30878 Feb 16 '18 at 21:50
  • @user30878, writing a program on the PC, and adding a push button is exactly what I wish to avoid with this question. If I went to that direction, then I would just have an on/off switch on the device and be done with it (which is what I've done meanwhile, anyways). – AnoE Feb 16 '18 at 22:06
  • Look answers below – user30878 Feb 16 '18 at 22:20
  • https://superuser.com/q/596758/697394 – user30878 Feb 16 '18 at 22:25

2 Answers2

2

Assuming you are using windows, on the device manager you can access each device's properties (power management tab), where you can allow or not each device to wake your system up.

Onairam
  • 21
  • 2
1

Check your BIOS for an option to wake up on a particular key combination, rather than "any key".

Another option is to configure a particular USB port to be powered down when the computer is asleep (or discover which ports are powered down if no such option is available). If that doesn't help, you can try to put a USB hub between the Arduino and the PC: many hubs don't cope with sleep modes very well, so there's a chance they won't re-transmit anything your Arduino is sending unless the PC wakes up. If your computer has USB3, you can try a USB3 hub, which has an even higher chance of exhibiting this behavior since BIOS often lacks USB3 hub support.

Dmitry Grigoryev
  • 1,278
  • 10
  • 31