Go Down

Topic: Help with project using ESP32 devkit v1 and arduino with HC-05 module (Read 318 times) previous topic - next topic

gtheis

Hello,

I need to make this project work or at least show why it can't work as of right now. We have 2 arduinos uno, 2 HC-05 and 2 ESP32 devkit v1 to work with. The motor indication system that we'll use are already working on both arduino uno and ESP32 devkit.

The objective is to make a guidance system without using GPS for a building. The user receives an wearable BLE device that should broadcast the room the user want to go. A device fixed in the wall should be able to read the broadcast and extract the room from it. By knowing the room the system will indicate the direction. The shows a simplified and rushed proposition of the system.

We wanted to use the ESP32 as broadcaster and the HC-05+Arduino as listener, but we can easily use another ESP32 as llistener. The problem is how to create the broadcast and listen+identify the message from it and how to create multiple reconfigurable messages to it.

Apperently the image did not load (I don't know why, here is the link to it: http://tinypic.com/view.php?pic=iwsopy&s=9)

Thank you in advance and let me know if this is not very clear!

gtheis

As of right now I decided to use two ESP32 devkits using their examples (scan and server) the problem is how to identify the name of the server module.

I can get open the serial monitor and see a response from our "server" that is like this

Advertised Device: Name: P130, Address: 80:7d:3a:fd:df:9e, serviceUUID: 4fafc201-1fb5-459e-8fcc-c5c9c331914b, txPower: 3

But I don't understand how I could extract a variable (a string) from this. I wanted to extrac "P130" in this example. The code of the example code is here:


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

#include <BLEDevice.h>
#include <BLEUtils.h>
#include <BLEScan.h>
#include <BLEAdvertisedDevice.h>

int scanTime = 30; //In seconds
BLEScan* pBLEScan;

class MyAdvertisedDeviceCallbacks: public BLEAdvertisedDeviceCallbacks {
    void onResult(BLEAdvertisedDevice advertisedDevice) {
      Serial.printf("Advertised Device: %s \n", advertisedDevice.toString().c_str());
    }
};

void setup() {
  Serial.begin(115200);
  Serial.println("Scanning...");

  BLEDevice::init("");
  pBLEScan = BLEDevice::getScan(); //create new scan
  pBLEScan->setAdvertisedDeviceCallbacks(new MyAdvertisedDeviceCallbacks());
  pBLEScan->setActiveScan(true); //active scan uses more power, but get results faster
  pBLEScan->setInterval(100);
  pBLEScan->setWindow(99);  // less or equal setInterval value
}

void loop() {
  // put your main code here, to run repeatedly:
  BLEScanResults foundDevices = pBLEScan->start(scanTime, false);
  Serial.print("Devices found: ");
  Serial.println(foundDevices.getCount());
  Serial.println("Scan done!");
  pBLEScan->clearResults();   // delete results fromBLEScan buffer to release memory
  delay(2000);
}

I know the string that is printed there is in the class:

class MyAdvertisedDeviceCallbacks: public BLEAdvertisedDeviceCallbacks {
    void onResult(BLEAdvertisedDevice advertisedDevice) {
      Serial.printf("Advertised Device: %s \n", advertisedDevice.toString().c_str());
    }
};


But I wanted to create a string variable like myString = Name: P130 and then process this data in my loop(){}

Any suggestion how to find it?

gtheis

I have tried to understand the source codes from the library I have been using that are available here https://github.com/nkolban/ESP32_BLE_Arduino/tree/master/src but I can't understand still how I can extract a variable to process with it

gtheis

To future reference I was able to do it by using this: https://forum.arduino.cc/index.php?topic=571087.0

Go Up