same here, the Xiao BLE nRF52840 Receiver Central freezes after 15-30min !!!
I am using ArduinoBLE library, normal as usual.
The sender is off most of the time and will only connect and send sensor data about once or twice a day. I try to have the receiver active 24h. But it freezes after 15-30min.
Here is my receiver Central code:
#include <ArduinoBLE.h>
char* PERIPHERAL_LOCAL_NAME = "SOME PERIPHERAL NAME";
#define BLE_UUID_SENSOR_DATA_SERVICE "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
#define BLE_UUID_MULTI_SENSOR_DATA "yyyyyyyy-yyyy-yyyy-yyyy-yyyyyyyyyyyy"
#define BAUDRATE 115200
#define UPDATE_INTERVALL 10
#define BLE_POLL_INTERVALL 5
uint64_t previousMillis = 0;
void setup() {
Serial.begin(BAUDRATE);
delay(2000);
previousMillis = millis();
BLE.begin();
BLE.scanForUuid(BLE_UUID_SENSOR_DATA_SERVICE);
}
void loop() {
unsigned long currentMillis = millis();
if (currentMillis - previousMillis > UPDATE_INTERVALL) {
previousMillis = currentMillis;
BLE.scanForUuid(BLE_UUID_SENSOR_DATA_SERVICE);
BLEDevice peripheral = BLE.available();
if (peripheral) {
if (peripheral.localName() != PERIPHERAL_LOCAL_NAME) {
return;
}
BLE.stopScan();
explorePeripheral(peripheral);
}
}
}
bool explorePeripheral(BLEDevice peripheral) {
if (!peripheral.connect()) {
return false;
}
if (!peripheral.discoverAttributes()) {
peripheral.disconnect();
return false;
}
BLECharacteristic multiSensorDataCharacteristic = peripheral.characteristic(BLE_UUID_MULTI_SENSOR_DATA);
if (!multiSensorDataCharacteristic) {
peripheral.disconnect();
return false;
}
if (!multiSensorDataCharacteristic.canSubscribe()) {
peripheral.disconnect();
return false;
}
if (!multiSensorDataCharacteristic.subscribe()) {
peripheral.disconnect();
return false;
}
while (peripheral.connected()) {
unsigned long currentMillis = millis();
if (currentMillis - previousMillis > BLE_POLL_INTERVALL) {
previousMillis = currentMillis;
BLE.poll();
if (multiSensorDataCharacteristic.valueUpdated()) {
multiSensorDataCharacteristic.readValue(...);
}
// if (peripheral.rssi() != 0) {
// digitalWrite(RSSI_OK_LED_PIN, HIGH);
// } else {
// digitalWrite(RSSI_OK_LED_PIN, LOW); // red alarm LED ON
// }
}
}
peripheral.disconnect();
return true;
}
I tried to add a periodic BLE.end();
followed by a BLE.begin();
every 10 seconds because I believed this might help. But no change.
It seems that only a module RESET will solve the problem.
However, in my application I would like to have the receiver listen during 24 hours (and never power it off or reset).
What could be the issue of the freeze ?