rekosk
December 19, 2024, 4:23am
1
Hey, just a genuine question - on the library keyboard.h , there is for some reason listed combability with arduino nano, but everybody is saying that atmega328 can't itself work as keyboard manager. I don't have an arduino nano home right now, but i have arduino UNO with which it is 100% not working, atleast for me. So, like isn't arduino nano just a smaller version of arduino UNO? Or am I wrong?
Hi @rekosk .
The library reference pages like https://www.arduino.cc/reference/en/libraries/keyboard/ are automatically generated for all the libraries in the Arduino Library Manager based on the information in their library.properties
metadata file .
The "Compatibility " list on the reference pages is based on the architectures
field of that file. The reference page generator simply adds all the official boards of each architecture in the field to the list. This is why official boards like the classic Nano and UNO R3 are included in the "Compatibility " list on the "Keyboard " library's page, even though they are absolutely not compatible with the library.
As in this case, a library might require capabilities that are not provided by all boards of that architecture. Currently, there isn't any machine readable data that would allow the generator to understand this so boards that are incompatible with the library may be listed in the reference page.
This problem is tracked by the Arduino website developers here:
opened 07:16AM - 16 Mar 23 UTC
Type: Bug
Component: Website
https://www.arduino.cc/reference/en/libraries/keyboard/
Arduino Uno/Mega/Nano a… re included in the compatibility list even though they are not compatible with the Keyboard library.
### Additional context
#### Additional reports
- https://github.com/arduino-libraries/ArduinoIoTCloud/pull/380#issuecomment-1737244158
- https://forum.arduino.cc/t/arduino-keyboard-not-working-on-arduino-uno-r3/1102400
- https://forum.arduino.cc/t/documentation-for-keyboard-library-needs-some-correction/1126221
- https://forum.arduino.cc/t/sketch-funktioniert-nicht-keyboard/1099364/6
- https://forum.arduino.cc/t/issue-on-keyboard-library/1065385
- https://forum.arduino.cc/t/what-is-wrong-here/1080550/7
- https://forum.arduino.cc/t/why-is-arduino-nano-usable-as-usb-keyboard-controller/1333682
The developers are already working on adding the capability to define compatibility at a board-level granularity:
opened 02:33PM - 17 Apr 23 UTC
type: enhancement
topic: documentation
status: waiting for information
topic: code
phase: design
### Describe the request
Add support for a field named `supported` in [the `l… ibrary.properties` library metadata file](https://arduino.github.io/arduino-cli/dev/library-specification/#library-metadata). This field is a comma-separated list of patterns to match against an FQBN.
This will allow library developers to define the supported boards for the library down to board-level granularity.
The result would be something like this in the `library.properties` file:
```text
name=Camera
version=1.0
author=Arduino
maintainer=Arduino <[email protected] >
sentence=Camera library for Portenta H7 Vision Shield
paragraph=
category=Other
url=https://github.com/arduino/ArduinoCore-mbed/tree/master/libraries/Camera
architectures=mbed,!avr
supported=*:mbed:portenta,!*:*:nano33ble
#supported=mbed:portenta,!mbed:nano33ble <- without wildcards
```
This information could be used for applications such as:
- Accurately populate the "**Compatibility**" lists in [the Arduino Library Reference](https://www.arduino.cc/reference/en/libraries/) (this would require also changing [the **libraries-repository-engine** tool](https://github.com/arduino/libraries-repository-engine) to include the information in [the Library Manager index](http://downloads.arduino.cc/libraries/library_index.json)).
- Select the best library for the selected board during [library discovery](https://arduino.github.io/arduino-cli/dev/sketch-build-process/#dependency-resolution).
- Print a warning when compiling the library for an unsupported board.
- Disallow compilation of the library for boards that are explicitly specified as being unsupported.
### Describe the current behavior
Library developers can only indicate compatibility at architecture-level granularity. A library may have dependencies on attributes that only present on a subset of boards of a given architecture.
This means it is not possible for tools to accurately determine whether a specific board is supported by a library.
For example, the "**Keyboard**" library specifies compatibility with the `avr` architecture:
https://github.com/arduino-libraries/Keyboard/blob/1.0.4/library.properties#L9
```text
architectures=avr, samd, sam
```
However, not all AVR microcontrollers have the required native USB capability. This results in inaccurate information about the library's support for those boards.
The library is listed in `lib list` command output when the FQBN of an unsupported board (e.g., [**Uno**](https://docs.arduino.cc/hardware/uno-rev3)) is specified via the `--fqbn` flag:
```text
$ arduino-cli lib install Keyboard
Downloading [email protected] ...
[email protected] [email protected] already downloaded
Installing [email protected] ...
Installed [email protected]
$ arduino-cli lib list Keyboard --fqbn arduino:avr:uno
Name Installed Available Location Description
Keyboard 1.0.4 - LIBRARY_LOCATION_USER -
```
Unsupported boards are included in the automatically generated "**Compatibility**" list of the library's reference page:
https://www.arduino.cc/reference/en/libraries/keyboard/
### Arduino CLI version
0.32.2
### Operating system
N/A
### Operating system version
N/A
### Additional context
The newly added field should be ignored by versions of Arduino development tools that don't have support for the new field. If so, this change would not result in any backwards incompatibility of the libraries that use it.
---
Relevant code:
https://github.com/arduino/arduino-cli/blob/743c3e9b3c94eded62b44081a03650d571fa230c/arduino/libraries/libraries.go#L78
#### Related
- https://github.com/arduino/Arduino/issues/11871
- https://github.com/arduino/ArduinoCore-mbed/issues/529#issuecomment-1201117968
- https://github.com/arduino/arduino-ide/issues/1304
- https://github.com/arduino-libraries/ArduinoIoTCloud/pull/380#issuecomment-1737244158
- https://forum.arduino.cc/t/documentation-for-keyboard-library-needs-some-correction/1126221
- https://forum.arduino.cc/t/arduino-keyboard-not-working-on-arduino-uno-r3/1102400
- https://forum.arduino.cc/t/sketch-funktioniert-nicht-keyboard/1099364/6
- https://forum.arduino.cc/t/issue-on-keyboard-library/1065385
- https://forum.arduino.cc/t/what-is-wrong-here/1080550/7
- https://forum.arduino.cc/t/comments-on-arduino-1-5-specifications/162030/72 / https://forum.arduino.cc/t/comments-on-arduino-1-5-specifications/162030/83
- https://forum.arduino.cc/t/comments-on-arduino-1-5-specifications/162030/84
### Issue checklist
- [X] I searched for previous requests in [the issue tracker](https://github.com/arduino/arduino-cli/issues?q=)
- [X] I verified the feature was still missing when using the [nightly build](https://arduino.github.io/arduino-cli/dev/installation/#nightly-builds)
- [X] My request contains all necessary details
If you have a GitHub account, you can subscribe to that issue to get notifications of any new developments related to this subject.
Please only comment on the GitHub issue thread if you have new technical information that will assist with the resolution. General discussion and support requests are always welcome here on the Arduino Forum.
That is correct.
Note that there are more modern boards in the Nano form factor which are compatible with the library. The Nano 33 IoT is a nice board that does have the native USB capability that will allow it to be used with the Keyboard library.
You can also do keyboard emulation with the Nano ESP32 , but that is done using a different library than Keyboard.
2 Likes
Remember that NANO is a form factor used with several different processors with vastly different capabilities. This can be a problem when posters say "I have a NANO" without telling us which one. (Why yes, this is a pet peeve of mine.)
3 Likes
rekosk
December 21, 2024, 6:47pm
4
Thanks for fast reply. I understand it now.
1 Like
siebe
December 21, 2024, 6:58pm
5
If you really want something small that supports HID, you can buy the Arduino nano ESP32. It does all of it, I think even trough Bluetooth.
1 Like