I am currently working on a project using an ESP32 to monitor wifi packets (using promiscuous mode). Currently, I am using arduino for ESP32 (but can change to esp-idf if necessary), and am able to perform the monitoring correctly.
When monitoring, I get a current consumption of around 100/102mA. (with core frequency of 80MHz). I am looking to reduce this power consumption a bit. How could I do so ?
This is a simplified version of my code:
Code: Select all
void wifi_promiscuous(void* buff, wifi_promiscuous_pkt_type_t type) {
// store the packet in memory
}
void setup() {
esp_bt_controller_disable();
nvs_flash_init();
tcpip_adapter_init();
wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT();
ESP_ERROR_CHECK(esp_event_loop_init(event_handler, NULL)); // event_handler does nothing
ESP_ERROR_CHECK(esp_wifi_init(&cfg));
ESP_ERROR_CHECK(esp_wifi_set_storage(WIFI_STORAGE_RAM));
ESP_ERROR_CHECK(esp_wifi_set_mode(WIFI_MODE_NULL));
ESP_ERROR_CHECK(esp_wifi_start());
esp_wifi_set_max_tx_power(-4); // reduce tx power, as we only receive
esp_wifi_set_channel(ch, WIFI_SECOND_CHAN_NONE);
esp_wifi_set_promiscuous_rx_cb(&wifi_promiscuous);
esp_wifi_set_promiscuous(true);
vTaskDelay(1000L * (MEASUREMENT_DURATION) / portTICK_PERIOD_MS);
// Do something with the measurement, then get turned off externally.
}