analogRead stops working when Wi-Fi is on

  • ESP32

Why it happens

  • Pins 0, 2, 4, 12, 13, 14, 15, 25, 26 and 27 use ADC2, which Wi-Fi also uses.

How to fix it

  1. Move the sensor to GPIO 32, 33, 34, 35, 36 or 39 (ADC1).
  2. Change the pin in the code.

It worked if: The reading changes smoothly with Wi-Fi connected.

From the official documentation. From Espressif's ESP32 GPIO notes. Sources: Espressif: ESP32 GPIO notes.

Didn't help? Search another error or ask us.