Potentiometer not working while WiFi-AP is active

Hello,
I have a problem with my ESP32. I'm running a simple WiFi-Accesspoint program and I'm trying now to read a potentiometer while the server is running... The problem is that i can't read the potentiometer (value is always 0). As soon as i start the program without the webserver it works totally fine.
Any ideas why it's not working ?

The code:

#include <WiFi.h>
#include <AsyncTCP.h>
#include <ESPAsyncWebServer.h>

const char* ssid = "ESP32WiFi";
const char* password = "12345";
AsyncWebServer server(80);


#define POTI 14



const char index_html[] PROGMEM = R"rawliteral(


<!DOCTYPE HTML><html>
<head>
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>ESP Web Server</title>
  <style>

  </style>
</head>
<body>
  <h1>body</h1>

<script>

</script>
</body>
</html>


)rawliteral";



void setup(){

  pinMode(POTI, INPUT);

  
  Serial.begin(115200);
  WiFi.softAP(ssid, password);
  IPAddress IP = WiFi.softAPIP();
  Serial.print("AP IP address: ");
  Serial.println(IP);

  server.on("/", HTTP_GET, [](AsyncWebServerRequest *request){
    request->send_P(200, "text/html", index_html);
  });
  server.begin();
  
}
  
void loop() {
 Serial.println(analogRead(POTI));
}


Note: ADC2 pins cannot be used when Wi-Fi is used. So, if you’re using Wi-Fi and you’re having trouble getting the value from an ADC2 GPIO, you may consider using an ADC1 GPIO instead, that should solve your problem.
https://randomnerdtutorials.com/esp32-adc-analog-read-arduino-ide/

1 Like

Thank you so much for the information :slightly_smiling_face:
Have a nice day ;^)

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.