esp-now icon indicating copy to clipboard operation
esp-now copied to clipboard

use ESP-now and ADC at the same time

Open RTLhamster opened this issue 2 years ago • 3 comments

Hi there,

I try to send unidirectional ESP32 ADC2 (and other) data continuously to a second ESP32. The ADC does not return data if ESP-now is enabled. As far as I know is that ADC2 is used by the Wi-Fi driver and must be disabled to read ADC samples.

I tried to disable wifi: esp_wifi_stop(); read data: esp_err_t r = adc2_get_raw(ADC2_CHANNEL_3, ADC_WIDTH_12Bit, &data[0]);
and re-start the WiFi front-end esp_wifi_start();

It works but it takes quite some time. Without stopping/starting WiFi I can easily meet my timing constrain of sending data every 10ms. With it, it needs at least 70ms which is too much for my application.

Is it possible to disable/enable the front-end differently/faster?

Thanks!

RTLhamster avatar Aug 16 '22 15:08 RTLhamster

You may try to close the log during wifi stop and wifi start,like using esp_log_level_set("wifi", ESP_LOG_NONE); esp_log_level_set("phy_init", ESP_LOG_NONE);

Besides that, it seems that there is no other way to shorten the time.

LJYSP avatar Aug 29 '22 09:08 LJYSP

Hi LJYSP, thanks for your response.

I've tried your suggestion, but it didn't decrease the loop-time. For me its not clear if and why the disabling and re-enabling of the wifi/esp_now stack is required. There was a way to store/re-store the ADC config.: https://github.com/espressif/arduino-esp32/issues/440#issuecomment-1008165291 but it doesn't work.

Maybe some could ague that the WiFi stack could be messed up while doing it. But as far as I understand esp-now, its a connection less protocol: sending data, wait for reply, re-configure ADC should not result in any issue here. Also with respect of low-power, esp-now API should give us a easier and fast way to enable/disable it.

RTLhamster avatar Sep 05 '22 10:09 RTLhamster

ESP-NOW uses wifi action frame to send and receive data, so wifi start is needed.

Or you may try ESP32-S2, it can use wifi while using ADC2.

LJYSP avatar Sep 07 '22 11:09 LJYSP

@RTLhamster Any update about this?

lhespress avatar Jan 11 '23 10:01 lhespress

Hi @lhespress, unfortunately not, we change the PCB to use ADC1 GPIOs. It's a pity since a software support on ESP-now could be added I believe... But we have to live with it :/

RTLhamster avatar Jan 11 '23 14:01 RTLhamster

Thanks for your feedback, i'll check it again.

lhespress avatar Jan 12 '23 14:01 lhespress

@RTLhamster I reproduce the issue on ESP32, we didn't suggest that use ADC2 when you need WIFI or BLE because of the PHY also used it.

lhespress avatar Apr 24 '23 08:04 lhespress

@RTLhamster Closing this issue since there has been no update on this. Please feel free to reopen if required.

lhespress avatar Jun 02 '23 03:06 lhespress