user76576: I have an ESP32, the current program running on it uses WiFi but, if I use WiFi and Analog read at the same time, Analog read does not work.
Why does this happen and what's the way around it?
Hardware - ESP32, Pin 25 for the ADC
Code-
#include <WiFi.h>

void setup() {
  Serial.begin(115200);
  WiFi.begin("You really", "Want to know"); // If this line is commented then it works
}

void loop() {
  Serial.println(analogRead(25));
}


user4143: The ESP32 has two ADCs. One of them, ADC2, is actively used by the WiFi.
From the IDF documentation:

Since the ADC2 module is also used by the Wi-Fi, only one of them could get the preemption when using together, which means the adc2_get_raw() may get blocked until Wi-Fi stops, and vice versa.

That means you can't use the ADC on any of the ADC2 channels while WiFi is on: GPIO4, GPIO0, GPIO2, GPIO15, GPIO13, GPIO12, GPIO14, GPIO27, GPIO25 and GPIO26.
But you can use ADC1, which uses pins GPIO36, GPIO37, GPIO38, GPIO39, GPIO32, GPIO33, GPIO34 and GPIO35.

76576: <p>I have an ESP32, the current program running on it uses WiFi but, if I use WiFi and Analog read at the same time, Analog read does not work.</p>
<p>Why does this happen and what's the way around it?</p>
<p>Hardware - ESP32, Pin 25 for the ADC</p>
<p>Code-</p>
<pre><code>#include &lt;WiFi.h&gt;

void setup() {
  Serial.begin(115200);
  WiFi.begin(&quot;You really&quot;, &quot;Want to know&quot;); // If this line is commented then it works
}

void loop() {
  Serial.println(analogRead(25));
}
</code></pre>
 4143: <p>The ESP32 has two ADCs. One of them, ADC2, is actively used by the WiFi.</p>
<p>From the IDF documentation:</p>
<blockquote>
<p>Since the ADC2 module is also used by the Wi-Fi, only one of them could get the preemption when using together, which means the adc2_get_raw() may get blocked until Wi-Fi stops, and vice versa.</p>
</blockquote>
<p>That means you can't use the ADC on any of the ADC2 channels while WiFi is on: GPIO4, GPIO0, GPIO2, GPIO15, GPIO13, GPIO12, GPIO14, GPIO27, GPIO25 and GPIO26.</p>
<p>But you can use ADC1, which uses pins GPIO36, GPIO37, GPIO38, GPIO39, GPIO32, GPIO33, GPIO34 and GPIO35.</p>
