Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Best way to observe a peripheral’s RSSI #25

Closed
stapelberg opened this issue Sep 7, 2019 · 2 comments
Closed

Best way to observe a peripheral’s RSSI #25

stapelberg opened this issue Sep 7, 2019 · 2 comments
Labels
type: support OT: Request for help using the project

Comments

@stapelberg
Copy link

I want to build a key bowl which detects whether a certain keychain was placed in it by detecting the attached Tile tag via BLE.

What is the most energy-efficient yet reliable way to observe a peripheral’s RSSI?

Currently, I am scanning repeatedly, limited to 4x per second and the specific peripheral address I am interested in:

#include <ArduinoBLE.h>

void setup() {
  Serial.begin(9600);
  while (!Serial); // wait
  
  Serial.println("setup");
  BLE.begin();
  BLE.setEventHandler(BLEDiscovered, discovered);
  BLE.scanForAddress("xx:yy:zz:aa:bb:cc", true);
}

void logDevice(BLEDevice dev) {
  Serial.print("BLE device found: ");
  Serial.print("address=");
  Serial.print(dev.address());
  Serial.print(", rssi=");
  Serial.print(dev.rssi());
  if (!dev.hasLocalName()) {
    Serial.println("");
    return;
  }
  Serial.print(", name=");
  Serial.print(dev.localName());
  Serial.println("");
}

void discovered(BLEDevice dev) {
  BLE.stopScan();
  logDevice(dev);
  delay(250); // ms
  BLE.scanForAddress("xx:yy:zz:aa:bb:cc", true);
}

void loop() {
  BLE.poll(1000); // ms
}

I’m a bit hesitant to connect to the device, because I don’t want to disrupt any other functionality of the Tile.

Is there a better way than the approach displayed above?

Thanks,

@sandeepmistry
Copy link
Contributor

Hi @stapelberg,

Your sketch looks fine, are you planning to power your central via a battery?

If you are, and using a Arduino Nano 33 BLE board, please follow pull request #15 for more low power tricks.

@stapelberg
Copy link
Author

Thanks for taking a look! Yes, I am planning to power the nano 33 BLE from a battery. Thanks for the pointer to the power saving PR :)

@per1234 per1234 added the type: support OT: Request for help using the project label Sep 10, 2019
cparata added a commit to cparata/ArduinoBLE that referenced this issue Feb 8, 2021
Activate default clocks on the stm32wb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: support OT: Request for help using the project
Projects
None yet
Development

No branches or pull requests

3 participants