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
At first I thought it was due to my code, so I tested it with an absolute minimal configuration: same result.
Setup: Seed Studio XIAO ESP32C3 with button connected to D0<->GND
Arduino IDE with esp32 2.0.17
On Windows 10/11, the device is detected and can be paired.
After pairing, everything works perfectly. When you press the button, "i" characters are typed into Notepad.
When you restart the ESP, the Windows laptop, or even just the Bluetooth on the laptop, the paired device reconnects, but no letters are typed into Notepad anymore. Something is happening though, as the cursor briefly stops blinking.
This issue doesn't occur on iOS, Android, ChromeOS, or Linux.
I even tested it with a live system on the same hardware where it wasn't working under Windows:
With Ubuntu, there's no problem at all - after resetting the ESP, it reconnects immediately and you can type letters again.
If I remove the device under Windows and pair it again, it works again - until the next reconnection.
Any ideas? Or has anyone experienced the same problem?
The Code I use for testing.
#include <BleKeyboard.h>
// Initialize the BLE Keyboard with a name and manufacturer
BleKeyboard bleKeyboard("Button Keyboard", "MyCompany", 100);
// Define the button pin
const int BUTTON_PIN = 2; // D0 = GPIO2
// Variables for button debouncing
bool lastButtonState = HIGH; // Initial state (Pull-Up)
unsigned long lastDebounceTime = 0;
const unsigned long debounceDelay = 50; // Debounce time in milliseconds
void setup() {
// Start serial communication for debugging (optional)
Serial.begin(115200);
Serial.println("Starting BLE Keyboard...");
// Configure the button pin as input with internal pull-up resistor
pinMode(BUTTON_PIN, INPUT_PULLUP);
Serial.println("Button pin configured as INPUT_PULLUP.");
// Start the BLE Keyboard
bleKeyboard.begin();
Serial.println("BLE Keyboard initialized.");
}
void loop() {
// Check if the BLE Keyboard is connected
if (bleKeyboard.isConnected()) {
// Read the current state of the button
int reading = digitalRead(BUTTON_PIN);
// Check if the button state has changed (debouncing)
if (reading != lastButtonState) {
lastDebounceTime = millis();
}
// If the state has been stable for longer than the debounce delay
if ((millis() - lastDebounceTime) > debounceDelay) {
// If the button is pressed (LOW because of Pull-Up)
if (reading == LOW) {
Serial.println("Button pressed. Sending 'i'.");
bleKeyboard.print("i");
// Short delay to prevent multiple sends
delay(200);
}
}
// Update the last button state
lastButtonState = reading;
}
// Short delay to reduce CPU usage
delay(10);
}
The text was updated successfully, but these errors were encountered:
At first I thought it was due to my code, so I tested it with an absolute minimal configuration: same result.
Setup: Seed Studio XIAO ESP32C3 with button connected to D0<->GND
Arduino IDE with esp32 2.0.17
On Windows 10/11, the device is detected and can be paired.
After pairing, everything works perfectly. When you press the button, "i" characters are typed into Notepad.
When you restart the ESP, the Windows laptop, or even just the Bluetooth on the laptop, the paired device reconnects, but no letters are typed into Notepad anymore. Something is happening though, as the cursor briefly stops blinking.
This issue doesn't occur on iOS, Android, ChromeOS, or Linux.
I even tested it with a live system on the same hardware where it wasn't working under Windows:
With Ubuntu, there's no problem at all - after resetting the ESP, it reconnects immediately and you can type letters again.
If I remove the device under Windows and pair it again, it works again - until the next reconnection.
Any ideas? Or has anyone experienced the same problem?
The Code I use for testing.
The text was updated successfully, but these errors were encountered: