Keyboard and ESP32-S3-Zero

Hello,

I have as project to simulate keyboard with a ESP32-S3.
In Arduino IDE, I hav already installed Adafruit TinyUSB Library and ESP32TinyUSB.
My config concerning my board :

Here a short code to simulate the pressing of A character :

#include <Adafruit_TinyUSB.h>

Adafruit_USBD_HID usb_hid;

void setup() {
    Serial.begin(115200);
    usb_hid.begin();
    while (!TinyUSBDevice.mounted()) {
        delay(100);
    }
    Serial.println("USB HID initialized and mounted");

    // Test envoi d'une touche
    delay(1000); // Attendre avant d'envoyer
    sendKey('A');
}

void loop() {
    // Vide
}

void sendKey(char ch) {
    uint8_t keycode = HID_KEY_A; // Envoie simplement la touche 'A'
    uint8_t modifiers = 0;

    Serial.println("Sending key press...");
    usb_hid.keyboardPress(keycode, modifiers);
    Serial.println("Key press sent.");
    delay(100);
    usb_hid.keyboardRelease(keycode);
    Serial.println("Key released");
}

The ouput of Serial Monitor :

3:51:22.850 -> Sending key press...Sending key press...Sending key press...Sending key press...

For each "Sending key press...", the ESP32S3 reboots. And I don't have the ouput string 'USB HID initialized and mounted', so it seems the TinyUSB is not mounted, but the while loop is finish :frowning_face:

Can you help me please ?

Thank you :slight_smile:

I moved your topic to a more appropriate forum category @Electrof .

The Nano ESP32 category you chose is only used for discussions directly related to the Arduino Nano ESP32 board.

In the future, please take the time to pick the forum category that best suits the subject of your question. There is an "About the _____ category" topic at the top of each category that explains its purpose.

Thanks in advance for your cooperation.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.