AnalogRead does indeed work on the ESP32. Many sites and posts that claim that the Analog to Digital converter of the ESP32 doesn’t work. I have tested analogRead using the code below and it works as expected. The code below compiles and downloads to my ESP32 Development board and produces correct results. The input pin is the seventh pin from the top on the left hand side of the ESP32 Development Board.
#define RLED 16 #define InPin 33 int x ; void setup() { Serial.begin(115200); pinMode(RLED, OUTPUT); } void loop() { digitalWrite(RLED, LOW); delay(100); x = analogRead( InPin ); Serial.println( x ); digitalWrite(RLED, HIGH); delay(100); }
Have fun!