ESP32 How to set Power Level Bluetooth Classic BR/EDR

Post here to discuss any new features, components, chips, etc, that you would like to see in Flowcode.
stefan.erni
Valued Contributor
Posts: 738
http://meble-kuchenne.info.pl
Joined: Wed Dec 02, 2020 10:53 am
Has thanked: 149 times
Been thanked: 170 times

ESP32 How to set Power Level Bluetooth Classic BR/EDR

Post by stefan.erni »

Hi Ben

For the Bluetooth Classic BR/EDR it's possible to set the transmit power Level
mostly the transmission power can be adjusted in few steps dbm like

0dbm
+4dbm
+20dbm

With this setting you can set the distance range and the power requirement.
In my project I only need a few centimeters but I have a small battery available

Can I use commans to set or read like in this doku with flowcode?

regards

Stefan


https://docs.espressif.com/projects/esp ... ower_level
ESP32_Power_2022-04-19_14-23-49.jpg
ESP32_Power_2022-04-19_14-23-49.jpg (88.3 KiB) Viewed 3309 times

mnfisher
Valued Contributor
Posts: 938
Joined: Wed Dec 09, 2020 9:37 pm
Has thanked: 104 times
Been thanked: 502 times

Re: ESP32 How to set Power Level Bluetooth Classic BR/EDR

Post by mnfisher »

Should be possible in a C block - might need an include for the appropriate header file too (in supplementary code or just in main depending on use)

Martin

stefan.erni
Valued Contributor
Posts: 738
Joined: Wed Dec 02, 2020 10:53 am
Has thanked: 149 times
Been thanked: 170 times

Re: ESP32 How to set Power Level Bluetooth Classic BR/EDR

Post by stefan.erni »

Hi Martin

I found 3 of this file and I included one of them (I have a ESP32 Pico)
No Error

Code: Select all

#include "C:\Users\Kfs-Forschung\Desktop\esp-idf\components\bt\include\esp32\include\esp_bt.h"
I also build a variable ESP_ERR_ T (byte) and add the C code in my program. But now Error on compiling...

Code: Select all

/*
  Enter C code below this comment
*/

FCV_ESP_ERR_T esp_bredr_tx_power_set(esp_power_level_tmin_power_level, esp_power_level_tmax_power_level)
regards

Stefan

File avaible
include_2022-04-19_15-14-29.jpg
include_2022-04-19_15-14-29.jpg (19.88 KiB) Viewed 3302 times
Sub_2022-04-19_15-25-43.jpg
Sub_2022-04-19_15-25-43.jpg (53.81 KiB) Viewed 3302 times

LeighM
Valued Contributor
Posts: 394
Joined: Mon Dec 07, 2020 1:00 pm
Has thanked: 69 times
Been thanked: 208 times

Re: ESP32 How to set Power Level Bluetooth Classic BR/EDR

Post by LeighM »

Hi Stefan
In your C code icon, you don't need the FCV_ESP_ERR_T so can remove it.
Also you do need a semicolon at the end of that statement.
Hope that helps

stefan.erni
Valued Contributor
Posts: 738
Joined: Wed Dec 02, 2020 10:53 am
Has thanked: 149 times
Been thanked: 170 times

Re: ESP32 How to set Power Level Bluetooth Classic BR/EDR

Post by stefan.erni »

Hi Martin, Hi Leigh

I've tried many things but as soon as I activate the C code I can't compile anymore.

And I also suspect the path for the additional code would have to be shorter than what I did.

regards

Stefan
Attachments
Demodata_ESP32_v2.fcfx
(87.52 KiB) Downloaded 79 times

stefan.erni
Valued Contributor
Posts: 738
Joined: Wed Dec 02, 2020 10:53 am
Has thanked: 149 times
Been thanked: 170 times

Re: ESP32 How to set Power Level Bluetooth Classic BR/EDR

Post by stefan.erni »

Hi Martin, Hi Leigh

I tried the program from Martin to let the esp32 sleep.
After I change some paths then it working very nice.
Instead of 70mA it only needs 20mA (with a LED on) in sleep mode
https://flowcode.co.uk/forums/viewtopic ... 5660#p5660

I did the same for my program for the BT command
Also my command for BT Power dont give errors anymore.
But the power with bluetooth sending dont change even if I set to min or max power.
I'll see what else I need to do then additionally so the powermode will work.

esp_bredr_tx_power_set(ESP_PWR_LVL_N12,ESP_PWR_LVL_N9);
esp_bredr_tx_power_set(ESP_PWR_LVL_P6,ESP_PWR_LVL_P9);


regards

Stefan

BenR
Matrix Staff
Posts: 1706
Joined: Mon Dec 07, 2020 10:06 am
Has thanked: 435 times
Been thanked: 598 times

Re: ESP32 How to set Power Level Bluetooth Classic BR/EDR

Post by BenR »

Hi Stefan,

The Bluetooth transmission will essentially be a spike in the power of the module. Is your current monitor capable of detecting the spike or is it simply averaging? Even if you are constantly transmitting this might help to allow you to see the current usage a bit better but even then the radio tx packets will be sent in bursts and so may be being averaged out. There could also be capacitors on the module that are also somewhat shielding you from the spiked tx power usage.

A better test might be to charge a battery up to a known voltage and then time how long it takes to discharge to a known voltage. Then compare with a different BT power level.

stefan.erni
Valued Contributor
Posts: 738
Joined: Wed Dec 02, 2020 10:53 am
Has thanked: 149 times
Been thanked: 170 times

Re: ESP32 How to set Power Level Bluetooth Classic BR/EDR

Post by stefan.erni »

Hi Ben

Yes. Good idea. I will do that. I need the measurement anyway how long can I measure or send BT with one charge.

I understood now a little how use set commands for the ESP32
Can you also give me an example of how I can read values from ESP32 with FC9 "C command"?
Like this get command..

regards

Stefan

Code: Select all

esp_err_tesp_bredr_tx_power_get(esp_power_level_t *min_power_level, esp_power_level_t *max_power_level)
https://docs.espressif.com/projects/esp ... _vhci.html
get_-04-22_16-04-22.jpg
get_-04-22_16-04-22.jpg (35.82 KiB) Viewed 3263 times

BenR
Matrix Staff
Posts: 1706
Joined: Mon Dec 07, 2020 10:06 am
Has thanked: 435 times
Been thanked: 598 times

Re: ESP32 How to set Power Level Bluetooth Classic BR/EDR

Post by BenR »

Hello,

The C code for that might look like this. You can use a Flowcode Byte variables min and max to take the values in a more normal numeric format you can work with.

Code: Select all

esp_power_level_t esp_min, esp_max;
esp_bredr_tx_power_get(*esp_min, *esp_max);
FCV_MIN = (unsigned char) esp_min;
FCV_MAX = (unsigned char) esp_max;
This is the breakdown for the power level values.

Code: Select all

typedef enum {
    ESP_PWR_LVL_N12 = 0,                /*!< Corresponding to -12dbm */
    ESP_PWR_LVL_N9  = 1,                /*!< Corresponding to  -9dbm */
    ESP_PWR_LVL_N6  = 2,                /*!< Corresponding to  -6dbm */
    ESP_PWR_LVL_N3  = 3,                /*!< Corresponding to  -3dbm */
    ESP_PWR_LVL_N0  = 4,                /*!< Corresponding to   0dbm */
    ESP_PWR_LVL_P3  = 5,                /*!< Corresponding to  +3dbm */
    ESP_PWR_LVL_P6  = 6,                /*!< Corresponding to  +6dbm */
    ESP_PWR_LVL_P9  = 7,                /*!< Corresponding to  +9dbm */
    ESP_PWR_LVL_N14 = ESP_PWR_LVL_N12,  /*!< Backward compatibility! Setting to -14dbm will actually result to -12dbm */
    ESP_PWR_LVL_N11 = ESP_PWR_LVL_N9,   /*!< Backward compatibility! Setting to -11dbm will actually result to  -9dbm */
    ESP_PWR_LVL_N8  = ESP_PWR_LVL_N6,   /*!< Backward compatibility! Setting to  -8dbm will actually result to  -6dbm */
    ESP_PWR_LVL_N5  = ESP_PWR_LVL_N3,   /*!< Backward compatibility! Setting to  -5dbm will actually result to  -3dbm */
    ESP_PWR_LVL_N2  = ESP_PWR_LVL_N0,   /*!< Backward compatibility! Setting to  -2dbm will actually result to   0dbm */
    ESP_PWR_LVL_P1  = ESP_PWR_LVL_P3,   /*!< Backward compatibility! Setting to  +1dbm will actually result to  +3dbm */
    ESP_PWR_LVL_P4  = ESP_PWR_LVL_P6,   /*!< Backward compatibility! Setting to  +4dbm will actually result to  +6dbm */
    ESP_PWR_LVL_P7  = ESP_PWR_LVL_P9,   /*!< Backward compatibility! Setting to  +7dbm will actually result to  +9dbm */
} esp_power_level_t;

stefan.erni
Valued Contributor
Posts: 738
Joined: Wed Dec 02, 2020 10:53 am
Has thanked: 149 times
Been thanked: 170 times

Re: ESP32 How to set Power Level Bluetooth Classic BR/EDR

Post by stefan.erni »

Hi Ben

As soon as I use the get command I always get an error no matter what I try

regards

Stefan
Demodata_ESP32_post1.fcfx
(64.57 KiB) Downloaded 99 times

Post Reply