u/Fast-Albatross1848

I am having trouble getting this code to work on my esp32 devkit called 1965-ESP32-DEVKITM-1-ND could someone give me steps that should allow it to work

#include <BLEAdvertisedDevice.h>
#include <BLEDevice.h>
#include <BLEScan.h>


const int PIN = 2;
const int CUTOFF = -60;


void setup() {
  pinMode(PIN, OUTPUT);
  BLEDevice::init("");
}


void loop() {
  BLEScan *scan = BLEDevice::getScan();
  scan->setActiveScan(true);
  BLEScanResults results = scan->start(1);
  int best = CUTOFF;
  for (int i = 0; i < results.getCount(); i++) {
    BLEAdvertisedDevice device = results.getDevice(i);
    int rssi = device.getRSSI();
    if (rssi > best) {
      best = rssi;
    }
  }
  digitalWrite(PIN, best > CUTOFF ? HIGH : LOW);
}
reddit.com
u/Fast-Albatross1848 — 23 days ago