今天小編帶來是創客Hamid Sheibani的項目:鑰匙尋找器。使用了XIAO nRF52840開發板,與鑰匙串結合,讓你告別日常尋找鑰匙的煩惱!
背景故事
該設備利用低功耗藍牙(BLE)技術,與智能手機同步,通過蜂鳴器和LED燈幫助用戶輕松找到遺失的鑰匙。本文將探討這款基于XIAO nRF52840模塊的智能鑰匙定位器的開發過程,并展示其核心功能。
材料清單
硬件
Seeed XIAO BLE nRF52840 Sense × 1
蜂鳴器 × 1
LED × 1
軟件
nRF Connect SDK
Seeed Fusion
核心組件及作用
這款智能鑰匙尋找器的核心是XIAO NRF52840模塊,這是一款小巧強大的開發板,內置ARM Cortex-M4處理器,專為低功耗藍牙(BLE)通信而設計。其功能的實現離不開以下關鍵組件:
蜂鳴器:通過發出獨特聲音,幫助鑰匙主人快速找到鑰匙
LED燈:在昏暗環境下,LED燈發出亮光,讓丟失的鑰匙輕松現身。
按鈕:這實用的組件負責在找到鑰匙后關閉蜂鳴器和LED燈。
硬件配置
通過XIAO nRF52840的通用輸入輸出(GPIO)引腳連接到蜂鳴器、LED燈和按鈕。
程序邏輯與Arduino IDE
Arduino IDE:通過功能強大的Arduino集成開發環境(IDE),固件程序得以實現,重點開發穩定的BLE功能,實現與智能手機的無縫通信。
BLE同步:通過nRF Connect應用,鑰匙定位器與智能手機建立BLE連接,搭建指令傳輸的橋梁。
指令執行:固件程序的核心是接收智能手機信號后精準執行指令,從而激活蜂鳴器和LED燈,引導用戶找到鑰匙。
高效電源管理:為了延長電池壽命,固件集成了智能省電機制,在設備空閑時切換到低功耗模式。
以下是可參考的Arduino代碼:
#includeBLEService KeyFinderService("19B10000-E8F2-537E-4F6C-D104768A1214"); // Bluetooth Low Energy KeyFinder Service // Bluetooth Low Energy Key Finder Characteristic - custom 128-bit UUID, read and writable by central BLEByteCharacteristic switchCharacteristic("19B10001-E8F2-537E-4F6C-D104768A1214", BLERead | BLEWrite); const int ledPin = LED_BUILTIN; // pin to use for the LED void setup() { Serial.begin(115200); // set LED pin to output mode pinMode(ledPin, OUTPUT); pinMode(D6, OUTPUT); pinMode(D5, OUTPUT); pinMode(D7, INPUT); // begin initialization if (!BLE.begin()) { Serial.println("starting Bluetooth Low Energy module failed!"); while (1); } // set advertised local name and service UUID: BLE.setLocalName("KeyFinder"); BLE.setAdvertisedService(KeyFinderService); // add the characteristic to the service KeyFinderService.addCharacteristic(switchCharacteristic); // add service BLE.addService(KeyFinderService); // set the initial value for the characeristic: switchCharacteristic.writeValue(0); // start advertising BLE.advertise(); Serial.println("BLE Key Finder Peripheral"); } void loop() { // listen for Bluetooth Low Energy peripherals to connect: BLEDevice central = BLE.central(); // if a central is connected to peripheral: if (central) { Serial.print("Connected to central: "); // print the central's MAC address: Serial.println(central.address()); // while the central is still connected to peripheral: while (central.connected()) { if (switchCharacteristic.written()) { if (switchCharacteristic.value()) { Serial.println("LED on"); digitalWrite(ledPin, LOW); // changed from HIGH to LOW digitalWrite(D5, HIGH); while(1) { tone(D6, 500, 500); delay(1000); if(digitalRead(D7) == 0) { Serial.println(F("LED off")); digitalWrite(ledPin, HIGH); // changed from LOW to HIGH digitalWrite(D5, LOW); digitalWrite(D6, LOW); break; } } } } } // when the central disconnects, print it out: Serial.print(F("Disconnected from central: ")); Serial.println(central.address()); } }
操作流程
BLE配對:通過nRF Connect應用,智能手機能夠檢測到鑰匙定位器的存在,并建立BLE連接,打開了一個無縫的通信通道。
指令傳輸:智能手機傳輸預設的指令,激活蜂鳴器和LED燈,提供定位鑰匙的提示。
輕松發現:用戶只需跟隨聽得見的提示音和LED燈的引導,便能快速高效地找到鑰匙,告別忙亂的尋找過程。
優勢與實際應用場景
量身定制的用戶體驗:可定制的固件使用戶能夠根據個人偏好調整聲音和燈光模式。
適應性強的設計:該設備具備未來擴展的潛力,可以集成更多傳感器,保持靈活與適應性。
緊急援助:除了作為鑰匙尋找器,這款設備還能在關鍵時刻作為SOS信號燈,提供緊急求助功能。
結論
這款基于XIAO nRF52840模塊的鑰匙尋找器,通過BLE連接,優雅地彌合了日常物品與智能解決方案之間的差距,展示了技術的純粹魅力。
-
定位器
+關注
關注
2文章
170瀏覽量
17649 -
BLE
+關注
關注
12文章
670瀏覽量
59552 -
nrf52840
+關注
關注
2文章
99瀏覽量
8338
原文標題:創客項目秀|基于XIAO nRF52840的鑰匙尋找器
文章出處:【微信號:ChaiHuoMakerSpace,微信公眾號:柴火創客空間】歡迎添加關注!文章轉載請注明出處。
發布評論請先 登錄
相關推薦
評論