3.3v thermistor voltage reference ADC8
Break the problem down a bit to understand what's going on here:

1) Your thermistor is a variable resistor whose value can vary as its temperature changes.

2) The resistance change will not be linear over a large enough temperature range. The Steinhart-Hart Equation referenced in your code is a widely used third-order approximation to the relationship between temperature and resistance for a thermistor. The three seemingly random looking numbers in your Thermistor function are the Steinhart-Hart coefficients, which may not be the right values for your thermistor (see datasheet if possible).

3) When you put the thermistor in series, you form a standard voltage divider like in the schematic below. Following Ohm's Law, the output voltage from the divider is given by:

$$V_{adc} = {R_2 \over R_{thermistor} + R_2} * V_1$$

4) You need to know the range of resistance for your thermistor to determine the voltage range you will see with your second resistor at 100k ohm. It would be best to have the datasheet for your thermistor, but you could attempt to reverse engineer it by taking a few measurements.

5) Your Arduino is measuring the voltage at the ADC pin relative to a reference voltage and converting to an integer in [0, 1023] (10-bit ADC can measure 2^10=1024 unique values). If the voltage at the pin is equal to (or higher than) the reference voltage, then it should read 1023, and if the voltage is zero then it will read 0.

6) By default the Arduino will use supply voltage as the ADC voltage reference (so either 5V or 3.3V depending on how you are powering it). According to this reference, you can change the voltage reference for the Arduino Mega's ADC to be one of several different values, including providing your own external voltage reference.

7) Ideally, your voltage divider would provide a voltage swing from zero to the ADC reference voltage over the temperature range you intend on measuring to provide the maximum precision (most efficient use of your available 10 bits). You will not get exactly Vref or zero volts out of the divider, but you get the idea...







simulate this circuit &ndash; Schematic created using CircuitLab