BLE Not connecting properly

Hi,

I designed a custom NRF52832 board and need to connect it to an ESP32 board. I soldered five boards for testing and also have an NRF devkit.

However, the ESP32 only detects two of the boards, while the others are not recognized. When I scan using the nRF Connect app, it detects all of them. Additionally, I suspect there may be issues even with the working boards, as some data packets are missing intermittently. This could be due to antenna mismatch or possibly unexpected board resets, but I'm not sure. The NRF devkit works properly without issues.

I'm using the internal LF crystal with the following configuration, which I added to the beacon example code:

CONFIG_CLOCK_CONTROL_NRF_K32SRC_RC=y
CONFIG_CLOCK_CONTROL_NRF_K32SRC_500PPM=y

Attached are the schematic and Arduino code for scanning BLE MAC addresses. I made slight modifications to the Arduino IDE BLE scan code to scan for a specific device. what would be the reason for this issue?

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

const char* targetMAC = "cf:24:a5:df:46:47";  // Target MAC address

BLEScan *pBLEScan;

class MyAdvertisedDeviceCallbacks : public BLEAdvertisedDeviceCallbacks {
  void onResult(BLEAdvertisedDevice advertisedDevice) {
    String deviceMAC = advertisedDevice.getAddress().toString();
    int rssi = advertisedDevice.getRSSI();

    if (deviceMAC == targetMAC) {
      Serial.printf("Device Found! MAC: %s, RSSI: %d dBm\n", deviceMAC.c_str(), rssi);
    }
  }
};

void setup() {
  Serial.begin(115200);
  Serial.println("Starting BLE scan...");

  BLEDevice::init("");
  pBLEScan = BLEDevice::getScan();
  pBLEScan->setAdvertisedDeviceCallbacks(new MyAdvertisedDeviceCallbacks());
  pBLEScan->setActiveScan(true);  // Active scan for faster results
  pBLEScan->setInterval(100);
  pBLEScan->setWindow(99);
}

void loop() {
  BLEScanResults *foundDevices = pBLEScan->start(5, false);  // Scan for 5 seconds
  pBLEScan->clearResults(); // Clear buffer to free memory
  delay(100); // Add a small delay to avoid overwhelming the ESP32
}

  • After hours of debugging, I found that the issue is with the ESP board. I don't know the exact reason why only two boards connected while the others didn't. However, when I used the ESP32-S3 development board, all the NRF boards connected properly. I suspect the issue is related to Bluetooth compatibility. Does anyone know the exact reason why only two boards connected while the others didn't?

Related