B4R Question ESP32 serial comunication with bluetooth

Discussion in 'B4R Questions' started by Humberto, Feb 6, 2018.

  1. Humberto

    Humberto Active Member Licensed User

    Can I communicate with cellphone through bluetooth with ESP32 ?

    It´s already implemented ?

    Thanks
     
  2. Erel

    Erel Administrator Staff Member Licensed User

    There is currently no support for the built-in Bluetooth. I'm not sure that it is supported by the underlying ESP32 / Arduino framework. Last time I checked it was not supported.
     
  3. Humberto

    Humberto Active Member Licensed User

    In arduino IDE version 1.85 there ae examples of BLE as a cliente, server

    Bellow is a server example

    Code:
    /*
        Based on Neil Kolban example 
    for IDF: https://github.com/nkolban/esp32-snippets/blob/master/cpp_utils/tests/BLE%20Tests/SampleServer.cpp
        Ported 
    to Arduino ESP32 by Evandro Copercini
    */

    #include <BLEDevice.h>
    #include <BLEUtils.h>
    #include <BLEServer.h>

    // See the following 
    for generating UUIDs:
    // https://www.uuidgenerator.net/

    #define SERVICE_UUID        "4fafc201-1fb5-459e-8fcc-c5c9c331914b"
    #define CHARACTERISTIC_UUID "beb5483e-36e1-4688-b7f5-ea07361b26a8"

    void setup() {
      
    Serial.begin(115200);
      
    Serial.println("Starting BLE work!");

      BLEDevice::init(
    "MyESP32");
      BLEServer *pServer = BLEDevice::createServer();
      
    BLEService *pService = pServer->createService(SERVICE_UUID);
      
    BLECharacteristic *pCharacteristic = pService->createCharacteristic(
                                             CHARACTERISTIC_UUID,
                                             
    BLECharacteristic::PROPERTY_READ |
                                             
    BLECharacteristic::PROPERTY_WRITE
                                           );

      pCharacteristic->setValue(
    "Hello World says Neil");
      pService->start();
      BLEAdvertising *pAdvertising = pServer->getAdvertising();
      pAdvertising->start();
      
    Serial.println("Characteristic defined! Now you can read it in your phone!");
    }

    void loop() {
      // put your main code here, to run repeatedly:
      delay(2000);
    }
     
    Erel likes this.
  4. tigrot

    tigrot Well-Known Member Licensed User

    You could wrap the library or write a few C code lines to use the new capability.
     
  5. Humberto

    Humberto Active Member Licensed User

    I don´t know how to do it.
     
  6. tigrot

    tigrot Well-Known Member Licensed User

    Look at examples for inline c coding. I have not esp32 to test. Sorry. The samples for ble could be a good start point. All you need is a write routine and read routine which generates an event for incoming data.
     
  7. mterveen

    mterveen Member Licensed User

    ble is available, classic bluetooth is not.
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice