Connecting HM-10 to ESP32

Ok, I'm having a very hard time understanding Bluetooth concepts...
I have an ESP32 (Wemos Lolin32) working with BluetoothSerial library (haven't figured out BLE/BT4.0 yet, but that will come).

Instead of using one of those apps like Serial Bluetooth Monitor where I configured a Macro to send commands, I'd like to move that part to an Arduino with an HM-10 module (clone). But I have no idea of where to start to connect the HM to the ESP.

I understand the ESP32 is an slave and any device can connect to it. That leaves the HM-10 to be the master. How can I make it scan and pair/connect to the ESP32? No luck so far.

//Bluetooth
#include "BluetoothSerial.h" 
//Header File for Serial Bluetooth, will be added by default into Arduino
BluetoothSerial ESP_BT; //Object for Bluetooth


//<----------------VARIABLES---------------->
//BlueTooth
bool finSerial;
uint8_t bufferInput[10];   
byte bufferIndex = 0;


//<------------------SETUP------------------->
void setup() {
    

      Serial.begin(9600); //Start Serial monitor in 9600



    //Bluetooth initialization
    ESP_BT.begin("Lion"); //Name of your Bluetooth Signal
    Serial.println("Bluetooth Device is Ready to Pair");

}

//<------------------LOOP--------------------->
void loop() {
   
    while (ESP_BT.available()) //Check if we receive anything from Bluetooth
    {
        Serial.print("BT Serial available size: ");
        Serial.println(ESP_BT.available());
      
      bufferInput[bufferIndex] = ESP_BT.read();
      
        Serial.print("buffer ");
        Serial.print(bufferIndex);
        Serial.print(": ");
        Serial.println(bufferInput[bufferIndex]);

        bufferIndex++;
      
    }
    
    bufferIndex = 0;
    
}

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