# Peripheral does not have a characteristic

**URL:** <https://forum.arduino.cc/t/peripheral-does-not-have-a-characteristic/1381593>\
**Category:** Programming\
**Created:** [May 15, 2025, 1:03am UTC](https://forum.arduino.cc/t/peripheral-does-not-have-a-characteristic/1381593 "2025-05-15T01:03:02Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![mfusco](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/mfusco/32/1098565_2.png) [@mfusco](https://forum.arduino.cc/u/mfusco)\
**Post date:** [May 15, 2025, 1:03am UTC](https://forum.arduino.cc/t/peripheral-does-not-have-a-characteristic/1381593/1 "2025-05-15T01:03:02Z")

</div>

With the sketches below, "Peripheral does not have a characteristic" prints from the Central sketch. The characteristic is the same in both sketches so I'm unsure as to why it's not working. Any help would be greatly appreciated. Thank you.

```arduino
#include <ArduinoBLE.h>
#include <Wire.h>
#include "SparkFun_Qwiic_Joystick_Arduino_Library.h" //Click here to get the library: http://librarymanager/All#SparkFun_joystick

JOYSTICK joystick; //Create instance of this object

int x, y;
int output[2];

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

  BLE.scanForUuid("19B10000-E8F2-537E-4F6C-D104768A1214");

  pinMode(10, OUTPUT);

  if(joystick.begin() == false) {
    Serial.println("Joystick does not appear to be connected. Please check wiring. Freezing...");
    while(1);
  }
}

void loop() {
  BLEDevice peripheral = BLE.available();

  if (peripheral) {
    Serial.print("Found ");
    Serial.print(peripheral.address());
    Serial.print(" '");
    Serial.print(peripheral.localName());
    Serial.print("' ");
    Serial.print(peripheral.advertisedServiceUuid());
    Serial.println();

    if (peripheral.localName() != "Alvik") {
      return;
    }

    BLE.stopScan();

    BLECharacteristic directionCharacteristic = peripheral.characteristic("19B10001-E8F2-537E-4F6C-D104768A1214");

    //Serial.println("Characteristic: " + peripheral.characteristic("19B10001-E8F2-537E-4F6C-D104768A1214"));

    if (!directionCharacteristic) {
      Serial.println("Peripheral does not have characteristic");
      peripheral.disconnect();
      return;
    } else if (!directionCharacteristic.canWrite()) {
      Serial.println("Peripheral does not have a writable characteristic!");
      peripheral.disconnect();
      return;
    }

    while (peripheral.connected()) {
      digitalWrite(10, HIGH);
      readJoyStick();

      output[0] = (x / 4) - 15;
      output[1] = (y / 4) - 15;

      directionCharacteristic.writeValue(output, 2);
    }

    BLE.scanForUuid("19b10000-e8f2-537e-4f6c-d104768a1214");
  }
}

void readJoyStick() {
  x = joystick.getHorizontal();
  y = joystick.getVertical();
}

```

```arduino
#include <ArduinoBLE.h>

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

BLEByteCharacteristic characteristic("19b10001-e8f2-537e-4f6c-d104768a1214", BLERead | BLEWrite);

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

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

    while (1);
  }

  BLE.setLocalName("Alvik");
  BLE.setAdvertisedService(joystick);

  joystick.addCharacteristic(characteristic);

  BLE.addService(joystick);

  characteristic.writeValue(0);

  BLE.advertise();

  Serial.println("Alvik Peripheral");
}

void loop() {
  BLEDevice central = BLE.central();

  if (central) {
    Serial.print("Connected to central: ");
    
    Serial.println(central.address());

    while (central.connected()) {
      if (characteristic.written()) {
        Serial.println(characteristic.value());
      }
    }

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

```

---

<div class="post-metadata">

**Author:** ![xfpd](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/xfpd/32/1120236_2.png) [@xfpd](https://forum.arduino.cc/u/xfpd)\
**Post date:** [May 15, 2025, 2:35am UTC](https://forum.arduino.cc/t/peripheral-does-not-have-a-characteristic/1381593/2 "2025-05-15T02:35:14Z")

</div>

> [@mfusco](#):
>
> why it's not working

```arduino
directionCharacteristic

```

The value of this is zero, causing the output. Find the source of this.

---

<div class="post-metadata">

**Author:** ![cattledog](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/cattledog/32/217816_2.png) [@cattledog](https://forum.arduino.cc/u/cattledog)\
**Post date:** [May 15, 2025, 3:05am UTC](https://forum.arduino.cc/t/peripheral-does-not-have-a-characteristic/1381593/3 "2025-05-15T03:05:43Z")

</div>

> [@mfusco](#):
>
> "Peripheral does not have a characteristic" prints from the Central sketch.

Look more carefully at the ArduinoBLE.h library Central example sketch "LedControl". With the local name of the peripheral changed, it indeed finds your characteristic.

You have left out needed chunks of the routine related to attribute discovery.

```arduino
  // discover peripheral attributes
  Serial.println("Discovering attributes ...");
  if (peripheral.discoverAttributes()) {
    Serial.println("Attributes discovered");
  } else {
    Serial.println("Attribute discovery failed!");
    peripheral.disconnect();
    return;
  }

```

---

<div class="post-metadata">

**Author:** ![mfusco](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/mfusco/32/1098565_2.png) [@mfusco](https://forum.arduino.cc/u/mfusco)\
**Post date:** [May 19, 2025, 11:44pm UTC](https://forum.arduino.cc/t/peripheral-does-not-have-a-characteristic/1381593/4 "2025-05-19T23:44:21Z")

</div>

I tried adding `switchCharacteristic.writeValue(1);` in `void setup` of the peripheral sketch but that didn't seem to work. The central Arduino does detect the peripheral but for some reason the characteristic is blank. Why would that be?

---

<div class="post-metadata">

**Author:** ![cattledog](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/cattledog/32/217816_2.png) [@cattledog](https://forum.arduino.cc/u/cattledog)\
**Post date:** [May 20, 2025, 12:49am UTC](https://forum.arduino.cc/t/peripheral-does-not-have-a-characteristic/1381593/5 "2025-05-20T00:49:36Z")

</div>

Where in the central sketch do you think you are reading the value?

Look closely at the library example "Peripheral Explorer" for where it reads the characteristic value.

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/system/32/1140315_2.png) [@system](https://forum.arduino.cc/u/system)\
**Post date:** [November 16, 2025, 12:49am UTC](https://forum.arduino.cc/t/peripheral-does-not-have-a-characteristic/1381593/6 "2025-11-16T00:49:38Z")

</div>

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