Closed brianmathews closed 9 months ago
// Mapping Table {Power, max_tx_power} = {{8, 2}, {20, 5}, {28, 7}, {34, 8}, {44, 11}, {52, 13}, {56, 14}, {60, 15}, {66, 16}, {72, 18}, {80, 20}}.
const uint8_t MAX_TX_PWR = 44; // set to first arg in table above for the desired dBm (second arg)
// Not required, but we read the starting power just for informative purposes
int8_t default_wifi_power = 0;
ESP_ERROR_CHECK(esp_wifi_get_max_tx_power(&default_wifi_power));
ESP_LOGI(TAG, "Default max tx power: %d", default_wifi_power);
ESP_LOGI(TAG, "Setting wifi max power to %d", MAX_TX_PWR);
ESP_ERROR_CHECK(esp_wifi_set_max_tx_power(MAX_TX_PWR));
Justin K5EM says that the default WiFi power is much higher than required. Lower power reduces WiFi noise into the KX radio, slightly lengthens battery life span.
From Justin: