低功耗藍芽本身就有不同的連接方式,剛好 Arduino 提供中央和週邊的連接方式。
首先,要去 Board Manager,下載到 Intel Curie 的專用 Library:
然後,燒錄這個 Code:
#include <CurieBLE.h> void setup() { Serial.begin(9600); // initialize the BLE hardware BLE.begin(); Serial.println("BLE Central scan"); // start scanning for peripheral BLE.scan(); } void loop() { // check if a peripheral has been discovered BLEDevice peripheral = BLE.available(); if (peripheral) { // discovered a peripheral Serial.println("Discovered a peripheral"); Serial.println("-----------------------"); // print address Serial.print("Address: "); Serial.println(peripheral.address()); // print the local name, if present if (peripheral.hasLocalName()) { Serial.print("Local Name: "); Serial.println(peripheral.localName()); } // print the advertised service UUID's, if present if (peripheral.hasAdvertisedServiceUuid()) { Serial.print("Service UUID's: "); for (int i = 0; i < peripheral.advertisedServiceUuidCount(); i++) { Serial.print(peripheral.advertisedServiceUuid(i)); Serial.print(" "); } Serial.println(); } // print the RSSI Serial.print("RSSI: "); Serial.println(peripheral.rssi()); Serial.println(); } }
燒入後,就可以搜尋到周圍設備了:
沒有留言:
張貼留言