Redboard Artemis Nano ArduinoBLE Example Problem

Redboard Artemis Nano

SparkFun Apollo3 Boards version 2.2.1

ArduinoBLE.h version 1.3.2

I’m attempting to run the ArduinoBLE/Peripheral/LED example.

The example compiles (with what appear to be warnings) and then uploads.

At runtime I get the following error.

++ MbedOS Error Info ++

Error Status: 0x80FF013D Code: 317 Module: 255

Error Message: Fault exception

Location: 0x111E0

Error Value: 0x10006018

Current Thread: main ID: 0x100045B8 Entry: 0x294A5 StackSize: 0x1000 StacMem: 0x10006078 SP: 0x10007020

At an mbed.com link referenced in the error I find the following:

ERROR CODE

HardFault exception

Cortex-M HardFault exception has occurred. Please see https://os.mbed.com/docs/latest/tutoria … -dump.html for more info.

Thanks in advance for any help with this.

I have just tried to compile and it works unmodified. Please post the sketch as you have it. (use full Editor & Preview and use the </> around your code to keep the sketch readable)

Thanks Paul. Here is the code.

< LED

This example creates a Bluetooth® Low Energy peripheral with service that contains a

characteristic to control an LED.

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.

You can use a generic Bluetooth® Low Energy central app, like LightBlue (iOS and Android) or

nRF Connect (Android), to interact with the services and characteristics

created in this sketch.

This example code is in the public domain.

*/

#include <ArduinoBLE.h>

BLEService ledService(“19B10000-E8F2-537E-4F6C-D104768A1214”); // Bluetooth® Low Energy LED Service

// Bluetooth® Low Energy 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

void setup() {

Serial.begin(9600);

while (!Serial);

// set LED pin to output mode

pinMode(ledPin, OUTPUT);

// begin initialization

if (!BLE.begin()) {

Serial.println(“starting Bluetooth® Low Energy module failed!”);

while (1);

}

// set advertised local name and service UUID:

BLE.setLocalName(“LED”);

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(“BLE LED Peripheral”);

}

void loop() {

// listen for Bluetooth® Low Energy 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()) {

// if the remote device wrote to the characteristic,

// use the value to control the LED:

if (switchCharacteristic.written()) {

if (switchCharacteristic.value()) { // any value other than 0

Serial.println(“LED on”);

digitalWrite(ledPin, HIGH); // will turn the LED on

} else { // a 0 value

Serial.println(F(“LED off”));

digitalWrite(ledPin, LOW); // will turn the LED off

}

}

}

// when the central disconnects, print it out:

Serial.print(F("Disconnected from central: "));

Serial.println(central.address());

}

} >

just tested. works without problems. Give that same code another try for the Nano

Ps.

For a next post of code first press on Full Editor & Preview.

Then select the code and press on the bottom as in the screen attached. With Preview you can see the code before it is send.

Might be a bad board. I had same issue a couple of yeas ago.

Old post:

I’m on Windows10 but but other stats are same ( 1.8.13, 1.13, 2.0.2). I have 2 Nano boards. One board would not function and registered a hardware fault that occasionally printed the whole error message but usually just partial prints to Termite emulator (must wait a couple of seconds before connecting emulator to see anything). I was VERY frustrated. Could not even get Blinky example to run (no ble). Tried second board and vuallah … Blinky WORKED. Tried BLE - Worked. Sorry, no MAC here but one of my Nano boards definately works completely with BLE. May be some production qc issues with Nano , or maybe I just killed something at some point with the first board. First board did work completely with 1.0.30 Arduino Core. Very strange.

Failed again with same hard fault error at runtime. I added a Serial.print line after the call to BLE.begin() after the “if” function. Neither the “failed” statement in the “if” function or my line printed on the Serial monitor before I received the hard fault error. Partial code follows.

#include <ArduinoBLE.h>

BLEService ledService("19B10000-E8F2-537E-4F6C-D104768A1214"); // Bluetooth® Low Energy LED Service

// Bluetooth® Low Energy 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

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

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

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

    while (1);
  }

  Serial.print("Bluetooth module started");    // I added this line

maybe KHE is right… it might be a board issue.

Try to set

Serial.println("Bluetooth module started"); 

instead of

Serial.print("Bluetooth module started"); // I added this line

if that does not work : re-install the ArduinoBLE library. and try again. just to make sure.

I reformatted my print statement as you recommended Paul and got the same result. I then uninstalled and reinstalled ArduinoBLE.h 1.3.2 and again got the same result. Since you aren’t having any problem with your Nano it must be a problem with my board. I’ll contact SparkFun to see if there is any remedy available to me.

Thanks for your help Paul and KHE, thanks to you as well. Looks like you were right.

I got a new Artemis Nano and BLE is working like it should. I definitely had a hardware problem on my first Nano.

Good to hear and appreciate the update / feedback.