How do I write directly from the s monitor and send it to the smartphone (BLE)?

I connected my esp32 via Bluetooth (BLE) to my iphone. And I already can send messages form the iPhone to the arduino serial monitor, but the problem is I don't know how to do it the other way; by that, I mean, that I don't know how to send a string from the Serial Monitor to my iPhone. To get the messages I am using an app called BLE Scanner on my iPhone. I would appreciate your point of view.

class MyCallbacks: public BLECharacteristicCallbacks {
    void onWrite(BLECharacteristic *pCharacteristic) {
      std::string value = pCharacteristic->getValue();

      if (value.length() > 0) {
        Serial.print("Respuesta: ");


        for (int i = 0; i < value.length(); i++)
          Serial.print(value[i]);
             Serial.println();
      }



    }


};

void setup() {
  Serial.begin(115200); 
  BLEDevice::init("yoESP32");
  BLEServer *pServer = BLEDevice::createServer();
  BLEService *pService = pServer->createService(SERVICE_UUID);
  BLECharacteristic *pCharacteristic = pService->createCharacteristic(
                                         CHARACTERISTIC_UUID,
                                         BLECharacteristic::PROPERTY_READ |
                                         BLECharacteristic::PROPERTY_WRITE
                                       );
  pCharacteristic->setCallbacks(new MyCallbacks());
  pService->start();
  BLEAdvertising *pAdvertising = pServer->getAdvertising();
  pAdvertising->start();
}

how to send a string from the Serial Monitor to my iPhone

The Serial Monitor is a terminal program that runs on a PC or Mac. An Arduino can send data to an instance of a PC Serial Monitor program through the serial port connecting the Arduino and the PC .

What do you actually want to send to the iPhone, and how do you want to do that?

Thank you for answering. I only want to send a string or a hex from the computer to the iphone using BLE with the esp32. But I don't know how to do that. I only know how to do it the other way: from the iphone to the computer, not from the arduino to the iphone.

Most Bluetooth modules look like a serial port connection to the Arduino. You send serial data out by using Serial.print(), just like you would to the serial monitor program. With Android, I use a bluetooth terminal program to receive the data from the Arduino.

This phrase doesn't make sense to me. What is "the computer"? The ESP32 is not an Arduino, but it can be programmed using the Arduino IDE.

send a string or a hex from the computer to the iphone using BLE with the esp32.

Thank you :slight_smile:

How do I enter text in the text box to the left of the Send button?

Click in the text box, enter your text then click on Send or press return. The text entered will be sent to the Arduino over the Serial link.

I suspect that you really mean how do you use the text entered. This may help Serial input basics - updated

But if I click in the text box and send the text, it won't appear.

Where do you think the text is supposed to appear?