-
Notifications
You must be signed in to change notification settings - Fork 7.6k
ESP32-S3 - Arduino v3.1 - USBHIDKeyboard won't wake up pc from sleep #10831
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I confirm the problem with an ESP32-S2 board, using the OP source plus the following loop(). #include "tusb.h" // for tud_suspended(), tud_remote_wakeup()
const int buttonPin = 0; // input pin for pushbutton
int previousButtonState = HIGH; // for checking the state of a pushButton
int counter = 0; // button push counter
void loop() {
// read the pushbutton:
int buttonState = digitalRead(buttonPin);
// if the button state has changed, and it's currently pressed:
if ((buttonState != previousButtonState) && (buttonState == LOW)) {
if (tud_suspended()) { // Ensure the PC is actually in sleep mode
tud_remote_wakeup(); // TinyUSB wakeup function
webSerial.println("Wakeup send.");
} else
webSerial.println("Not suspended.");
// increment the button counter
counter++;
// type out a message
webSerial.print("You pressed the button ");
webSerial.print(counter);
webSerial.println(" times.");
}
// save the current button state for comparison next time:
previousButtonState = buttonState;
} Since USB SUSPENDED, USB RESUMED are never received (the only events received are USB UNPLUGGED and USB PLUGGED), tud_suspended() is always false, but even if we ignore it and send tud_remote_wakeup() anyway, nothing happens.
Tested on a Desktop with Windows 10, USB power is always ON (ESP32-S2 has power even when PC is shut down or during sleep) |
@me-no-dev @SuGlider Is there anything we can do to help troubleshoot the issue? It seems @dat-master has confirmed the behaviour on the S2 as well. |
Any updates on this? @SuGlider |
Hi all, sorry to bump this, but it’s been open for 4 months without any updates or feedback. It would be really appreciated if someone from the team could take a moment to confirm whether this is on the radar, or if there’s anything we (or other contributors) can do to help investigate or work toward a fix. Even a quick comment would go a long way in clarifying the current status. Thanks in advance for your time and for all the hard work on the project. |
Board
ESP32-S3
Device Description
Custom ESP32-S3 keyboard but it should work on any ESP32-S3 devkit with USB connection.
Hardware Configuration
N.A.
Version
v3.1.0
IDE Name
Arduino IDE
Operating System
macOS 15.2
Flash frequency
80MHz
PSRAM enabled
no
Upload speed
921600
Description
I’m using an ESP32-S3 with Arduino’s USBHIDKeyboard library to emulate a USB keyboard. However, the device never enters USB suspend mode when the host (PC) is put to sleep. This prevents the ESP32-S3 from waking the PC using the remote wakeup feature.
Expected Behavior:
• When the PC enters sleep mode, the ESP32-S3 should detect the USB suspend signal and enter suspend mode.
• Upon a key press or specific action, the ESP32-S3 should trigger a remote wakeup to wake the PC.
Actual Behavior:
• The ESP32-S3 simply detects the USB being disconnected.
• The remote wakeup functionality does not work because the device never transitions to suspend mode.
I tested this behavior using a windows notebook and a generic logitech keyboard and once the pc goes (or is forced) to sleep, the keyboard is able to wake it up. Important: the keyboard must be connected before going to sleep.
I tested this with both Arduino version v2.0.17 and v3.1.0, so it appears it's not a new issue.
I must specify I added the REMOTE_WAKEUP attribute before initializing the USB.
I found another repository that doesn't use the Arduino Core and it seems this is something possible with the ESP32-S3 hardware and TinyUSB: https://github.com/nonoo/esp-remote-wakeup/
I also tried to manually call the
tud_remote_wakeup
function but without success, it is probably because the bus is not in the suspended mode.In the example sketch you can replace the Serial Printf for ARDUINO_USB_SUSPEND_EVENT and ARDUINO_USB_RESUME_EVENT with a digitalWrite to a LED to see the behavior without having access to the serial.
Let me know if I can help by providing more details or other stuff I tested.
Sketch
Debug Message
Other Steps to Reproduce
No response
I have checked existing issues, online documentation and the Troubleshooting Guide
The text was updated successfully, but these errors were encountered: