You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
#include<USB.h>
#include<USBCDC.h>
#include<USBHIDKeyboard.h>
USBHIDKeyboard m_keyboard;
USBCDC m_serial;
ESPUSB* m_usb;
staticvoidusbEventCallback(void* arg,
esp_event_base_t event_base,
int32_t event_id,
void* event_data)
{
if (event_base == ARDUINO_USB_EVENTS) {
arduino_usb_event_data_t* data = (arduino_usb_event_data_t*)event_data;
switch (event_id) {
case ARDUINO_USB_STARTED_EVENT:
m_serial.println("USB PLUGGED");
break;
case ARDUINO_USB_STOPPED_EVENT:
m_serial.println("USB UNPLUGGED");
break;
case ARDUINO_USB_SUSPEND_EVENT:
m_serial.printf("USB SUSPENDED: remote_wakeup_en: %u\n",
data->suspend.remote_wakeup_en);
break;
case ARDUINO_USB_RESUME_EVENT:
m_serial.println("USB RESUMED");
break;
default:
break;
}
} elseif (event_base == ARDUINO_USB_HID_EVENTS) {
arduino_usb_hid_event_data_t* data =
(arduino_usb_hid_event_data_t*)event_data;
switch (event_id) {
case ARDUINO_USB_HID_SET_PROTOCOL_EVENT:
m_serial.printf("HID SET PROTOCOL: %s\n",
data->set_protocol.protocol ? "REPORT" : "BOOT");
break;
case ARDUINO_USB_HID_SET_IDLE_EVENT:
m_serial.printf("HID SET IDLE: %u\n", data->set_idle.idle_rate);
break;
default:
break;
}
}
}
voidsetup()
{
// put your setup code here, to run once:// m_serial.begin(115200);
USB.onEvent(usbEventCallback);
m_keyboard.onEvent(usbEventCallback);
m_serial.onEvent(usbEventCallback);
m_keyboard.begin();
m_serial.begin(115200);
// m_serial.enableReboot(false);
m_usb = &USB; // get the USB object
m_usb->manufacturerName("TEST MAN");
m_usb->productName("TEST DEV");
// also tried with just TUSB_DESC_CONFIG_ATT_REMOTE_WAKEUP no change
m_usb->usbAttributes(TUSB_DESC_CONFIG_ATT_SELF_POWERED | TUSB_DESC_CONFIG_ATT_REMOTE_WAKEUP);
m_usb->begin();
}
voidloop()
{
// put your main code here, to run repeatedly:delay(1000);
}
Debug Message
N.A.
Other Steps to Reproduce
No response
I have checked existing issues, online documentation and the Troubleshooting Guide
I confirm I have checked existing issues, online documentation and Troubleshooting guide.
The text was updated successfully, but these errors were encountered:
TheCrypt0
changed the title
ESP32-S3 - USBHIDKeyboard won't wake up pc from sleep
ESP32-S3 - Arduino v3.1 - USBHIDKeyboard won't wake up pc from sleep
Jan 9, 2025
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: