This example sketch demonstrates how to use the ESP32 to read analog values accurately. Well, at least better that analogRead() will get you that's for sure. If your new(ish) to ESP32, then you may have noticed that the Arduino way of reading analog signals does not work with ESP32. This means you need to do it the ESP32 way and this sketch will help.
Don't forget, you can't use ADC2 when using WiFi.
Video tutorial:
Thank you. Kitecaft.