The Rev1 and Rev0 versions of the ESP32 has a couple of issues with the ADC. There is a topic on noise pickup https://forum.ezsbc.com/viewtopic.php?f=12&t=8816 that describes that issue. In addition to that issue the ADC is not as linear as it should be but the non-linearity is repeatable and can be removed with some numerical manipulation. The code below corrects the raw readings from the ADC and returns a corrected, linearized reading. The code is not particularly fast because it uses floating point functions. If you care about speed you can put the function into a spreadsheet and generate a lookup table.