Bluetooth Low Energy: Peripheral HIDS Keyboard¶
Overview¶
The Peripheral HIDS Keyboard sample demonstrates how to use the GATT Human Interface Device (HID) Service to implement a keyboard input device that you can connect to your computer.
The sample uses the USR button to simulate the letter keys by generating letter keystrokes for a predefined string.
Requirements¶
Before you start, check that you have the required hardware and software:
- 1x nRF54L15 Connect Kit
- 1x U.FL cabled 2.4 GHz Antenna (included in the box)
- 1x USB-C Cable
- A computer running macOS, Ubuntu, or Windows 10 or newer with Bluetooth LE supported
Attaching the 2.4 GHz antenna¶
Before applying power to the board, ensure the U.FL cabled 2.4 GHz antenna is properly installed.
Building the sample¶
To build the sample, follow the instructions in Getting Started Guide to set up your preferred building environment.
Use the following steps to build the Peripheral HIDS Keyboard sample on the command line.
-
Open a terminal window.
-
Go to
NCS-Project/nrf54l15-connectkit
repository cloned in the Getting Started Guide. -
Build the sample using the
west build
command, specifying the board (following the-b
option) asnrf54l15_connectkit/nrf54l15/cpuapp
.west build -p always -b nrf54l15_connectkit/nrf54l15/cpuapp samples/bluetooth/peripheral_hids_keyboard
Tip
The
-p
always option forces a pristine build, and is recommended for new users. Users may also use the-p auto
option, which will use heuristics to determine if a pristine build is required, such as when building another sample. -
After building the sample successfully, the firmware with the name
merged.hex
can be found in thebuild
directory.
Flashing the firmware¶
Connect the nRF54L15 Connect Kit to the computer with a USB-C cable:
Then flash the sample using west flash
:
Tip
In case you wonder, the west flash
will execute the following command:
Testing¶
After programming the sample, test it by performing the following steps:
-
Open up a serial terminal, specifying the primary COM port that your computer uses to communicate with the nRF54L15:
- Start PuTTY.
-
Configure the correct serial port and click Open:
-
Press the DFU/RST button to reset the nRF54L15.
-
Observe the output of the terminal. You should see the output, similar to what is shown in the following:
-
On your computer, search for Bluetooth devices and connect to the device named Nordic_HIDS_keyboard.
-
When pairing, press USR button on the board to confirm the passkey value. Observe the output of the terminal:
-
Open a text editor on your computer, repeatedly press USR button on the board. Every button press sends one character of the test message
hello
(the test message includes a carriage return) to the computer, and this will be displayed in the text editor.