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 How to set Power Level Bluetooth Classic BR/EDR
-
- Valued Contributor
- Posts: 760
- http://meble-kuchenne.info.pl
- Joined: Wed Dec 02, 2020 10:53 am
- Has thanked: 150 times
- Been thanked: 171 times
-
- Valued Contributor
- Posts: 991
- Joined: Wed Dec 09, 2020 9:37 pm
- Has thanked: 106 times
- Been thanked: 517 times
Re: ESP32 How to set Power Level Bluetooth Classic BR/EDR
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
Martin
-
- Valued Contributor
- Posts: 760
- Joined: Wed Dec 02, 2020 10:53 am
- Has thanked: 150 times
- Been thanked: 171 times
Re: ESP32 How to set Power Level Bluetooth Classic BR/EDR
Hi Martin
I found 3 of this file and I included one of them (I have a ESP32 Pico)
No Error
I also build a variable ESP_ERR_ T (byte) and add the C code in my program. But now Error on compiling...
regards
Stefan
File avaible
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"
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)
Stefan
File avaible
-
- Valued Contributor
- Posts: 401
- Joined: Mon Dec 07, 2020 1:00 pm
- Has thanked: 73 times
- Been thanked: 218 times
Re: ESP32 How to set Power Level Bluetooth Classic BR/EDR
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
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
-
- Valued Contributor
- Posts: 760
- Joined: Wed Dec 02, 2020 10:53 am
- Has thanked: 150 times
- Been thanked: 171 times
Re: ESP32 How to set Power Level Bluetooth Classic BR/EDR
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
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 92 times
-
- Valued Contributor
- Posts: 760
- Joined: Wed Dec 02, 2020 10:53 am
- Has thanked: 150 times
- Been thanked: 171 times
Re: ESP32 How to set Power Level Bluetooth Classic BR/EDR
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
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
-
- Matrix Staff
- Posts: 1756
- Joined: Mon Dec 07, 2020 10:06 am
- Has thanked: 446 times
- Been thanked: 606 times
Re: ESP32 How to set Power Level Bluetooth Classic BR/EDR
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.
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.
Regards Ben Rowland - MatrixTSL
Flowcode Online Code Viewer (Beta) - Flowcode Product Page - Flowcode Help Wiki - My YouTube Channel
Flowcode Online Code Viewer (Beta) - Flowcode Product Page - Flowcode Help Wiki - My YouTube Channel
-
- Valued Contributor
- Posts: 760
- Joined: Wed Dec 02, 2020 10:53 am
- Has thanked: 150 times
- Been thanked: 171 times
Re: ESP32 How to set Power Level Bluetooth Classic BR/EDR
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
https://docs.espressif.com/projects/esp ... _vhci.html
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)
-
- Matrix Staff
- Posts: 1756
- Joined: Mon Dec 07, 2020 10:06 am
- Has thanked: 446 times
- Been thanked: 606 times
Re: ESP32 How to set Power Level Bluetooth Classic BR/EDR
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.
This is the breakdown for the power level values.
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;
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;
Regards Ben Rowland - MatrixTSL
Flowcode Online Code Viewer (Beta) - Flowcode Product Page - Flowcode Help Wiki - My YouTube Channel
Flowcode Online Code Viewer (Beta) - Flowcode Product Page - Flowcode Help Wiki - My YouTube Channel
-
- Valued Contributor
- Posts: 760
- Joined: Wed Dec 02, 2020 10:53 am
- Has thanked: 150 times
- Been thanked: 171 times
Re: ESP32 How to set Power Level Bluetooth Classic BR/EDR
Hi Ben
As soon as I use the get command I always get an error no matter what I try
regards
Stefan
As soon as I use the get command I always get an error no matter what I try
regards
Stefan