Portenta BLE

Hi All,

Am attempting to get the Portenta communicating via BLE, am having a few adventures, and would appreciate insights into what others see. Bottom line up front I wonder if the ArduinoBLE.h library is compatible with Portenta radio hardware?

My first attempt was to substitute a USB A-C cable and just reuse the Arduino Nano 33 BLE Sense Script/Sketch for a BLE peripheral (I modified it a bit in order to better understand how the script works)

/*

  This example creates a BLE peripheral that blinks an LED when connected to a central BLE device (iPad, iPhone)

  Materials Schedule
   (1 each) Arduino Nano 33 BLE Sense
     https://store.arduino.cc/usa/nano-33-ble-sense-with-headers
   (1 each) Sparkfun Cerberus USB Cable
     https://www.sparkfun.com/products/12016
       
  Assembly
   1.Update Arduino software
     a.Tools->Board->Boards Manager->Arduino nRF528x mbed Core
   2.Attach Cerberus USB Cable to Nano and Laptop
   3.Use Arduino IDE to Select Board and Port         
     a.Tools->Board->Arduino NANO 33 BLE
     b.Tools-Port->/dev/cu.usbmodem14101 (Adafruit NANO 33 BLE)
   4.Use Arduino IDE to Verify/compile & upload program to Nano
     a.Sketch->Verify/Compile
     b.Sketch->Upload
   5.Download BLE App onto iPad or iPhone & Scan for BLE Peripheral
     a. nRF Connect or Bluefruit or Light Blue
     b. Scan for "Nano33ble" or "Arduino"      

  Engineering
   https://www.arduino.cc/en/Guide/NANO33BLESense
     revised 2019/08/17 by SM  
   https://github.com/sandeepmistry
     by Sandeep Mistry
   Arduino 
     File->Examples->ArduinoBLE->Peripheral->LED
   https://github.com/AnchorageBot/YouTube
   https://www.youtube.com/channel/UCDuWq2wFqeVII1KC7grySRg/videos    
     Modified September 2019 by ATS
*/

#include <ArduinoBLE.h>

BLEService ledService("19B10000-E8F2-537E-4F6C-D104768A1214"); // BLE LED Service

// BLE LED Switch Characteristic - custom 128-bit UUID, read and writable by central
BLEByteCharacteristic switchCharacteristic("19B10001-E8F2-537E-4F6C-D104768A1214", BLERead | BLEWrite);

const int ledPin = LED_BUILTIN; // pin to use for the LED
int timerLED = 500;

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

  // set LED pin to output mode
  pinMode(ledPin, OUTPUT);

  // begin initialization
  if (!BLE.begin()) {
    Serial.println("starting BLE failed!");

    while (1);
  }

  // set advertised local name and service UUID:
  BLE.setLocalName("Nano33ble");
  BLE.setAdvertisedService(ledService);

  // add the characteristic to the service
  ledService.addCharacteristic(switchCharacteristic);

  // add service
  BLE.addService(ledService);

  // set the initial value for the characeristic:
  switchCharacteristic.writeValue(0);

  // start advertising
  BLE.advertise();

  Serial.println("Nano33ble Peripheral");
}

void blink()  // Blink the onboard LED
{
  digitalWrite(ledPin, HIGH);   // turn the LED on 
  delay(timerLED);                       
  digitalWrite(ledPin, LOW);    // turn the LED off 
  delay(timerLED);                       
}

void loop() {
  // listen for BLE peripherals to connect:
  BLEDevice central = BLE.central();

  // if a central is connected to peripheral:
  if (central) {
    Serial.print("Connected to central: ");
    // print the central's MAC address:
    Serial.println(central.address());


    // while the central is still connected to peripheral:
    while (central.connected()) {
      blink();
    }

    // when the central disconnects, print it out:
    Serial.print(F("Disconnected from central: "));
    Serial.println(central.address());
  }
}

This script fails on the Portenta; reading the serial port at 9600 baud reveals the message “starting BLE failed!”

Assembly

  • 1.Update Arduino software*
  • a.Tools->Board->Boards Manager->Arduino Mbed Enabled Boards->Update*
  • 2.Attach USB Cable to both Portenta and Laptop*
    1. Use Arduino IDE to Select Board and Port *
  • a.Tools->Board->Arduino Mbed OS Boards (nRF52840/STM32H747)->Arduino Portenta H7 (M7 Core)*
  • b.Tools-Port->/dev/cu.usbmodem14101 (Arduino Portenta H7 (M7 Core)) *
  • 4.Use Arduino IDE to Verify/compile & upload program to Portenta*
  • a.Sketch->Verify/Compile*
  • b.Sketch->Upload*
    1. Download BLE App onto iPad or iPhone & Scan for BLE Peripheral*
  • a. nRF Connect or Bluefruit or Light Blue*
  • b. Scan for “Arduino” or “Portenta BLE”*

Next I pulled the material specifications sheets for the radio modules for both the Nano 33 BLE Sense and the Portenta from the Arduino web page in order to conduct a compare/contrast review.

nRF52840 for the Nano 33 BLE Sense

Murata 1DX dual WiFi 802.11b/g/n 65 Mbps and Bluetooth 5.1 BR/EDR/LE for the Portenta

Finally I reviewed the available documentation for the ArduinoBLE.h library

https://www.arduino.cc/en/Reference/ArduinoBLE

https://github.com/arduino-libraries/ArduinoBLE

Is there a way to adapt the ArduinoBLE.h library to support the Portenta, or is another library on the way?

Same issue here it seems. BLE fails to initialise. The ArduinoBLE library lists the Portenta as compatible.

https://www.arduino.cc/reference/en/libraries/arduinoble/

Let's hope a full set of libraries and documentation is on the way.

It seems the device is not getting beyond this point in BLELocalDevice::begin()

if (HCI.readLocalVersion(hciVer, hciRev, lmpVer, manufacturer, lmpSubVer) != 0) {
end();
return 0;
}

More specifically within HCI.readLocalVersion,

int result = sendCommand(OGF_INFO_PARAM << 10 | OCF_READ_LOCAL_VERSION);

is returning -1;

But that is the extent of my detective abilities.

Hi all! It might not cover your complete use case, but we just posted a simple tutorial on how to do BLE with the Portenta:
https://arduino-pro-website-dev.arduino.cc/pro/tutorials/portenta-h7/por-ard-ble
Let me know if it helps.

sbhklr:
Hi all! It might not cover your complete use case, but we just posted a simple tutorial on how to do BLE with the Portenta:
https://arduino-pro-website-dev.arduino.cc/pro/tutorials/portenta-h7/por-ard-ble
Let me know if it helps.

Hey sbhklr,

Unfortunately my Portenta is still failing to start BLE with mbed 1.2.2 and BLE 1.1.3.

EDIT: Just tested with latest core-mbed, core-API and ArduinoBLE all taken from github. BLE is now working with this setup!

Thanks for working on and posting the link to the BLE Tutorial sbhklr !

Thanks for the observations and sharing a way to get the tutorial up and running snugglekittens !

Not quite there, insights would be appreciated

… here is the path I followed:

Copy/paste the code from the tutorial link posted by sbhklr into the Arduino IDE and save the file

https://arduino-pro-website-dev.arduino.cc/pro/tutorials/portenta-h7/por-ard-ble

Round One - Check and Use Installed Library and Board versions

Check Arduino IDE version 1.8.13
Arduino->About Arduino

Check ArduinoBLE Library version 1.1.13
Arduino->Tools->Manage Libraries->Filter your search

Check Arduino mbed-enabled Boards version 1.2.2
Arduino->Tools->Board-Boards Manager->Filter your search

Upload & Run BLE tutorial
Portenta blinks Red LED
Serial Terminal shows “starting BLE Failed!”

Round Two - Install Github ArduinoBLE Library

Remove ArduinoBLE Library version 1.1.13
Mac File Manager->Arduino->Libraries->Highlight ArduinoBLE
->Right Click/Move to Trash

Goto Github and get latest ArduinoBLE library

Note that the file was last updated two days ago, version number has not yet changed
Code->Download Zip

Upload Zip File to Arduino IDE
Arduino->Sketch->Include Library->Add .Zip Library->Downloads

Restart Arduino IDE

Upload & Run BLE tutorial
Portenta blinks Red LED
Serial Terminal shows “starting BLE Failed!”

Round Three - Install Fresh Copy of Portenta Boards file from Arduino Board Manager

Goto Pert’s post (#9) in the Arduino Forum
Arduino Forum>Products>Portenta>Portenta H7 doesn’t (or maybe it does) get recognized by Windows

Follow Pert’s instructions for removing and reinstalling the boards file

Restart Arduino IDE

Upload & Run BLE tutorial
Portenta blinks Red LED
Serial Terminal shows “starting BLE Failed!”

Round Four - Attempt to Install Github version of Board File

Remove Arduino mbed-enabled Boards version 1.2.2
Arduino->Tools->Board-Boards Manager->Filter your search
->Arduino mbed-enabled Boards version 1.2.2
->Remove

Goto Github and get latest Arduino mbed-enabled Boards file

GitHub->Search->Arduino

Look around …

Note that the file was last updated two days ago, version number has not yet changed
Code->Download Zip

Upload Zip File to Arduino IDE
Arduino->Sketch->Upload File>Downloads

Hmmm … got the download file but am unsure how to successfully install all the files

This is what I did.

  • Install Portenta board from Arduino IDE.

  • Replace all the board files (for example in your 1.2.2 folder) with the ones from github (GitHub - arduino/ArduinoCore-mbed)

The 1.2.2 folder is in /Users/yourusername/Library/Arduino15/packages/arduino-beta/hardware/mbed on mac. There will be an equivalent folder somewhere on PC, usually /Users/yourusername/AppData/Local/Arduino15/packages/arduino-beta/hardware/mbed.

I'm guessing it won't be too long before these fixes make it into a mainstream release.

We improved the BLE handling lately. Those changes might solve your problem. We have yet to package a release for both the core and the BLE library but if you want you can use the latest version from

GitHub - arduino/ArduinoCore-mbed and
GitHub - arduino-libraries/ArduinoBLE: ArduinoBLE library for Arduino to see if it works for you. The corresponding PRs are here:

[portenta] Send service pack updates through mbed initialization by Polldo · Pull Request #111 · arduino-libraries/ArduinoBLE · GitHub and
https://github.com/arduino/ArduinoCore-mbed/pull/49

Thanks for the insights snugglekittens

Appreciate you and the team updating everything sbhklr

Updated the M7 core
Tools->Boards Manager->
removed the depreciated Portenta board software
installed the updated Portenta board software

...next used the Arduino Portenta H7 Bootloader tutorial
https://www.arduino.cc/pro/tutorials/portenta-h7/por-ard-bl

... and was then able to run the Arduino Portenta H7 BLE tutorial using the Light Blue App
https://www.arduino.cc/pro/tutorials/portenta-h7/por-ard-ble