[SOLVED] How to change WiFi TX power in source code

Agree007
Posts: 103
Joined: Mon Sep 18, 2017 7:11 pm
Location: Copenhagen

[SOLVED] How to change WiFi TX power in source code

Postby Agree007 » Thu Apr 12, 2018 9:46 am

We would like to be able to adjust (reduce) the TX power when close to our access points, in order to save battery power.
In an old post I found a statement that it would be implemented in version 1.0, but I have not been able to find more information about this.

So my question is, if we can change the TX power on our WiFi in our program and if yes, how it should be done ?

Thx in advance for your support.
Last edited by Agree007 on Thu Apr 12, 2018 10:22 am, edited 1 time in total.

WiFive
Posts: 3529
Joined: Tue Dec 01, 2015 7:35 am

Re: How to change WiFi TX power in source code

Postby WiFive » Thu Apr 12, 2018 10:15 am

Last edited by WiFive on Tue Jul 31, 2018 5:16 pm, edited 1 time in total.

Agree007
Posts: 103
Joined: Mon Sep 18, 2017 7:11 pm
Location: Copenhagen

Re: How to change WiFi TX power in source code

Postby Agree007 » Thu Apr 12, 2018 10:17 am

Thanks a lot, will try play with asap :-)

User avatar
mzimmers
Posts: 643
Joined: Wed Mar 07, 2018 11:54 pm
Location: USA

Re: [SOLVED] How to change WiFi TX power in source code

Postby mzimmers » Tue Jul 31, 2018 5:01 pm

Note: I just ran across this...good answer, but the line number has changed. I assume you were referring to the routine esp_wifi_set_max_tx_power().

WiFive
Posts: 3529
Joined: Tue Dec 01, 2015 7:35 am

Re: [SOLVED] How to change WiFi TX power in source code

Postby WiFive » Tue Jul 31, 2018 5:18 pm

Sorry fixed to permalink

User avatar
mzimmers
Posts: 643
Joined: Wed Mar 07, 2018 11:54 pm
Location: USA

Re: [SOLVED] How to change WiFi TX power in source code

Postby mzimmers » Tue Jul 31, 2018 6:45 pm

As long as I'm nitpicking, I'd greatly prefer a different way of expressing the power ranges. For example:

Code: Select all

            - [78, 127]: level0
Is not going to be interpreted as "from 78 to 127." I'm not sure how it will be interpreted, but it's likely to cause confusion. I recommend:

Code: Select all

            - 78 - 127: level0
or

Code: Select all

            - from 78 through 127: level0
And, I think the ranges need to be updated. On my device, I ran the following little test:

Code: Select all

            int8_t i, j, jSave = -128;

            for ( i = -128; i < 127; ++i)
            {
                ESP_ERROR_CHECK(esp_wifi_set_max_tx_power(i));
                ESP_LOGI(TAG, "Wifi power set to %d.", i);

                ESP_ERROR_CHECK(esp_wifi_get_max_tx_power(&j));
                if (j != jSave)
                {
                    ESP_LOGI(TAG, "\t\t\tWifi power get is %d.", j);
                    jSave = j;
                }
            }
Here's the output I got:
I (4326) Worker: Wifi power set to -128.
I (4326) Worker: Wifi power get is -4.
I (4326) Worker: Wifi power set to -127.
I (4326) Worker: Wifi power set to -126.
I (4326) Worker: Wifi power set to -125.
...
I (4916) Worker: Wifi power set to 6.
I (4926) Worker: Wifi power set to 7.
I (4926) Worker: Wifi power set to 8.
I (4936) Worker: Wifi power get is 8.
I (4936) Worker: Wifi power set to 9.
I (4936) Worker: Wifi power set to 10.
I (4946) Worker: Wifi power set to 11.
I (4946) Worker: Wifi power set to 12.
I (4956) Worker: Wifi power set to 13.
I (4956) Worker: Wifi power set to 14.
I (4966) Worker: Wifi power set to 15.
I (4966) Worker: Wifi power set to 16.
I (4976) Worker: Wifi power set to 17.
I (4976) Worker: Wifi power set to 18.
I (4976) Worker: Wifi power set to 19.
I (4986) Worker: Wifi power set to 20.
I (4986) Worker: Wifi power get is 20.
I (4996) Worker: Wifi power set to 21.
I (4996) Worker: Wifi power set to 22.
I (5006) Worker: Wifi power set to 23.
I (5006) Worker: Wifi power set to 24.
I (5016) Worker: Wifi power set to 25.
I (5016) Worker: Wifi power set to 26.
I (5016) Worker: Wifi power set to 27.
I (5026) Worker: Wifi power set to 28.
I (5026) Worker: Wifi power get is 28.
I (5036) Worker: Wifi power set to 29.
I (5036) Worker: Wifi power set to 30.
I (5046) Worker: Wifi power set to 31.
I (5046) Worker: Wifi power set to 32.
I (5056) Worker: Wifi power set to 33.
I (5056) Worker: Wifi power set to 34.
I (5056) Worker: Wifi power get is 34.
I (5066) Worker: Wifi power set to 35.
I (5066) Worker: Wifi power set to 36.
I (5076) Worker: Wifi power set to 37.
I (5076) Worker: Wifi power set to 38.
I (5086) Worker: Wifi power set to 39.
I (5086) Worker: Wifi power set to 40.
I (5096) Worker: Wifi power set to 41.
I (5096) Worker: Wifi power set to 42.
I (5096) Worker: Wifi power set to 43.
I (5106) Worker: Wifi power set to 44.
I (5106) Worker: Wifi power get is 44.
I (5116) Worker: Wifi power set to 45.
I (5116) Worker: Wifi power set to 46.
I (5126) Worker: Wifi power set to 47.
I (5126) Worker: Wifi power set to 48.
I (5126) Worker: Wifi power set to 49.
I (5136) Worker: Wifi power set to 50.
I (5136) Worker: Wifi power set to 51.
I (5146) Worker: Wifi power set to 52.
I (5146) Worker: Wifi power get is 52.
I (5156) Worker: Wifi power set to 53.
I (5156) Worker: Wifi power set to 54.
I (5166) Worker: Wifi power set to 55.
I (5166) Worker: Wifi power set to 56.
I (5166) Worker: Wifi power get is 56.
I (5176) Worker: Wifi power set to 57.
I (5176) Worker: Wifi power set to 58.
I (5186) Worker: Wifi power set to 59.
I (5186) Worker: Wifi power set to 60.
I (5196) Worker: Wifi power get is 60.
I (5196) Worker: Wifi power set to 61.
I (5206) Worker: Wifi power set to 62.
I (5206) Worker: Wifi power set to 63.
I (5206) Worker: Wifi power set to 64.
I (5216) Worker: Wifi power set to 65.
I (5216) Worker: Wifi power set to 66.
I (5226) Worker: Wifi power get is 66.
I (5226) Worker: Wifi power set to 67.
I (5236) Worker: Wifi power set to 68.
I (5236) Worker: Wifi power set to 69.
I (5246) Worker: Wifi power set to 70.
I (5246) Worker: Wifi power set to 71.
I (5246) Worker: Wifi power set to 72.
I (5256) Worker: Wifi power get is 72.
I (5256) Worker: Wifi power set to 73.
I (5266) Worker: Wifi power set to 74.
I (5266) Worker: Wifi power set to 75.
I (5276) Worker: Wifi power set to 76.
I (5276) Worker: Wifi power set to 77.
I (5286) Worker: Wifi power set to 78.
I (5286) Worker: Wifi power get is 78.
I (5286) Worker: Wifi power set to 79.
I (5296) Worker: Wifi power set to 80.
I (5296) Worker: Wifi power set to 81.
I (5306) Worker: Wifi power set to 82.
...
I (5486) Worker: Wifi power set to 124.
I (5496) Worker: Wifi power set to 125.
I (5496) Worker: Wifi power set to 126.
As you can see, the ranges are a bit different (at least on my device).

EDIT: sorry for the lousy formatting; I guess my tabs got filtered out somehow. The levels seem to change at:
78, 72, 66, 60, 56, 52, 44, 34, 28, 20, 8 and (-4).

Who is online

Users browsing this forum: No registered users and 103 guests