Page 1 of 1

Conflict between ADC2 and Wifi

Posted: Fri Oct 12, 2018 11:48 pm
by FoxHole
Hi all,

After a few hours of research, I was finally able to isolate my strange problem.
In the code below, if I uncomment the lines concerning wifi, the analog input A10 (GPIO4) always reports 4095.

Code: Select all

#include <Arduino.h>
#include <WiFi.h>

void setup() {
	Serial.begin(115200); 
	pinMode(A10, INPUT_PULLDOWN);

	/* Lines to uncomment to create the problem.
	WiFi.mode(WIFI_STA); 
	WiFi.disconnect();*/
}
void loop() {
	int analog = analogRead(A10);
	Serial.println(analog, DEC);
}
I finally found here(https://github.com/espressif/arduino-esp32/issues) and here (https://desire.giesecke.tk/index.php/20 ... is-in-use/) that adc2 channel could not be used while wifi was in use. I didn't have the time to check yet but I hope adc1 will work correctly (thanks for your advices on that matter)

That said, I don't really understand 2 points :
  • You will see in my code that I want to disconnect the wifi => Why does the conflict still exist (Note : Actually after that, I want to use esp_now protocol, which may create the conflict anyway, I don't know)
  • As the ESP product range has been mainly designed to be used with Wifi, Why Espressif does not communicate more on that issue and/or write it in big somewhere. ?
One problem remains for me : if only adc1 remains, that gives me "only" 6 Analog inputs available. I may need 2 more. Is there a fix planned for this problem ? Or may be a turn around ?

And is there a guide somewhere telling precisely which GPIO, ADC ... you can use in which configuration (if possible, I would like to avoid this waste of time in the future) ?

Thanks in advance for all your help and advices.

Antoine

Re: Conflict between ADC2 and Wifi

Posted: Sat Oct 13, 2018 2:08 am
by ESP_krzychb
FoxHole wrote:And is there a guide somewhere telling precisely which GPIO, ADC ... you can use in which configuration (if possible, I would like to avoid this waste of time in the future) ?
Hi Antoine,
This is documented in Analog to Digital Converter section of the ESP32 Programming Guide. If you are interested in use of other (not ADC related) GPIOs then also check GPIO & RTC GPIO section of the same guide. To discuss Arduino code please post directly in ESP32 Arduino section of this forum.