1

OS: Mac Arduino: 1.8.13 Keyboard Library: 1.0.2

ESP8266

I have a generic ESP8266 board, and I have the following code

void setup() {
  // put your setup code here, to run once:
  pinMode(LED_BUILTIN, OUTPUT);
  Keyboard.begin();
}

void loop() {}

However I get the following ouput:

In file included from /Users/quba/Sandbox/sketch_feb07a/sketch_feb07a.ino:1:0:
/Applications/Arduino.app/Contents/Java/libraries/Keyboard/src/Keyboard.h:25:17: fatal error: HID.h: No such file or directory
#include "HID.h"
                          ^
compilation terminated.
exit status 1
Error compiling for board Generic ESP8266 Module.
Could not find boards.txt in /Users/quba/Library/Arduino15/packages/arduino/hardware/megaavr/1.8.7. Is it pre-1.5?

1 Answer 1

4

The Keyboard library is for Arduino ATMega32U4 based Arduinos (and other similar ones with USB) only. The ESP8266 does not have USB, so how can it possibly use the Keyboard library?

2
  • I have added a picture so you can see the TX and RX pins, as well as the USB Feb 8, 2021 at 8:02
  • 2
    The keyboard library is meant for devices that can talk DIRECTLY to the USB bus, like the AVR ATMega32u4. The ESP8266 on the NodeMCU you show in your picture does not have that capability but it has a separate Serial-to-USB chip that's able to talk to a PC via USB. Even then, it can only act as a peripheral to a PC and not as a USB "Master" that's able to control its own USB peripherals (like a keyboard).
    – StarCat
    Feb 8, 2021 at 9:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.