how to set BLE transmit power above 3dB?

ea2020
Posts: 1
Joined: Thu Mar 12, 2020 8:03 pm

how to set BLE transmit power above 3dB?

Postby ea2020 » Thu Mar 12, 2020 8:48 pm

I have my basic solution working (Adafruit ESP32 Feather to custom iOS application), but am not quite getting the range I want.

esp_bt.h enums the available esp_ble_power_type_t and esp_power_level_t to use when calling:

Code: Select all

esp_ble_tx_power_set(esp_ble_power_type_t power_type, esp_power_level_t power_level)
These suggest that using ESP_PWR_LVL_P9 should result in a +9 dB transmit power rather than the +3 dB default.

BLEDevice.cpp shows that the BLEDevice::setPower method calls the above function and sets the default power (ESP_BLE_PWR_TYPE_DEFAULT) to whatever power level is passed in with the call.

I've tried calling BLEDevice::setPower in many places (immediately after my call to BLEDevice::init, in my server callbacks after a successful connection, etc.). But, I always end up with +3dB of transmit power according the the nRF connect app (range and RSSI values also remain unchanged).

Digging through the IDF documentation, I found the following function:

Code: Select all

 esp_bredr_tx_power_set(esp_power_level_tmin_power_level, esp_power_level_tmax_power_level)
There is a note saying that it must be called after esp_bt_controller_enable and before anything that would cause the RF section to transmit.

Since esp_bt_controller_enable is called in BLEDevice::init, I tried the following:

Code: Select all

BLEDevice::init()
esp_bredr_tx_power_set(ESP_PWR_LVL_N12, ESP_PWR_LVL_P9)
BLEDevice::setPower(ESP_PWR_LVL_P9).
I still only see +3 dB transmit power.

I cannot find a call to esp_bredr_tx_power_set anywhere within the arduino IDE BLE source files (1.0.4/libraries/BLE/src), so I do not know where the default esp_power_level_tmax_power_level is being set.

Does anyone have any suggestions of what I am doing wrong?

If not, can anyone tell me where the +3 dB default value is set so I could at least hack something ugly together to test with +9 dB?

GYC-Espressif
Espressif staff
Espressif staff
Posts: 5
Joined: Tue Dec 31, 2019 9:57 am

Re: how to set BLE transmit power above 3dB?

Postby GYC-Espressif » Fri Mar 13, 2020 1:08 pm

Hello. This function is provided by ESP-IDF. And you can use it in following ways.

Code: Untitled.c Select all

/**
* @brief Set BLE TX power
* Connection Tx power should only be set after connection created.
* @param power_type : The type of which tx power, could set Advertising/Connection/Default and etc
* @param power_level: Power level(index) corresponding to absolute value(dbm)
* @return ESP_OK - success, other - failed
*/
esp_err_t esp_ble_tx_power_set(esp_ble_power_type_t power_type, esp_power_level_t power_level);
To set the 9dB tx Power for adv, you can set it as

Code: Untitled.c Select all

esp_ble_tx_power_set(ESP_BLE_PWR_TYPE_ADV,ESP_PWR_LVL_P9);
Thanks.

chuledeco
Posts: 8
Joined: Thu Feb 13, 2020 3:22 pm

Re: how to set BLE transmit power above 3dB?

Postby chuledeco » Fri Mar 28, 2025 4:50 pm

I have the same problem. It doesn't matter if I change the power using:

Code: Select all

esp_ble_tx_power_set(ESP_BLE_PWR_TYPE_ADV,ESP_PWR_LVL_P9);
The Tx power remains +3dbm

I'm reading the Tx power using NrfConnect

lbernstone
Posts: 1131
Joined: Mon Jul 22, 2019 3:20 pm

Re: how to set BLE transmit power above 3dB?

Postby lbernstone » Fri Mar 28, 2025 9:06 pm

The timing matters
Try setting the defaults and actually look at the result to make sure it is ESP_OK (not all devices have the same power capabiities)

Code: Select all

esp_err_t result = esp_ble_tx_power_set(ESP_BLE_PWR_TYPE_DEFAULT,ESP_PWR_LVL_P9);

Who is online

Users browsing this forum: Baidu [Spider], Semrush [Bot] and 1 guest