Arduino Nano 33 BLE connection loss

Hi I was wondering if anyone knows how to keep a consistent data connection between two Arduino Nano 33 BLE boards. Currently I have to implement a loop of disconnect and reconnect the devices as a means of updating my data. However after a few minutes it will eventually fail to discover any attributes of the device thus requiring me to reset both boards. Any help would be appreciated.

Thanks.

Hello Dino2013,

Could you possibly provide a bit more detail as to what you are trying to do (including frequency of data reads, other tasks required by the boards, how long they are going to have be on for, etc.), what the data is, and what you are currently doing to achieve this?

It would probably also be helpful to read the Arduino BLE library documentation if you haven't done so already.

There are several ongoing discussion about connection loss handling, for example https://forum.arduino.cc/index.php?topic=645907.0, so you are not alone.

Please use the code square brackets for any code.

Thanks,
Matt

Hi matt_lee_smith,

I am planning on collecting real-world data and relay that information across different BLE boards in a mesh network structure. Currently I am planning on just collecting temperature data as a basis though I would like to incorporate different data once I finalise the communication aspect.

In regards to transmission I would like for 24 hour transmission to be possible as long as there is a corresponding board within range with data transmitted within intervals between 5-10 mins or when a certain threshold has been reached.

In terms of communication I have the system set to identify a specific UUID and when connection is lost to rescan until found again. However when if I don't disconnect and reconnect the data will only show the first value and not update but if I disconnect and reconnect the data updates however it will eventually fail to discover the data values.

I have looked at the Arduino BLE library documentation but have yet to find anything that may prove useful for this situation but thanks for the suggestion.

Thanks,

D

Right, so is this mesh going to try to send the data from one board to another via other boards acting as nodes or is it more like there is one central board that collects various node data if they are in range? A diagram would be helpful.

I ask because of the peripheral/central structure of the BLE. It works by having a peripheral advertise data and the central picks it up. A mesh of nodes would probably have to switch between peripheral and central modes in order to collect and then transmit the data along the mesh.

If the central device is just collecting data from a number of Nano 33 Senses then you might be better off using a Nano 33 Iot as a central device as it currently handles the loss of connection better. I have been experimenting with disconnecting a Sense (peripheral) from an IoT (central) in the middle of transmitting data and plugging it back in and seems to work ok.

I have also left the IoT constantly running the discover peripheral example with a slight modification that means the BLE ends and begins at each disconnect effectively resetting it (see below). The IoT seems to be able to handle running BLE.end() and then BLE.begin() over and over whereas last time I tried the Sense couldn’t.

void loop() {
  // check if a peripheral has been discovered
  BLEDevice peripheral = BLE.available();

  if (peripheral) {
    // discovered a peripheral, print out address, local name, and advertised service
    Serial.print("Found ");
    Serial.print(peripheral.address());
    Serial.print(" '");
    Serial.print(peripheral.localName());
    Serial.print("' ");
    Serial.print(peripheral.advertisedServiceUuid());
    Serial.println();

    if (peripheral.localName() == "BatteryMonitor") {
      // stop scanning
      BLE.stopScan();

      explorerPeripheral(peripheral);
      BLE.end();
      if (!BLE.begin()) {
        Serial.println("starting BLE failed!");

        while (1);
      }
      BLE.scan(true);
    }
  }
}

If you are able to it would help to upload the code you are using and use the code tags or attach it as a separate file. Once the two boards are connected, do they ever need to disconnect?