Thermistors are a type of variable resistor that change resistance with changes in temperature. In order to get an accurate reading from your thermistor, you first have to calibrate it. You can make use of the Steinhart-Hart Equation to make sense of voltage input data from your thermistor. Using this equation, temperature = 1/(A+B*ln(R)+C*(ln(R))^3)
, where A, B, and C are coefficients you must solve for and R is resistance. The easiest way to get the coefficient values for your particular thermistor is to look up its datasheet. On the datasheet, there should be Resistance-Temperature Curve plots. You can pick points from these plots and plog them into a calculator (like this one
) to get the coefficient values for A, B, and C. The points I used are marked by the red circles on the plot. Ideally, you want to pick values at the top, middle, and bottom of the range you expect to use the thermistor in to get the most accurate curve. Once you have these values, you can plug them into the "Thermistor" function in the code.