ArduinoBLE libarary with Nano 33 IOT 'No Characteristic Available' Error in LightBlue App

Hello,

I have a simple BLE framework here that has worked previously with a Seeeduino XIAO BLE nRF52840. I was able to set up a service and a characteristic on that uC and transmit data via the characteristic to a free app called LightBlue that can easily detect and connect to peripheral bluetooth devices within range. On the app, once the peripheral device/uC is connected the UUID of the advertised service can easily be located and once clicked on one can click the 'read' button to read any transmitted values from the code [sent via bleCharacteristic.writeValue() ]. I am currently using a Nano 33 IOT (SAMD21 ARM Cortex) and am able to connect to the device and everything with more or less the same code but under the service UUID on the app I see 'No characteristic available', and I am unable to transmit any data even though I am writing data to it. Is there any way around this issue? Any help, suggestions on what to do or what exact framework I should use for BLE would be greatly appreciated!

Thank you!

Here is the code I am using. All bluetooth related functions are defined as in the ArduinoBLE Library. I am suspicious that there could be something wrong with 'BLELongCharacteristic' in that I would think the best option would be to use 'BLECharacteristic' but I have had problems getting this (latter) function to work.

#include <ArduinoBLE.h>
#include <stdio.h>

//BLUETOOTH SETUP
//Peripheral Device Setup: 
//Create Service, assign 128-bit custom UUID
BLEService Service1("ec70e16f-ca8b-4c18-9118-dcdd339e5288"); 
 
//Create Bluetooth® Characteristic(s) for the Service. Same 128-bit UUID, read and writable by central
BLELongCharacteristic Char1("ec70e16f-ca8b-4c18-9118-dcdd339e5288", BLERead | BLEWrite | BLENotify);

void setup() {
  Serial.begin(9600); 
  while (!Serial);
  // begin initialization
  if (!BLE.begin()) {
    Serial.println("BLE Connection Failed!");
    while (1);
  }
 
  //Set advertised local name and service UUID:
  BLE.setDeviceName("Arduino Nano"); //Look for this name on Central device
  BLE.setLocalName("Arduino Nano");
  
  //Add services
  BLE.addService(Service1); 
  BLE.setAdvertisedService(Service1);
  
  //Add the characteristic to the service
  Service1.addCharacteristic(Char1); 

  // set the initial value for the characeristic:
  Char1.writeValue(0);
 
  // start advertising
  BLE.advertise();
  Serial.println("Begin Advertising...");
}
 
void loop() {
  //Wait to connect to BLE central device:
  BLEDevice central = BLE.central();
 
  if (central) {
    Serial.print("Connected to central: ");
    Serial.println(central.address()); // print the central's MAC address:

  while (central.connected()) { 
    
      char Ser = Serial.read();
      if (Serial.read() != -1) {
      Serial.print("Received: ");
      Serial.println(Ser); 
      Char1.writeValue(Ser); } //BLE
    }
    // when the central disconnects, print it out:
    Serial.print(F("Disconnected from central: "));
    Serial.println(central.address());
  }
}

If you look at the library examples you will see that the order of adding the service and characteristic is reversed from your sketch. The Serial input section also can use some revision. This modification of your sketch shows and reads the characteristic with Light Blue.

#include <ArduinoBLE.h>
#include <stdio.h>

//BLUETOOTH SETUP
//Peripheral Device Setup:
//Create Service, assign 128-bit custom UUID
BLEService Service1("ec70e16f-ca8b-4c18-9118-dcdd339e5288");

//Create Bluetooth® Characteristic(s) for the Service. Same 128-bit UUID, read and writable by central
BLELongCharacteristic Char1("ec70e16f-ca8b-4c18-9118-dcdd339e5288", BLERead | BLEWrite | BLENotify);

void setup()
{
  Serial.begin(9600);
  while (!Serial)
    ;
  // begin initialization
  if (!BLE.begin())
  {
    Serial.println("BLE Connection Failed!");
    while (1)
      ;
  }

  //Set advertised local name and service UUID:
  BLE.setDeviceName("Arduino Nano");  //Look for this name on Central device
  BLE.setLocalName("Arduino Nano");

  //Add services
  //BLE.addService(Service1);
  BLE.setAdvertisedService(Service1);

  //Add the characteristic to the service
  Service1.addCharacteristic(Char1);

  BLE.addService(Service1);

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

  // start advertising
  BLE.advertise();
  Serial.println("Begin Advertising...");
}

void loop()
{
  //Wait to connect to BLE central device:
  BLEDevice central = BLE.central();

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

    while (central.connected())
    {
      if (Serial.available())
      {

        char Ser = Serial.read();
        //if (Serial.read() != -1) {
        Serial.print("Received: ");
        Serial.println(Ser);
        Char1.writeValue(Ser);  //} //BLE
      }
    }
    // when the central disconnects, print it out:
      Serial.print(F("Disconnected from central: "));
      Serial.println(central.address());
  }
}

I also have Xiao BLE nrf52.
If I use arduinoBLE library what version of board should I choose in arduino ide ?
1.0.0 or 2.6.1 ? does this matter ?

Hi.
Can we talk about the UUID?
It is the same for service and characteric (and a mess to me). A friend told me it is just longer during bonding with BLE App and the code actually works.

Excluding the use of official UUID (I tried some for the fun in my sketch but no appelation falls perfectly in my needs), what could be the proper way to code UUID? use a generator for each?

thanks.

I do not understand the consequences of having the same UUID for the service and characteristic. i just modified the original posters sketch so that it would function properly.

what could be the proper way to code UUID? use a generator for each?

Yes.

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