Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

BLE Peripheral receiver for 24h usage: it freezes #284

Open
Labels
type: imperfectionPerceived defect in any part of project
@iKK001

Description

I am using the Xiao BLE nRF52840 from Seed Studio since the size is what I need (i.e. Nano 33 is too large)

However, using BLE Receiver Central, it freezes after 15-30min !!!

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 ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    type: imperfectionPerceived defect in any part of project

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

        AltStyle によって変換されたページ (->オリジナル) /