Decrease distance between ESP32 and Android device.

ivanicsjozsef94
Posts: 1
Joined: Tue Aug 18, 2020 4:14 pm

Decrease distance between ESP32 and Android device.

Postby ivanicsjozsef94 » Tue Aug 18, 2020 4:48 pm

Hi,

I just bought a NodeMCU-ESP32 board. I'm creating an Android app that can connect to the board via BLE. After a successfull connection, the app sends a key to the board that checks if it is valid or not and sends back the response to the app.
It currently works fine in a few meters but I want to decrease the range between devices. I only want those Android devices will be able to communicate with the ESP32 that are in a few centimeters away from it. So, I set the power in the source code but it seems not working. The signal strength is the same. Is there any other way to descrease the power of BLE?

Here is the code:

Code: Select all

  BLEDevice::init("MyESP32");
  BLEDevice::setPower(ESP_PWR_LVL_N14, ESP_BLE_PWR_TYPE_ADV);

  BLEServer *pServer = BLEDevice::createServer();
  pServer->setCallbacks(new MyServerCallbacks());

  BLEService *pService = pServer->createService(SERVICE_UUID);

  BLECharacteristic *pCharacteristic = pService->createCharacteristic(
                                         CHARACTERISTIC_UUID,
                                         BLECharacteristic::PROPERTY_READ |
                                         BLECharacteristic::PROPERTY_WRITE
                                       );

  pCharacteristic->setCallbacks(new MyCallbacks());

  pCharacteristic->setValue("Hello World");
  pService->start();

  BLEAdvertising *pAdvertising = pServer->getAdvertising();
  pAdvertising->start();
Thanks,

Who is online

Users browsing this forum: No registered users and 74 guests