@jalmalogni To debug the USB keyboard issue with your Tab5 (SKU:C145/K145), please try the following steps:
Verify USB OTG Configuration: Ensure your code correctly initializes USB OTG mode. Add these build flags to your PlatformIO configuration:
build_flags =
-DARDUINO_USB_CDC_ON_BOOT=1
-DARDUINO_USB_MODE=1
Check USB Initialization Order: Modify the initialization sequence in setup():
USB.begin(); // Initialize USB first
delay(1000); // Add delay before keyboard initialization
Keyboard.begin();
Monitor USB Enumeration: Connect via WebTerminal through UiFlow2 to check if the USB device is recognized. Navigate to the serial monitor and look for USB HID initialization messages.
Test Hardware Connection: Ensure you're using the USB-C port (labeled as USB 2.0 OTG) on Tab5, not the USB-A host port. Try different USB cables known to work with data transfer.
Simplify Test Code: Use this minimal example to isolate the issue:
#include <M5Unified.h>
#include "USB.h"
#include "USBHIDKeyboard.h"
USBHIDKeyboard Keyboard;
void setup() {
M5.begin();
USB.begin();
delay(2000);
Keyboard.begin();
M5.Lcd.print("USB HID Ready");
}
void loop() {
M5.update();
if (M5.BtnA.wasPressed()) {
Keyboard.print("Hello");
Keyboard.write(KEY_RETURN);
}
}
Check Power Management: Ensure Tab5 is sufficiently powered (use external power if battery level is low). USB HID functionality may be disabled under low power conditions.