The sketch works for both Arduino and ESP32 by just changing the line:
bool esp32 = true; // change to false when using Arduino
The sketch assumed that NTC Thermistor with 10k resistance at 25 degree Celcius and B parameter of 3950 to be used, if you have an Thermistor with 100k value, you may need to change some of the parameters accordingly.
To address the ESP32 ADC non-linear issue, a lookup table is used to correct the non-linearity. You may need to generate your own lookup table as it varies from device to device due to the variation of ESP32 internal reference voltage. The code for generating the lookup table is originally written by Helmut Weber and a modified and big-fixed version can be found here.
The ESP32 is much noisy compare to Arduino. Add a 0.1uF capacity on Vout would help a little bit in smoothing out the noise or alternative write a filter algorithm to handle it.
Arduino ADC reading from thermistor
ESP32 ADC reading from thermistor
For more detail discussion and references, read my blog post on the subject.