Electrical – Trying to get (more) accurate readings from thermistor (electronics, math, and code inside)

#nodemcuesp8266thermistor

So I'm trying to get accurate temperature readings off this TDK B57164K472J thermistor…

It's connected in series with a 1 K resistor, and connected to an ESP8266's onboard ADC.

The thermistor has a Beta of 3950, and the datasheet includes a table for resistances between -55 and 150 C.

In my attempt to increase accuracy, I calculate the Beta myself for the interval the thermistor's resistance is in using the following equation:

B = 1 / ( 1 / T1 - 1 / T2 ) log ( R1 / RR2 )

Then I try to determine the temperature using this equation:

T = T1 * B / log ( R1 / R2 ) / ( B / log ( R1 / R2 ) - T1 )

The full code can be viewed here: https://pastebin.com/ECQHruKN

Factors that are possibly affecting accuracy: The ESP's interval voltage reference reads 3.56 V, it's supposed to be 3.3 V, and my multimeter reads 3.26.

I'm not sure about signage, that is whether my terms should be positive or negative, or when they should be the other.

I'm not sure about my circuit… it's simple for me to learn, but I've seen more complex thermistor circuits, I wasn't just sure how to implement them, and even less confident that I was going to be able to troubleshoot them.

Help would be greatly appreciated. Thank you.

Schematic

schematic

simulate this circuit – Schematic created using CircuitLab

Best Answer

The ESP8266 ADC is not really a very good one for instrumentation purposes. I believe it's not very linear (especially for voltages near 0V) and the internal reference voltage might be +/-10% or worse tolerance- loosely specified (with no accuracy limits that I can see, kind of a "bonus" functionality that you shouldn't depend on too much for serious applications).

You also have a pretty crummy NTC and are putting a lot of current through it at high temperatures due to the small 1K resistance (meaning self-heating).

Preferred method for thermistor measurement is ratiometric so the reference voltage cancels out, however the Espressif chip does not bring out the reference voltage, also many boards (I infer that yours is one) include a divider on the input that will load your input at least somewhat, perhaps 220K/100K for a nominal ~3.52V for 1024 counts +/- whatever. 10 bits is none too many for such a wide range of resistance.

There are other ways of measuring a thermistor resistance but they generally require more circuitry, for example to convert resistance to frequency, and switch between a reference resistor or resistors and the thermistor.

Given the huge memory in the ESP8266 you can forget all the fancy math and just build a simple lookup table with 1024 entries, but you'd probably have to build a calibration rig to do that (at least a programmable voltage) to cancel out the errors and the chip is not really specified for any particular accuracy or stability, so most of us would use an external ADC or other circuit so that the accuracy and stability is baked in at the beginning.

Related Topic