Arduino Nano 33 iol - Trouble scanning for my other nano's battery example

I'm using 2 Arduino Nano 33 iot's. On one of them I've uploaded the battery service example. On the other
I've uploaded the following code which I'm hoping will detect/see the other Nano's advertised battery service.
Unfortunately, I'm not finding it, or any other "random" ble services that are in the area.
The following code just forever displays "Scanning..."
It never seems to find anything available.

Any help will be greatly appreciated!
Thank you

#include <ArduinoBLE.h>
BLEDevice peripheral;
void setup() 
{
  // Try to initialize BLE
  if (!BLE.begin()) {
    Serial.println("Terminal Error: Could not start BLE!");
    while (1);
  }
  BLE.scan();
}

void ProcessBLE()
{
  Serial.print("Scanning... ");
  
  // check if a peripheral has been discovered
  peripheral = BLE.available();

  if (peripheral) 
   {
    Serial.print("Found ");
    Serial.print(peripheral.address());
    Serial.print(" '");
    Serial.print(peripheral.localName());
    exit(1);
   }

 BLE.scan();
}

void loop() {
  ProcessBLE();
}

I figured it out. I needed to put a Delay(200); after scanning, in order to give the device enough time to actually scan before restarting the scan again.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.