Arduino Nano33 BLE Sense with ArduinoBLE Library

Hello.

I’m trying to upload a simple BLE Scan example using ArduinoBLE library
on Arduino Nano33 BLE Sense board.
… and I get the following error:

Processing nano33ble (platform: nordicnrf52; board: nano33ble; framework: arduino)
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------Verbose mode can be enabled via '-v, --verbose' option
CONFIGURATION: https://docs.platformio.org/page/boards/nordicnrf52/nano33ble.html
PLATFORM: Nordic nRF52 (9.4.0) > Arduino Nano 33 BLE
HARDWARE: NRF52840 64MHz, 256KB RAM, 960KB Flash
DEBUG: Current (blackmagic) External (blackmagic, cmsis-dap, jlink)
PACKAGES:
 - framework-arduino-mbed @ 3.1.1
 - tool-sreccat @ 1.164.0 (1.64)
 - toolchain-gccarmnoneeabi @ 1.80201.181220 (8.2.1)
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 39 compatible libraries
Scanning dependencies...
Dependency Graph
|-- ArduinoBLE @ 1.3.2
Building in release mode
Linking .pio\build\nano33ble\firmware.elf

...

collect2.exe: error: ld returned 1 exit status
*** [.pio\build\nano33ble\firmware.elf] Error 1
================================================================================================= [FAILED] Took 2.27 seconds =================================================================================================

and Here is full build log and project file

I’ve been trying to fix the problem but haven’t been able to figure out what could be causing the problem.

I am new to PlatformIO… any help would be appreciated.
Thanks

1 Like

Just use the updated ArduinoBLE library, there are zero problems.

[env:nano33ble]
platform = nordicnrf52
board = nano33ble
framework = arduino
lib_deps =
  arduino-libraries/ArduinoBLE@^1.3.7
/*
  Scan

  This example scans for Bluetooth® Low Energy peripherals and prints out their advertising details:
  address, local name, advertised service UUID's.

  The circuit:
  - Arduino MKR WiFi 1010, Arduino Uno WiFi Rev2 board, Arduino Nano 33 IoT,
    Arduino Nano 33 BLE, or Arduino Nano 33 BLE Sense board.

  This example code is in the public domain.
*/

#include <ArduinoBLE.h>

void setup() {
  Serial.begin(9600);
  while (!Serial);

  // begin initialization
  if (!BLE.begin()) {
    Serial.println("starting Bluetooth® Low Energy module failed!");

    while (1);
  }

  Serial.println("Bluetooth® Low Energy Central scan");

  // start scanning for peripheral
  BLE.scan();
}

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

  if (peripheral) {
    // discovered a peripheral
    Serial.println("Discovered a peripheral");
    Serial.println("-----------------------");

    // print address
    Serial.print("Address: ");
    Serial.println(peripheral.address());

    // print the local name, if present
    if (peripheral.hasLocalName()) {
      Serial.print("Local Name: ");
      Serial.println(peripheral.localName());
    }

    // print the advertised service UUIDs, if present
    if (peripheral.hasAdvertisedServiceUuid()) {
      Serial.print("Service UUIDs: ");
      for (int i = 0; i < peripheral.advertisedServiceUuidCount(); i++) {
        Serial.print(peripheral.advertisedServiceUuid(i));
        Serial.print(" ");
      }
      Serial.println();
    }

    // print the RSSI
    Serial.print("RSSI: ");
    Serial.println(peripheral.rssi());

    Serial.println();
  }
}
1 Like

Hi Max thanks for your answer! I agree this does work for your example.

I would like to share what finally worked for me, perhaps because my project has a few dependencies that makes it a bit more complex.

Instead of having the ArduinoBLE lib installed by PIO under lib_deps, I have an Arduino IDE installed with all packages that I need, then I’m pointing my PIO project libs to them with lib_extra_dirs.

[env:nano33ble]
platform = nordicnrf52
board = nano33ble
framework = arduino
lib_extra_dirs = C:\Users\<your user>\Arduino\libraries

These are the Arduino libraries that I’m using:
ArduinoBLE
Arduino_BMI270_BMM150
Harvard_TinyMLx
MicroTFLite
Arduino_LSM9DS1

That’s the only way it worked for me (or if I copy these libs locally under my PIO project’s /lib folder and tweak some files then it also works)

If I try to install all these packages using PIO lib manager, I get the error described originally in this thread when I build it.

Another important detail, as I’m in a Windows environment, I also found that I need to have my PIO project folder near the root - e.g. C:\repos\<pio-project>\ - otherwise the path and file names generated during compilation might be too long and become an issue.