# Thermistor help

#### chimera

Joined Oct 21, 2010
122
Hello. Im trying to figure how to linearize a thermistor (10 KΩ). I want to learn to do this so that I can send the data to a uC.

I have already worked with LM35 but I am not pleased with its result. Its not to sensitive or accurate. It was easy to linearize the LM35 becaz of its straight forward voltage to temp graph (a basic linear equation).

However, I would like to know how to work with a thermistor. Eventually, I want to find a good approximation over a predicted range of temperature..say 25°C to 55°C.

Any ideas where to begin Thanks

#### MrChips

Joined Oct 2, 2009
21,635
You need to tell us a bit more than this.

1. What is the part number of the thermistor?
2. How do you plan on digitizing the thermistor?
3. What MCU are you planning on using?
4. How many bits of digitized data are you planning on having?

#### steveb

Joined Jul 3, 2008
2,436
Hello. Im trying to figure how to linearize a thermistor (10 KΩ). I want to learn to do this so that I can send the data to a uC.

I have already worked with LM35 but I am not pleased with its result. Its not to sensitive or accurate. It was easy to linearize the LM35 becaz of its straight forward voltage to temp graph (a basic linear equation).

However, I would like to know how to work with a thermistor. Eventually, I want to find a good approximation over a predicted range of temperature..say 25°C to 55°C.

Any ideas where to begin Thanks
You can't fully linearize it at the hardware level. However, you can make it more linear by placing a resistor in series with it and then placing a resistor in parallel with that and then placing a resistor in series with that. Then choose the three resistor values that best fit to a line, under the assumption that you will drive it with a current source. A current source drive tends to make it more linear than a voltage divider arrangement. Once you determine the circuit structure formulas, you can fit to a line using standard linear regression techniques and the thermistor data.

The final linearization must be done at the code level, but that is easier if you first linearize it with resistors. In addition to linearizing, you will want to calibrate each thermistor individually for gain and offset after the general linearization (both hardware and software linearization) that you apply to to all devices.

#### pilko

Joined Dec 8, 2008
213
If you check the resistance from the chart for a temp half way between the two limits, ie 40*, then put a resistor in // of the same value. The graph will be fairly linear within that range.
Better to use a DS18B20 digital temp sensor.

pilko

#### crutschow

Joined Mar 14, 2008
25,250
......................

I have already worked with LM35 but I am not pleased with its result. Its not to sensitive or accurate. It was easy to linearize the LM35 becaz of its straight forward voltage to temp graph (a basic linear equation).

..............
The thermistor is likely to be no more accurate then the LM35. If you need more sensitivity from the LM35 just add an op amp non-inverting amplifier. You can add some offset to that if you want to center the output over the desired temperature range to match the uC input voltage range.

#### joeyd999

Joined Jun 6, 2011
4,425
The thermistor is likely to be no more accurate then the LM35.
You are incorrect. The LM35 has best case accuracy of 0.25C at room temperature and 0.75C across the operating temperature range.

Precision thermistors that have an accuracy of 0.1C from 0-70C are available at Digikey, for example:

PS502J2

The nice thing about these is you don't need a voltage reference for accurate conversion. Just operate them ratiometrically with Vref as Vdd. Then, using a table (generated as described below) and piecewise-linear approximation, compute the actual temperature.

The only thing to watch out for is self-heating. They will generate a 1C error for every mW dissipated (in still air), but even this can be corrected and/or minimized.

If you check the resistance from the chart for a temp half way between the two limits, ie 40*, then put a resistor in // of the same value. The graph will be fairly linear within that range.
Also wrong. Series a fixed resistor with the thermistor (as a voltage divider). Pick a value for the resistor close to the midpoint of your desired temp range, as per pilko's suggestion. Then, plot Vout vs. temp (using the mfgrs temperature table) in a spreadsheet. Then, adjust your fixed value till the slope is steepest within the range of interest.

For best results. when you've determined the proper value, use a 0.1% fixed resistor.

#### crutschow

Joined Mar 14, 2008
25,250
You are incorrect. The LM35 has best case accuracy of 0.25C at room temperature and 0.75C across the operating temperature range.

Precision thermistors that have an accuracy of 0.1C from 0-70C are available at Digikey, for example:
True. But I should have elaborated on my statement. After you use typical 1% bias resistors for the thermistor circuit you will not get such high accuracy unless you calibrate the circuit, which means the accuracy is no better than your calibration. Unless you have access to a calibration lab that is unlikely to be better than the LM35 intrinsic accuracy.

#### joeyd999

Joined Jun 6, 2011
4,425
True. But I should have elaborated on my statement. After you use typical 1% bias resistors for the thermistor circuit you will not get such high accuracy unless you calibrate the circuit, which means the accuracy is no better than your calibration. Unless you have access to a calibration lab that is unlikely to be better than the LM35 intrinsic accuracy.
With the part I mentioned, and a 0.1% resistor, error is less than 0.2C (ignoring self heating), and this is *without* requiring a precision reference for the A/D conversion.

Edit: Also, no calibration required.

BTW...we are splitting hairs! OP never indicated what accuracy is required.

Last edited:

#### steveb

Joined Jul 3, 2008
2,436
In reference to my post above, I can give an example of placing a 10 K resistor in parallel with the 10K thermistor and then placing a 5 K resistor in series with that parallel combination. The total value is still 10 K at 25 deg C, but the response is more linear, at the expense of being less sensitive.

I've included two plots. I use two typical negative temperature coefficient thermistor curves for the comparison.

The first plot shows how both of these curves are more linear if the additional resistors are used. It is also clear that sensitivity is sacrificed for linearity. Note that it is implied that a current source will be driven through the network to maintain the better linearity. The use of a voltage divider will make it more nonlinear.

The second plot allows the linearity to be seen more clearly. Here the 10 K resistance is subtracted from both resistance curves, and then the modified resistance in multiplied by 10 times to make it clear that the improved linearity is really there.

It is possible to get better linearity with more complicated resistor networks and with optimized resistance values, however, this takes time to figure out, and I leave that to the OP, if this seems interesting to him. This type of curve is much easier to linearize in code than the raw resistance curve. I'm not saying this is necessarily the best option because tradeoffs are involved, but it is an option under the right circumstances.

#### Attachments

• 20.6 KB Views: 34
• 25.1 KB Views: 32

#### joeyd999

Joined Jun 6, 2011
4,425
In reference to my post above, I can give an example of placing a 10 K resistor in parallel with the 10K thermistor and then placing a 5 K resistor in series with that parallel combination. The total value is still 10 K at 25 deg C, but the response is more linear, at the expense of being less sensitive.

I've included two plots. I use two typical negative temperature coefficient thermistor curves for the comparison.

The first plot shows how both of these curves are more linear if the additional resistors are used. It is also clear that sensitivity is sacrificed for linearity. Note that it is implied that a current source will be driven through the network to maintain the better linearity. The use of a voltage divider will make it more nonlinear.

The second plot allows the linearity to be seen more clearly. Here the 10 K resistance is subtracted from both resistance curves, and then the modified resistance in multiplied by 10 times to make it clear that the improved linearity is really there.

It is possible to get better linearity with more complicated resistor networks and with optimized resistance values, however, this takes time to figure out, and I leave that to the OP, if this seems interesting to him. This type of curve is much easier to linearize in code than the raw resistance curve. I'm not saying this is necessarily the best option because tradeoffs are involved, but it is an option under the right circumstances.
So, to be clear, you are recommending the following:

1. Two precision resistors (for linearization);
2. A precision current source (to drive the network);
3. A precision voltage source (as a reference for the A/D converter);
4. A voltage vs. temperature curve equation (for temperature estimation based upon input voltage vs. Vref);
5. Code to preform the above equation.

I suggested the following:

1. One precision resistor;
2. A look-up table (easily derived from the mfg. data sheet);
3. Code to preform piece-wise approximation (interpolation between datapoints).

I think what's important here is the OP asked originally, "Im trying to figure how to linearize a thermistor (10 KΩ). I want to learn to do this so that I can send the data to a uC".

The answer is, he doesn't have to. The CPU can do the linearization. IMHO, the front-end should only be responsible for maximizing the dynamic range (i.e. sensitivity) of the incoming signal. And with as little contributed error as possible. A single resistor does this!

#### steveb

Joined Jul 3, 2008
2,436
So, to be clear, you are recommending ...

I suggested the following ...

I think what's important here is the OP asked originally, "Im trying to figure how to linearize a thermistor (10 KΩ). I want to learn to do this so that I can send the data to a uC".

The answer is, he doesn't have to. The CPU can do the linearization.
To be clear, I'm not recommending my suggestion, but am just providing information that seems relevant to the question.

I think your ideas and comments are very good, and as I said in my above post about my suggestion, "I'm not saying this is necessarily the best option because tradeoffs are involved, but it is an option under the right circumstances." I really don't know the details of the OPs application, so it's better to provide more information and let him decide.

#### pilko

Joined Dec 8, 2008
213
@joey99,
You stated that steveb and I were "incorrect/wrong" in our methods to improve liniarization.---In fact we were NOT wrong. Different recommendations from yours do not make them wrong.

pilko

#### joeyd999

Joined Jun 6, 2011
4,425
@joey99,
You stated that steveb and I were "incorrect/wrong" in our methods to improve liniarization.---In fact we were NOT wrong. Different recommendations from yours do not make them wrong.
Steveb was incorrect in saying that "The thermistor is likely to be no more accurate then the LM35." I gave an example where a particular thermistor's basic accuracy is 250% better at room temperature, and 750% better across the operating temperature range.

I further elaborated that, with only a single precision resistor, and no voltage or current sources, the overall accuracy can be held to less than 0.2C, or 350% better than the *best* accuracy achievable by the LM35 (without manual adjustment in either case). Additionally, the use of an LM35 solution requires an accurate Vref for digitization.

WRT your comment, I was considering the OP's original question, which was:

Im trying to figure how to linearize a thermistor (10 KΩ). I want to learn to do this so that I can send the data to a uC.

...

However, I would like to know how to work with a thermistor. Eventually, I want to find a good approximation over a predicted range of temperature..say 25°C to 55°C.
This is a two part question: 1. Linearization, 2. Digitize to a CPU. I was addressing the whole question, not just the linearization part.

Simply paralleling some resistors does not get the temperature data into a CPU. I was trying to illustrate that the OP could get high accuracy with a simple voltage divider and no additional precision references.

You provided a solution to the first part of the question, without further explanation of how to get the resulting temperature dependent resistance value accurately into the CPU. Perhaps the use of the word "wrong" was too strong. But at best, it was incomplete.

You are correct: there are many ways to skin a cat...but few good ones.

EDIT: SteveB *did not* make the above referenced comment re thermistor vs. LM35 accuracy. I sincerely apologize for the misattribution!

Last edited:

#### pilko

Joined Dec 8, 2008
213
@ joeyd999,

"You are correct: there are many ways to skin a cat...but few good ones".

I guess you are inferring then that the only good ways are your ways.

pilko

#### steveb

Joined Jul 3, 2008
2,436
Steveb was incorrect in saying that "The thermistor is likely to be no more accurate then the LM35."
Excuse me sir !

I never said that.

Personally, I haven't done a direct experimental comparison to make a statement either way on that question.

#### joeyd999

Joined Jun 6, 2011
4,425
Excuse me sir !

I never said that.

Personally, I haven't done a direct experimental comparison to make a statement either way on that question.
My most humblest apologies, Steveb. I got the posts mixed up. Crutschow made that comment. I will edit my comment to reflect my mistake!

#### joeyd999

Joined Jun 6, 2011
4,425
@ joeyd999,

"You are correct: there are many ways to skin a cat...but few good ones".

I guess you are inferring then that the only good ways are your ways.

pilko
No! I occasionally do things wrong. As a matter of fact, I made some smoke yesterday that brought one of our assembly lines to a halt

But I always try to learn to do things better.

My posts on this thread were for the benefit of the OP. I was trying to illustrate what I consider to be one of the best ways to get accurate temperature info into a CPU. I'll admit, it's not the *cheapest* way: a precision thermistor can cost up to \$8 in single quantities. But they are nice because they are easy to use and accurate. And linearization can be done in code, and there need be no dependency on other accurate components. And its hard to do wrong.

In this case, given the OP's question, yes, I think this is the best solution. You are free to disagree!

#### pilko

Joined Dec 8, 2008
213
A cheap, simple and accurate way is also the Dallas DS18B20 (10 bit capability), that I already mentioned.

pilko

#### MrChips

Joined Oct 2, 2009
21,635
You need to tell us a bit more than this.

1. What is the part number of the thermistor?
2. How do you plan on digitizing the thermistor?
3. What MCU are you planning on using?
4. How many bits of digitized data are you planning on having?
Have you noticed how the conversation can get heated and go on for a very long time with no signs of the OP? I never got a response on my questions at post #2.

I have to side with joeyd. We can maximize the sensitivity of the thermistor and then deal with the linearization on the MCU.

You don't even need an ADC to digitize the thermistor. A common solution is to use a capacitor and measure frequency or period, depending on whether the thermistor exhibits positive or negative temperature coefficient. You can easily get 12 to 16-bit resolution using this technique. No additional components required!