BLE Central device cannot retrieve characteristic

Device(s): Arduino Nano 33 IoT (x2)

I am attempting to create a “wireless relay” which I hope will behave essentially the same os the LED/LEDcontrol examples that are included with the ArduinoBLE library, except that the roles will be reversed: the peripheral will have the switch input and the central will receive the notification that the switch has been triggered and output a signal to a PLC (“i.e. turn on the LED”).

I am hung up on getting the central device to recognize/retrieve the characteristic from the peripheral. I cannot get the central to retrieve the characteristic UUID, let alone subscribe/listen for an updated value.

I have reduced the code for both the central and peripheral to simply try to connect and discover the characteristic from the peripheral.

Reduced CENTRAL code:

/*
  Central
*/

// ArduinoBLE - Version: Latest 
#include <ArduinoBLE.h>

const int PERIPHCONNPIN = 13;     // status of connection to peripheral 

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

  if (!BLE.begin()){
    Serial.println("starting BLE failed!");
    while (1);
  }
  
  Serial.println("BLE Central");
  
  Serial.println("Scanning for peripheral...");
  // start scanning for peripheral
  BLE.scanForUuid("19b10000-e8f2-537e-4f6c-d104768a1214");
}

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

  if (peripheral) {
    // discovered a peripheral, print out address, local name, and advertised service
    Serial.print("Found Device: ");
    Serial.println(peripheral.address());
    Serial.print("Device Name:");
    Serial.print(" '");
    Serial.print(peripheral.localName());
    Serial.println("' ");
    Serial.print("Service UUID: ");
    Serial.println(peripheral.advertisedServiceUuid());
    Serial.println();

    //check peripheral local name
    if (peripheral.localName() != "Peripheral") {
      Serial.println("Peripheral not found!");
      return;
    }
    
    // stop scanning
    BLE.stopScan();

    discoverCharacteristic(peripheral);

    // peripheral disconnected, start scanning again
    Serial.println("Scanning for peripheral...");
    BLE.scanForUuid("19b10000-e8f2-537e-4f6c-d104768a1214");
  }
}

void discoverCharacteristic(BLEDevice peripheral) {
  
  //connect to peripheral
  Serial.println("Connecting ...");
  if (peripheral.connect()) {
    Serial.println("Connected to peripheral");
  } else {
    Serial.println("Failed to connect!");
    Serial.println();
    return;
  }
  
  // discover peripheral attributes
  Serial.println("Discovering attributes ...");
  if (peripheral.discoverAttributes()) {
    Serial.println("Attributes discovered");
  } else {
    Serial.println("Attribute discovery failed!");
    peripheral.disconnect();
    return;
  }
  
  BLECharacteristic characteristic = peripheral.characteristic("19B10001-E8F2-537E-4F6C-D104768A1214");
  
  if (!characteristic){
    Serial.println("Peripheral does NOT have relay characteristic!");
    Serial.println();
    peripheral.disconnect();
    return;
  }else {
    Serial.println(characteristic.uuid());
  }
  
  while (peripheral.connected()) {
    // while the peripheral is connected
    
    //blink the built in LED
    digitalWrite(PERIPHCONNPIN, HIGH);
    delay(1000);
    digitalWrite(PERIPHCONNPIN, LOW);
    delay(1000);
  }
  
  Serial.println("Peripheral disconnected");
}

Reduced PERIPHERAL code

/*
  Peripheral
*/

// ArduinoBLE - Version: Latest 
#include <ArduinoBLE.h>

BLEService service("19B10000-E8F2-537E-4F6C-D104768A1214");

BLEByteCharacteristic characteristic("19B10001-E8F2-537E-4F6C-D104768A1214", BLERead | BLEWrite | BLENotify);

// constants to set pin numbers:
const int CENTRALCONNPIN = 13;    // status of connection to central 
//byte buttonValue = 0x00;

void setup() {
  Serial.begin(9600);
  while (!Serial);
  
  if (!BLE.begin()){
    Serial.println("starting BLE failed!");
    while (1);
  }
  
  // set advertised local name and service UUID:
  BLE.setLocalName("Peripheral");
  BLE.setAdvertisedServiceUuid("19B10000-E8F2-537E-4F6C-D104768A1214");

  // add service 
  BLE.addService(service);
  // add the characteristic to the service
  service.addCharacteristic(characteristic);


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

  // start advertising
  BLE.advertise();

  Serial.println("Peripheral");
  Serial.print("Characteristic UUID = ");
  Serial.println(characteristic.uuid());
  
  // register new connection handler
  BLE.setEventHandler(BLEConnected, blePeripheralConnectHandler);
  // register disconnect handler
  BLE.setEventHandler(BLEDisconnected, blePeripheralDisconnectHandler);
}

void loop() {

  BLEDevice central = BLE.central();
  
  if (central){
    while (central.connected()) {
      //while the central is connected...
      //do stuff
    }
  }
}

//callback functions for connect, disconnect and written characteristic are described below:
void blePeripheralConnectHandler(BLEDevice central) {
  // central connected event handler
  Serial.print(F("Connected event, central: "));
  Serial.println(central.address());
  
  //blink so we know it's connected
  digitalWrite(CENTRALCONNPIN, HIGH);
  delay(100);
  digitalWrite(CENTRALCONNPIN, LOW);
  delay(50);  
  digitalWrite(CENTRALCONNPIN, HIGH);
  delay(100);  
  digitalWrite(CENTRALCONNPIN, LOW);
}

void blePeripheralDisconnectHandler(BLEDevice central) {
  // central disconnected event handler
  Serial.print(F("Disconnected event, central: "));
  Serial.println(central.address());
  
    
  //turn on for half second so we know it's disconnected
  digitalWrite(CENTRALCONNPIN, LOW);
  delay(100);
  digitalWrite(CENTRALCONNPIN, HIGH);
  delay(500);
  digitalWrite(CENTRALCONNPIN, LOW);
}

The resulting serial monitor output for the CENTRAL device:

10:56:32.432 → Scanning for peripheral…
10:56:33.046 → Found Device: 4c:11:ae:c9:7e:3e
10:56:33.046 → Device Name: ‘Peripheral’
10:56:33.046 → Service UUID: 19b10000-e8f2-537e-4f6c-d104768a1214
10:56:33.046 →
10:56:33.046 → Connecting …
10:56:33.249 → Connected to peripheral
10:56:33.249 → Discovering attributes …
10:56:33.826 → Attributes discovered
10:56:33.826 → Peripheral does NOT have relay characteristic!

Again, this is not the full code, just a reduced version to troubleshoot this particular issue.

Any insight is appreciated!