ESP32 BLE Range


#1

Hi,

I have a ESP32 flashed with Openmqttgateway to read Mijia Temperature and humiduty sensor and convert to MQTT. After weeks triing to compile and flash, finally did it…But now the Bluetooth range is only 1 or 2 meters…
There is som way to change the power of BLE in code and how to do it???

Thanks

Ricardo Santos


#2

Hi,

This is strange that you get a so poor range, could you indicate the ESP32 board used? Do you have other board to test with your hum & temp sensor?


#3

hi,

Thanks for quick answer.
The board is https://www.banggood.com/ESP32-Development-Board-WiFiBluetooth-Ultra-Low-Power-Consumption-Dual-Cores-ESP-32-ESP-32S-Board-p-1109512.html?rmmds=cart_middle_products&cur_warehouse=CN

I dont have other board… But the sensor works with raspberry pi at 10 meters. I wanted to use this board because the raspberry cant reach the 1st floor. I have read that esp32 has several ble tx power…

Thanks


#4

This discussion talks about power and range. I cant figured out if it aplies to openmqttgateway…


#5

Thanks for the info, you can try to add :

esp_err_t errRc=esp_ble_tx_power_set(ESP_BLE_PWR_TYPE_DEFAULT,ESP_PWR_LVL_P9);
esp_ble_tx_power_set(ESP_BLE_PWR_TYPE_ADV, ESP_PWR_LVL_P9);
 esp_ble_tx_power_set(ESP_BLE_PWR_TYPE_SCAN ,ESP_PWR_LVL_P9); 

Into ZgatewayBT.ino


#6

Ok.

I will try that next week, now i cant…

Thanks


#7

Sorry cant do it, dont know were to put the code…
Coud you help me??


#8

Try maybe after this line :


#9

Hi, this is my first post so i would like to congratulate for the great idea!
I also experienced the same issue between ESP32 and ble 4.0 keyrings. Measured signal level is -80 at 1 meter of distance.
I tried as you suggested to include the esp_ble_tx_power_set but the configuration i had to set is ESP_PWR_LVL_P7 because with ESP_PWR_LVL_P9 i got the error:

\ZgatewayBT.ino: In function ‘void setupBT()’:

ZgatewayBT:129:73: error: ‘ESP_PWR_LVL_P9’ was not declared in this scope

     esp_err_t errRc = esp_ble_tx_power_set(ESP_BLE_PWR_TYPE_DEFAULT,ESP_PWR_LVL_P9);

anyway also with the P7 setup i didn’t experience any change in quality of signal (still between -70 or -80).

The purpose of my implementation is to set up a reliable presence detection to my openhab.

I configured:

#define TimeBtw_Read 500 //define the time between 2 scans
#define Scan_duration 10 //define the time for a scan

And i configured my openhab to set the person as “not at home” if i dont recieve updates for 2 minutes from the mqtt item.
Unfortunately it still looks like i got frequent offline messages. What can i do to improve my application?
Thank you!


#10

Same range , no improove…

also saw this…


#11

In in this case if we take this into account :

BLEDevice::setPower(powerLevel)

/**
 * @brief Set the transmission power.
 * The power level can be one of:
 * * ESP_PWR_LVL_N14
 * * ESP_PWR_LVL_N11
 * * ESP_PWR_LVL_N8
 * * ESP_PWR_LVL_N5
 * * ESP_PWR_LVL_N2
 * * ESP_PWR_LVL_P1
 * * ESP_PWR_LVL_P4
 * * ESP_PWR_LVL_P7
 * @param [in] powerLevel.
 */

Add after this line :

This code : BLEDevice::setPower(ESP_PWR_LVL_P7) ;


#12

Thank you!
Done, still between -70 and -80 so no change at all :frowning:


#13

Could you indicate where does these values of 70 and 80 comes from ?


#14

Hello, between - 70 and - 80 is the signal value that I read on mqtt for my ble keyrings, when they are 1-2 meters from my esp32. If I go more far I start to not discover anymore the devices


#15

No improvement. the range is only 2-3 meters.
Maybe its my hardware…

Do you have hardware that recomen? with guarantee better range in Bluetooth??

Thanks


#16

which hardware do you have?
This is mine:


#17

this is mine…


#18

I have the same board, i m going to do some range test and post the results.


#19

Hello any update on this issue? Thank you!


#20

Hello,i didn’t had the time yet unfortunately. I will keep you updated