Go Down

Topic: How do I write directly from the s monitor and send it to the smartphone (BLE)? (Read 152 times) previous topic - next topic

Lu2829

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.

Code: [Select]
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();
}

jremington

Quote
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?

Lu2829

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.

jremington

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.

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


Lu2829

#5
Jun 14, 2019, 11:20 pm Last Edit: Jun 14, 2019, 11:25 pm by Lu2829
How do I enter text in the text box to the left of the Send button?


UKHeliBob

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
Please do not send me PMs asking for help.  Post in the forum then everyone will benefit from seeing the questions and answers.

Lu2829

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

jremington


Go Up