# ArduinoBLE not connecting using basic example

**URL:** <https://forum.arduino.cc/t/arduinoble-not-connecting-using-basic-example/1100912>\
**Category:** Nano 33 BLE\
**Created:** [March 12, 2023, 10:33am UTC](https://forum.arduino.cc/t/arduinoble-not-connecting-using-basic-example/1100912 "2023-03-12T10:33:52Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![gaspiu](https://avatars.discourse-cdn.com/v4/letter/g/34f0e0/32.png) [@gaspiu](https://forum.arduino.cc/u/gaspiu)\
**Post date:** [March 12, 2023, 10:33am UTC](https://forum.arduino.cc/t/arduinoble-not-connecting-using-basic-example/1100912/1 "2023-03-12T10:33:52Z")

</div>

Hey!

Trying to control a wireless headset (Beats Studio 3) I've tried a simple example written in the doc of ArduinoBLE's library. ([ArduinoBLE - bleDevice.connect() - Arduino Reference](https://www.arduino.cc/reference/en/libraries/arduinoble/bledevice.connect/))

Even tho it detects the headset, can print its Mac Adress and all that, the peripheral.connect() keeps returning false.

Any idea of what I'm doing wrong?

Here's my entire code :

```cpp
#include <ArduinoBLE.h>

void setup() {
  Serial.begin(9600);
  while (!Serial);
  if (!BLE.begin()) {
    Serial.println("Error while trying to initialise BLE module");
    while (1);
  }
  Serial.println("Scanning for BLE devices...");
  
  BLE.scan();
}

void loop() {
  BLEDevice peripheral = BLE.available();
  if (peripheral) {
    if (peripheral.address().equalsIgnoreCase("94:F6:D6:F3:03:4A")) { // Just to connect to the desired headset and nothing else.
      Serial.println("Trying to connect to Beats Studio 3:");
      BLE.stopScan();
      if (peripheral.connect()) {
          Serial.println("Connected to device!");
      } else {
          Serial.println("Oops!");
          BLE.scan();
      }
    }
  }
}

```

Thanks in advance!

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/system/32/1140315_2.png) [@system](https://forum.arduino.cc/u/system)\
**Post date:** [September 8, 2023, 10:34am UTC](https://forum.arduino.cc/t/arduinoble-not-connecting-using-basic-example/1100912/2 "2023-09-08T10:34:06Z")

</div>

Closed on September 8, 2023, 10:34am UTC

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