Trouble with ArduinoBLE library on Arduino Nano 33 BLE Sense

Hi, I'm new to Arduino and trying to get the BLE running on the nano 33 BLE Sense. I'm coding on the IDE interface. I installed the ArduinoBLE library and when I try to include it with the following line:

#include <ArduinoBLE.h>                 // Library for the Bluetooth (BLE)

I get the following warning:
WARNING: library ArduinoBLE claims to run on samd, megaavr, mbed, apollo3 architecture(s) and may be incompatible with your current board which runs on mbed_nano architecture(s).

Is that a valid warning?

After that I get many (100's) of warnings like:
C:........\ATT.cpp:522:39: warning: variable length array 'notification' is used [-Wvla]
uint8_t notification[_peers[i].mtu];

I saw a few questions about these warnings on the web, but no solutions and I found nothing on the forum.

I'm sure there is something very basic that I'm doing wrong.

Thanks in advance,
Ben

What version of the library are you running?

Try the latest 1.2.1 if you are not running it. This was supposed to have been fixed about a month ago.
https://github.com/arduino-libraries/ArduinoBLE/commit/d59eb8c454c91b7a62b87dc538ca0250cb076b82#diff-f267f9ae2f5d5d56a1dbb305e95d40d4408d9ee7f71357f1f67fb18c29b7f082

Hi @benofthewoodz.

The TL;DR is that you are using an outdated version of the library. You can ignore the warning safely, or else update the library by following these instructions:

  1. Select Sketch > Include Library > Manage Libraries... from the Arduino IDE's menus.
  2. Wait for the update to finish.
  3. In the "Filter your search..." field, type "arduinoble".
  4. Press Enter.
  5. Scroll down through the list of search results until you find "ArduinoBLE by Arduino". Click on it.
  6. Click the Update button.
  7. Wait for the update to finish. You should now have ArduinoBLE 1.2.1 installed.
  8. Click the Close button.

But this is Arduino and some of us like to understand the "why"s, rather than being satisfied only with the "how"s, so I'll give a detailed explanation for those who are interested. Everyone else can happily ignore these ramblings.

The code ("Arduino boards platform") that defines the configuration of the Nano 33 BLE Sense and implements the core library that provides the standard Arduino Language functions (e.g., digitalWrite()) for that board was originally named "Arduino Mbed OS Boards". This boards platform originally only provided support for the Nano 33 BLE and Nano 33 BLE Sense, then was expanded for the Portenta H7, and most recently for the Nano RP2040 Connect and Edge Control.

A heavy weight platform from the beginning due to the inclusion of the Mbed OS realtime operating system, the addition of support for diverse microcontrollers made it grow and grow. For this reason, Arduino made the decision to split the Arduino Mbed OS Boards platform into separate platforms for each distinctive board family. This was done last month in the 2.0.0 release. All boards of the Arduino Mbed OS Boards platform were previously identified as having the mbed architecture, but with this split, each separate platform got its own architecture:

  • mbed_nano
    • Arduino 33 BLE
    • Arduino 33 BLE Sense
    • Arduino RP2040 Connect
  • mbed_edge
    • Arduino Edge Control
  • mbed_portenta
    • Arduino Portenta H7
  • mbed_rp2040
    • Raspberry Pi Pico
    • Other 3rd party RP2040-based boards

Arduino libraries have a metadata file named library.properties. This metadata file has an architectures field where the compatible board architectures of a library may be defined.

In the 1.2.0 and earlier versions, the ArduinoBLE library's architectures field looked like this:
https://github.com/arduino-libraries/ArduinoBLE/blob/1.2.0/library.properties#L9

architectures=samd,megaavr,mbed,apollo3

At that time, the mbed item in the architectures list was sufficient to indicate the library's compatibility with the Nano 33 BLE. But once the architecture name of the Nano 33 BLE changed, it was necessary to add new architectures to the list, retaining the original mbed for backwards compatibility for people who hadn't yet updated their boards platform. That was done in the ArduinoBLE 1.2.1 release:
https://github.com/arduino-libraries/ArduinoBLE/blob/1.2.1/library.properties#L9

architectures=samd,megaavr,mbed,apollo3,mbed_nano,mbed_portenta
1 Like

Thanks pert and cattledog. I just noticed that it defaulted to 1.2.0, so I updated it to 1.2.1. It took care of that warning, but I still get all the other warnings:

C:........\Arduino\libraries\ArduinoBLE\src\utility\HCI.cpp: In member function 'virtual int HCIClass::sendAclPkt(uint16_t, uint8_t, uint8_t, void*)':
C:........\Arduino\libraries\ArduinoBLE\src\utility\HCI.cpp:430:41: warning: variable length array 'txBuffer' is used [-Wvla]
uint8_t txBuffer[sizeof(aclHdr) + plen];
^
C:........\Arduino\libraries\ArduinoBLE\src\utility\HCI.cpp: In member function 'virtual int HCIClass::sendCommand(uint16_t, uint8_t, void*)':
C:........\Arduino\libraries\ArduinoBLE\src\utility\HCI.cpp:472:41: warning: variable length array 'txBuffer' is used [-Wvla]
uint8_t txBuffer[sizeof(pktHdr) + plen];
^
C:........\Arduino\libraries\ArduinoBLE\src\utility\ATT.cpp: In member function 'virtual bool ATTClass::handleNotify(uint16_t, const uint8_t*, int)':
C:........\Arduino\libraries\ArduinoBLE\src\utility\ATT.cpp:522:39: warning: variable length array 'notification' is used [-Wvla]
uint8_t notification[_peers[i].mtu];
^
C:........\Arduino\libraries\ArduinoBLE\src\utility\ATT.cpp: In member function 'virtual bool ATTClass::handleInd(uint16_t, const uint8_t*, int)':
C:........\Arduino\libraries\ArduinoBLE\src\utility\ATT.cpp:552:37: warning: variable length array 'indication' is used [-Wvla]
uint8_t indication[_peers[i].mtu];

And so on....

Thanks,
Ben

Any idea what may be causing this?

Reported as issue on GitHub
https://github.com/arduino-libraries/ArduinoBLE/issues/89

and here again
https://github.com/arduino-libraries/ArduinoBLE/issues/163

You probably just need to be aware of this issue, ignore the warnings, and watch your array sizes and bounds. :wink:

1 Like

Ok, I finally got this to compile without all these warnings.

  • If I open my sketch and compile with no board connected, I get all the warnings.
  • If I connect the board and compile, I don't get the warnings, and my code runs.
  • If I disconnect the board and compile, I still don't get the warnings
  • If I close the code and re-open and try to compile without connecting the board, I get all the warnings
  • If I connect the board and compile, I don't get the warnings.

I did that at least twice and I get the same behavior.

Does the library expect to have the board connected at least once to compile correctly? The first compilation after starting the editor takes a lot more time, so I guess it does something more than at subsequent compiles.

Thanks,
Ben

cattledog, I just saw your reply. Thanks.
Ok, I will keep that in mind and ignore them at first compile. It is strange though that they go away when the board is connected.

No. Compilation is exclusively a process handled by your PC, never affected by having a board connected to your computer. You can compile sketches for boards you don't even own if you like (I do it all the time while providing support).

The Arduino build system caches compiled libraries. So they are only compiled the first time you compile your sketch after starting the Arduino IDE or changing the Tools > Board selection, or in the event you make some modification to a library file.

The sketch code itself is recompiled every time.

Most especially in the case of the Nano 33 BLE Sense due to using Mbed OS, compiling those libraries takes quite some time, so the caching is nice.

A side effect of this caching is that you will only see warnings generated by library code on the first compilation. After that, you will only see the warnings generated by the sketch code.

1 Like

Thanks pert, that helps.
I just tried it again and I see exactly what you describe: On first compile, I see the warnings, then on second compile I don't see them, regardless if I have the board plugged in or not. I'm not sure why I did not realize that before, I guess I just happened to plug in the board everytime after the first try.

Anyway, thanks for the details, now I feel less like doing guesswork! :slight_smile:

Ben