Nordic IoT Axon NPU 手势演示(NRF54LM20)开发套件 第 7 篇(蓝牙 HID 模式)

本文是 Nordic nRF54LM20-DK 新款获奖 AI 物联网开发套件系列教程的第 7 篇。

本文承接第 5 篇手势识别演示教程继续讲解。本次我们将把 Nordic nRF54LM20-DK 开发套件配置为蓝牙 HID 设备。操作本章节内容前,请先按照第 5 篇教程完成前期准备。接下来修改prj.conf配置文件,添加如下配置:

#Bluetooth HID mode
CONFIG_BLE_MODE_HID=y

参照系列第 5 篇教程的步骤,完成固件编译并烧录至 nRF54LM20-DK 开发套件。

完成配置后,将该开发平台通过蓝牙连接至笔记本电脑。设备将会作为人机接口设备(HID),依靠 Axon 神经网络识别用户手势,从而在电脑端实现对应的控制功能。本次依旧使用DigiKey在售的 Bosch BMI270 惯性测量单元 Sparkfun 评估板进行手势动作采集。

minicom 串口终端会输出如下运行日志:

*** Booting MCUboot v2.3.0-dev-3dfaa012cf34 ***
*** Using nRF Connect SDK v3.3.0-preview2-ede152ec210b ***
*** Using Zephyr OS v4.3.99-4b6df5ff11b1 ***
I: Starting bootloader
I: Primary image: magic=unset, swap_type=0x1, copy_done=0x3, image_ok=0x3
I: Secondary image: magic=unset, swap_type=0x1, copy_done=0x3, image_ok=0x3
I: Boot source: none
I: Image index: 0, Swap type: none
I: Bootloader chainload address offset: 0x10000
I: Image version: v0.0.0
I: Jumping to the first image slot
*** Booting nRF Connect SDK v3.3.0-preview2-ede152ec210b ***
*** Using Zephyr OS v4.3.99-4b6df5ff11b1 ***
[00:00:00.050,382] <inf> fs_nvs: 8 Sectors of 4096 bytes
[00:00:00.050,390] <inf> fs_nvs: alloc wra: 0, ee0
[00:00:00.050,394] <inf> fs_nvs: data wra: 0, 160
[00:00:00.050,478] <inf> bt_sdc_hci_driver: SoftDevice Controller build revision: 
                                            ac 6c cb 12 2a 45 63 97  7c ba aa bd 8d 8f d0 9b |.l..*Ec. |.......
                                            c2 c9 23 ea                                      |..#.             
[00:00:00.052,819] <inf> bt_hci_core: HW Platform: Nordic Semiconductor (0x0002)
[00:00:00.052,835] <inf> bt_hci_core: HW Variant: nRF54Lx (0x0005)
[00:00:00.052,848] <inf> bt_hci_core: Firmware: Standard Bluetooth controller (0x00) Version 172.52076 Build 1665477138
[00:00:00.053,066] <inf> bt_hci_core: No ID address. App must call settings_load()
[00:00:00.053,082] <inf> ble_hid: Bluetooth initialized
[00:00:00.053,746] <inf> bt_hci_core: HCI transport: SDC
[00:00:00.053,852] <inf> bt_hci_core: Identity: F3:93:F9:A8:5C:40 (random)
[00:00:00.053,871] <inf> bt_hci_core: HCI: version 6.2 (0x10) revision 0x3073, manufacturer 0x0059
[00:00:00.053,890] <inf> bt_hci_core: LMP: version 6.2 (0x10) subver 0x3073
[00:00:00.056,394] <inf> ble_hid: Advertising successfully started
[00:00:00.056,444] <inf> main: nRF Edge AI Gestures Recognition Demo:
[00:00:00.056,455] <inf> main: nRF Edge AI Runtime Version: 2.2.0
[00:00:00.056,474] <inf> main: nRF Edge AI Lab Solution id: 36038
[00:00:00.134,029] <inf> bas: BAS Notifications enabled                  
[00:00:00.134,360] <inf> ble_hid: Connected 98:46:0A:8B:6B:9F (public)   |                             
[00:00:00.609,475] <inf> ble_hid: Input CCCD enabled                 
[00:00:00.609,492] <inf> ble_hid: Input attribute handle: 0             
[00:00:00.609,521] <inf> ble_hid: Consumer CCCD enabled                 
[00:00:00.609,631] <inf> ble_hid: Security changed: 98:46:0A:8B:6B:9F (public) level 2
[00:00:01.701,452] <inf> main: Predicted class: DOUBLE SHAKE, with probability 99 %
[00:00:01.701,690] <inf> ble_hid: BLE HID Key 8 sent successfully
[00:00:03.684,646] <inf> main: Predicted class: DOUBLE SHAKE, with probability 95 %
[00:00:03.684,884] <inf> ble_hid: BLE HID Key 8 sent successfully
[00:00:05.006,769] <inf> main: Predicted class: DOUBLE THUMB, with probability 99 %
[00:00:05.007,007] <inf> ble_hid: BLE HID Key 4 sent successfully
[00:00:06.328,840] <inf> main: Predicted class: DOUBLE SHAKE, with probability 81 %
[00:00:06.329,078] <inf> ble_hid: BLE HID Key 8 sent successfully
[00:00:07.650,962] <inf> main: Predicted class: DOUBLE THUMB, with probability 97 %
[00:00:07.651,200] <inf> ble_hid: BLE HID Key 4 sent successfully
[00:00:09.634,149] <inf> main: Predicted class: SWIPE LEFT, with probability 98 %
[00:00:09.634,387] <inf> ble_hid: BLE HID Key 16 sent successfully
[00:00:12.608,930] <inf> main: Predicted class: SWIPE LEFT, with probability 96 %
[00:00:12.609,168] <inf> ble_hid: BLE HID Key 16 sent successfully
[00:00:13.600,515] <inf> main: Predicted class: DOUBLE THUMB, with probability 78 %
[00:00:13.600,747] <inf> ble_hid: BLE HID Key 4 sent successfully
[00:00:15.914,187] <inf> main: Predicted class: SWIPE LEFT, with probability 93 %
[00:00:15.914,425] <inf> ble_hid: BLE HID Key 16 sent successfully
[00:00:17.236,372] <inf> main: Predicted class: DOUBLE THUMB, with probability 95 %
[00:00:17.236,610] <inf> ble_hid: BLE HID Key 4 sent successfully
[00:00:23.185,865] <inf> main: Predicted class: SWIPE RIGHT, with probability 87 %
[00:00:23.186,103] <inf> ble_hid: BLE HID Key 32 sent successfully
[00:00:29.135,414] <inf> main: Predicted class: SWIPE RIGHT, with probability 97 %
[00:00:29.135,652] <inf> ble_hid: BLE HID Key 32 sent successfully
[00:00:37.398,618] <inf> main: Predicted class: DOUBLE SHAKE, with probability 82 %
[00:00:37.398,856] <inf> ble_hid: BLE HID Key 8 sent successfully
[00:00:39.712,347] <inf> main: Predicted class: DOUBLE THUMB, with probability 99 %
[00:00:39.712,585] <inf> ble_hid: BLE HID Key 4 sent successfully
[00:00:40.703,925] <inf> main: Predicted class: DOUBLE THUMB, with probability 98 %
[00:00:40.704,157] <inf> ble_hid: BLE HID Key 4 sent successfully


etc

从终端日志可以看出蓝牙已成功连接:

[00:00:00.134,360] <inf> ble_hid: Connected 98:46:0A:8B:6B:9F (public)   |                             
[00:00:00.609,475] <inf> ble_hid: Input CCCD enabled                 
[00:00:00.609,492] <inf> ble_hid: Input attribute handle: 0             
[00:00:00.609,521] <inf> ble_hid: Consumer CCCD enabled

本手势识别演示程序可将识别到的特定手势映射为蓝牙 HID 按键信号,笔记本电脑可正常响应对应操作。该演示程序拥有两种工作模式,可通过 nRF54LM20-DK 开发套件上的 KEY0 按键进行切换,分别为演示文稿控制模式音乐播放控制模式**,两种模式分别对应不同的键盘按键指令。

敬请关注本系列后续文章。至此,这套基于 Axon 神经网络处理单元(NPU)、直接调用 Axon NPU 驱动、运行于Nordic 物联网平台的基础版手势识别演示教程全部讲解完毕。这款斩获 2026 嵌入式世界展会奖项的 Nordic nRF54LM20-DK 物联网开发套件,现已在DigiKey上架开售。