No matching function for call to 'BLEStringCharacteristic::read(arduino::String)' [ARDUINO NANO 33 BLE SENSE]

Hello All, Can anyone help me,please! my code error like this:
exit status 1
no matching function for call to 'BLEStringCharacteristic::read(arduino::String)'

and my code is like this

else if(result.classification[7].value > 0.70)
          {
          String data = "Terdeteksi Takut";
          Serial.println(data);
          if(central.connected()) serviceOutput.read(String(data));
          takut();
          }

What type of data does the read() function take ?
It seems that it is not a String

Please post your full sketch so that the context of the problem can be seen

I think the places where you use "String data" like this:

  {
    String data = "Terdeteksi Sedih";
    Serial.println(data);
    if (central.connected()) serviceOutput.read(String (data), 16);
    sedih();
  }

Should be:

  {
    Serial.println( "Terdeteksi Sedih");
    if (central.connected()) serviceOutput.read( "Terdeteksi Sedih", 16);
    sedih();
  }

or maybe:

  {
    char data[] = "Terdeteksi Sedih";
    Serial.println(data);
    if (central.connected()) serviceOutput.read(data, 16);
    sedih();
  }

oke thanks @johnwasser , i will trying it

I have tried but still like this, can you help me,please

BLEService service("42e48f10-e4e8-4c4e-b96e-b61cafdeb2f7");
BLEStringCharacteristic serviceOutput("9A48ECBA-2E92-082F-C079-9E75AAE428B1", BLERead | BLENotify ,100 );

instead of "serviceOutput" should it be "service"?

That says that the .read() function you are calling doesn't take any arguments. I think you are calling the wrong function if you are trying to pass it arguments. Go back to the example you are following and check you code.

I think you should be using serviceOutput.value()

String BLEStringCharacteristic::value(void)
{
  String str;
  int length = BLECharacteristic::valueLength();
  const uint8_t* val = BLECharacteristic::value();

  str.reserve(length);

  for (int i = 0; i < length; i++) {
    str += (char)val[i];
  }

  return str;
}

is there any provision in making the characteristics? or the name, because I tried to make any name and it didn't work, while when I made the name the code could be run, and I also saw how it was written on the internet and someone made serviceOutput

oke i will check my code, looks like I was wrong in the characteristics. thanks @johnwasser

Thanks @cattledog . but , guess where is this i add it in my code? can you help me,please ? I'm a little clueless about this syntax.

I suggest you write a simple test sketch where you set up a String characteristic for a service and write and read between a peripheral and central.

You may get some feel for the syntax from this posting
https://forum.arduino.cc/t/ble-code-to-take-string-input-from-another-bluetooth-enabled-deice/643877/2

oke thanks @cattledog i will trying. :slightly_smiling_face:

Thanks all @UKHeliBob @cattledog @johnwasser @gcjr :blush:, i can run my code and it can be read on nRF Connect. I created a UUID service and its characteristics like this Get Started with Arduino Nano 33 BLE - OKdo . and I changed my code to be like this:

else if(result.classification[1].value > 0.70){
          Serial.print( "Terdeteksi Marah");
          if(central.connected()) greetingCharacteristic.setValue("Terdeteksi Marah");
          marah();

I have permission to delete my code because I am in the process of completing research so that my final project is not detected by copies from the internet