Page 1 of 2

ESP32 S3 Bluetooth Range

Posted: Sat Dec 24, 2022 12:29 pm
by mariuselz
Hi guys,

I'm a bit lost regarding the BLE 5 range of the S3, any sort of feedback is very much appreciated.
I have totally redesigned a previous existing pcb and updated it to ESP32-S3 in order to benefit of 2 main things: OTA updates (wifi) and long range bluetooth (as I was using hm-10 module BLE 4.2 & arduino before)

Rewritten the code to fit ESP32 BLE and got to testing - to my horrifying surprise, the range is identical to my BLE 4.2 board, somewhere around 5-8 meters, maybe 10 in open field.

I started digging into it, the TX power seems to be +9dBm by default (as shown in LightBlue app on iOS, comparing to +4dBm shown on BLE 4.2), I also tried setting ESP_PWR_LVL_P9 for +9dBm range just in case and there is no effect.
Started reading about 1M, 2M and Coded PHY (as far as I'm aware, S3 supports all 3 of these) - from this I understood that the default BLE 5 layer of S3 is 1M PHY? Meaning up to 50m or so, but realistically same as BLE 4.

Is there any way I can adjust my code to have at least 15m or so of range?

Side note: I have another totally different pcb with S3, I tested the range between these 2 different S3 boards (one server, one client) and the range is the same as with the iPhone 12 Pro.

Any help or guidance is much much appreciated, thank you!

Marius

Re: ESP32 S3 Bluetooth Range

Posted: Tue Jan 03, 2023 10:54 am
by FRANCISCO2020
To set the BLE power on an ESP32, you must use the esp_ble_tx_power_set function from the BLE library and pass the desired power level as a parameter. The power level can be one of the following values:

ESP_PWR_LVL_N12 (power level -12 dBm)
ESP_PWR_LVL_N9 (power level -9 dBm)
ESP_PWR_LVL_N6 (power level -6 dBm)
ESP_PWR_LVL_N3 (power level -3 dBm)
ESP_PWR_LVL_0 (0 dBm power level)

For example, to set the power level to -6 dBm, you could use the following code:


#include "BLEDevice.h"

void setup()
{
BLEDevice::init("My BLE device");
esp_ble_tx_power_set(ESP_PWR_LVL_N6);
}

void loop()
{
// your code here
}

Note that the esp_ble_tx_power_set function is only available in version 5.2.0 or later of the BLE library.

Re: ESP32 S3 Bluetooth Range

Posted: Wed Jan 04, 2023 11:30 am
by mariuselz
FRANCISCO2020 wrote:
Tue Jan 03, 2023 10:54 am
To set the BLE power on an ESP32, you must use the esp_ble_tx_power_set function from the BLE library and pass the desired power level as a parameter. The power level can be one of the following values:

ESP_PWR_LVL_N12 (power level -12 dBm)
ESP_PWR_LVL_N9 (power level -9 dBm)
ESP_PWR_LVL_N6 (power level -6 dBm)
ESP_PWR_LVL_N3 (power level -3 dBm)
ESP_PWR_LVL_0 (0 dBm power level)

For example, to set the power level to -6 dBm, you could use the following code:


#include "BLEDevice.h"

void setup()
{
BLEDevice::init("My BLE device");
esp_ble_tx_power_set(ESP_PWR_LVL_N6);
}

void loop()
{
// your code here
}

Note that the esp_ble_tx_power_set function is only available in version 5.2.0 or later of the BLE library.

Thank you for your detailed answer!
As I mentioned, I have tried this and the TX Power is set to +9 by default. I see this in the LightBlue or any other Bluetooth app on the iOS or OS X. But now I'm a bit confused, do I need to set negative dBm power for longer range?

Also, I still cannot find any examples about 2M or Coded PHY.. I don't understand why the ESP32 S3 is marketed with long range if there is no help in this direction

I also found this in the datasheet at the Bluetooth section in Features:
High power mode (21 dBm)
However I cannot find how to set the bluetooth to high power mode.

Re: ESP32 S3 Bluetooth Range

Posted: Wed Jan 04, 2023 11:45 am
by FRANCISCO2020
Yes, correct, that's how it works.

Re: ESP32 S3 Bluetooth Range

Posted: Wed Jan 04, 2023 12:00 pm
by FRANCISCO2020
To set Bluetooth to high power mode on the ESP32-S3, try this:

Connect the ESP32-S3 to your computer and open the Arduino IDE.

In the Arduino IDE, go to the "Tools" menu and select the "Board" option. Select "ESP32 Dev Module" as the board.

Go to the "Tools" menu and select the "Port" option. Select the serial port that corresponds to your ESP32-S3.

In the Arduino IDE, go to the "File" menu and select "Examples". Scroll down and select the "ESP32" folder.

In the "ESP32" folder, select the "Bluetooth" folder. Select the "BLEDevice" example and click "Open".

In the "BLEDevice" sample sketch, find the following lines of code:



BLEDevice::init("ESP32");
Replace these lines with the following code:

copy code
BLEDevice::init("ESP32", true);

This will initialize Bluetooth in high power mode on the ESP32-S3.

Upload the sketch to the ESP32-S3 using the "Upload" button in the Arduino IDE.

Once the sketch has been uploaded, the ESP32-S3 will be configured to use high power mode for Bluetooth. You can use the Bluetooth features on your sketch to communicate with other Bluetooth devices in high power mode.

Re: ESP32 S3 Bluetooth Range

Posted: Wed Jan 04, 2023 1:09 pm
by mariuselz
FRANCISCO2020 wrote:
Wed Jan 04, 2023 11:45 am
Yes, correct, that's how it works.

I don't think this is right. I've done some testing again.
Average dB signal for various power setups, between an ESP32 S3 and iPhone 12 Pro that are 20cm apart:

Default: -59 dB
N12: -69 dB
N6: -66 dB
N0: -63 dB
P9: -55 dB

As you can see, the higher the Tx power, the bigger the range. The closer the dB value is to 0, the bigger the signal/range.
This also confirms that the default P9 power setup is the same as default. Meaning ESP32 S3 out of the box is transmitting at the highest power, so no need to change tx_power.

Code I used:

Code: Select all

BLEDevice::init("My ESP32 S3 Bluetooth");
BLEDevice::setPower(ESP_PWR_LVL_P9);
//esp_err_t errRc=::esp_ble_tx_power_set(ESP_BLE_PWR_TYPE_DEFAULT, ESP_PWR_LVL_P9);
-----------------------------------------

Code: Select all

BLEDevice::init("My ESP32 S3 Bluetooth", true);
Does not work: no matching function for call to 'BLEDevice::init(const char [21], bool)'

Re: ESP32 S3 Bluetooth Range

Posted: Wed Jan 04, 2023 3:43 pm
by FRANCISCO2020
How are you powering the esp32?

Re: ESP32 S3 Bluetooth Range

Posted: Wed Jan 04, 2023 6:52 pm
by mariuselz
FRANCISCO2020 wrote:
Wed Jan 04, 2023 3:43 pm
How are you powering the esp32?

USB-C and/or battery (LiPo 3.7V)

Re: ESP32 S3 Bluetooth Range

Posted: Thu Jan 05, 2023 9:55 am
by FRANCISCO2020
To carry out tests with Wi-Fi... and everything related to RF, I recommend a 1A power supply to avoid problems.
if you look at the pdf there are intensity peaks of more than 800mA

Re: ESP32 S3 Bluetooth Range

Posted: Thu Jan 05, 2023 10:20 am
by mariuselz
FRANCISCO2020 wrote:
Thu Jan 05, 2023 9:55 am
To carry out tests with Wi-Fi... and everything related to RF, I recommend a 1A power supply to avoid problems.
if you look at the pdf there are intensity peaks of more than 800mA

I also powered the pcb to +12V as well and I had the same results.
Also, this is Bluetooth not Wi-Fi, big difference, but I get your point.

Still nothing, I've been dealing with this for almost 1 month without any luck. Not sure what's happening and why it is not documented