RT temperature sensor calculations help

Thread Starter

zazas321

Joined Nov 29, 2015
936
Hello. I have an RT temperature sensor and I have been given the RT table as below:

I have been trying to find a good way to come up with an equation or a formula to convert the sensor output into the temperature but I have not managed to find a way yet, perhaps someone could point me in the right direction.



TEMPERATURERESISTANCEOUTPUT VOTLAGE
-20​
69693​
2,508227​
-19​
66329​
2,478073​
-17​
60140​
2,416143​
-16​
57294​
2,38442​
-15​
54600​
2,352219​
-14​
52049​
2,319568​
-13​
49633​
2,286501​
-12​
47344​
2,253046​
-11​
45174​
2,219225​
-10​
43117​
2,185084​
-9​
41166​
2,150648​
-8​
39315​
2,11595​
-7​
37559​
2,081041​
-6​
35891​
2,045919​
-5​
34307​
2,01064​
-4​
32803​
1,975255​
-3​
31373​
1,939762​
-2​
30015​
1,904249​
-1​
28723​
1,868697​
0​
27494​
1,833156​
1​
26325​
1,797672​
2​
25212​
1,762255​
3​
24153​
1,726971​
4​
23144​
1,691813​
5​
22184​
1,656871​
6​
21268​
1,622086​
7​
20396​
1,587574​
8​
19564​
1,553296​
9​
18771​
1,519323​
10​
18015​
1,48568​
11​
17294​
1,45239​
12​
16605​
1,419415​
13​
15948​
1,386856​
14​
15320​
1,354662​
15​
14720​
1,322876​
16​
14148​
1,29159​
17​
13600​
1,260674​
18​
13077​
1,230268​
19​
12577​
1,200338​
20​
12099​
1,170905​
21​
11641​
1,141919​
22​
11204​
1,113516​
23​
10785​
1,085573​
24​
10384​
1,058152​
25​
10000​
1,03125​
26​
9632​
1,004856​
27​
9280​
0,979028​
28​
8943​
0,95375​
29​
8620​
0,929001​
30​
8310​
0,904751​
31​
8012​
0,880968​
32​
7728​
0,857858​
33​
7454​
0,83514​
34​
7192​
0,813017​
35​
6940​
0,791361​
36​
6699​
0,770295​
37​
6467​
0,749679​
38​
6244​
0,729543​
39​
6030​
0,709918​
40​
5825​
0,690836​
41​
5628​
0,672231​
42​
5438​
0,654035​
43​
5256​
0,636366​
44​
5080​
0,619055​
45​
4912​
0,602319​
46​
4750​
0,585981​
47​
4594​
0,570061​
48​
4444​
0,554576​
49​
4300​
0,539544​
50​
4161​
0,524877​
51​
4027​
0,510589​
52​
3898​
0,496695​
53​
3774​
0,483208​
54​
3654​
0,470032​
55​
3539​
0,457289​
56​
3428​
0,44488​
57​
3322​
0,432928​
58​
3219​
0,421218​
59​
3119​
0,409758​
60​
3023​
0,398669​
61​
2931​
0,387963​


The first 2 columns of the table are provided. The 3rd row I have calculated myself and I will explain how below.

So I know what resistor values the temperature will give at any given temperature. The way I read the sensor values is by converting it to the voltage via the voltage divider and then connecting this to my ADC_pin of my microcontroller.

Vsupply = 3.3V
R1 = 22Kohms
R2 = Temperature_sensor_output
The following online calculator can be used:
https://ohmslawcalculator.com/voltage-divider-calculator


For example, when the temperature sensor outputs 10Kohms ( at 25 degrees Celcius) , the voltage output will be 1.031V.



Is there any formula that I can use to determine the current temperature ? Since the relationship is not linear, it makes it quite complicated to come up with an equation that I could use for all the possible values. Any help is appreciated.
 

Ian0

Joined Aug 7, 2020
9,667
It's an NTC thermistor - so you need the Hart-Steinhart equation.
https://en.wikipedia.org/wiki/Steinhart–Hart_equation
If you don't need it so accurate you can use
\(
R=R_0e^{B (\frac {1}{T}-\frac {1}{T_0})}
\)
or
\(
log(\frac {R}{R_0})=B (\frac {1}{T}-\frac {1}{T_0})
\)
R0 is the resistance at 298K (25°C), T0 = 298K (25°C)
All temperatures in Kelvin
If you find the datasheet for the device, it should give you the value of B. If not, it is possible to calculate it from two points in the table.
[Edit]
If you have a microcontroller, then the best answer is a look-up table.
If you are only using it over a small temperature range, then TI has a Application Note showing how to make it a bit more linear.
If you really need it linear, use a PTC thermistor (Note that there are two sorts of PTC thermistor, those where the resistance varies linearly with temperature, and those where the resistance changes abruptly at a certain temperature)
A small filament lamp also make a linear temperature sensor.
 
Last edited:

Thread Starter

zazas321

Joined Nov 29, 2015
936
I see. I have tried to calculate B using the formula you have given. Sadly my maths knowledge is long past gone now :D I think the Look up table is would be only choise.

So if I have values from -20 to 61 ( 81 values in total), would I need 81 values in my lookup table to determine what temperature is at any given time?

In that case, how can i determine if its 10,1 or 10,5 or 10.9 degrees? I need my temperature output to be 1 decimal place output
 

ericgibbs

Joined Jan 29, 2010
18,766
hi zazas,
May I ask why you need +/-0.1C resolution, using an RT sensor?
For such a limited., lowish temperature range, there are other types of sensors that would give that resolution.
E
 

Thread Starter

zazas321

Joined Nov 29, 2015
936
This is the requirement for the project. I must display the values with a 0.1 Celcius resolution ( That does not mean that I need to have 0.1 accuracy ). The sensor has already been chosen and I do not have a power to choose a different one. I would If I could!
 

Thread Starter

zazas321

Joined Nov 29, 2015
936
I do not know the constants of stenhart hart equation. I cannot wrap my head around if I can calculate my own constants based on the RT table that I have.
 

Ian0

Joined Aug 7, 2020
9,667
I see. I have tried to calculate B using the formula you have given. Sadly my maths knowledge is long past gone now :D I think the Look up table is would be only choise.

So if I have values from -20 to 61 ( 81 values in total), would I need 81 values in my lookup table to determine what temperature is at any given time?

In that case, how can i determine if its 10,1 or 10,5 or 10.9 degrees? I need my temperature output to be 1 decimal place output
I use a look up table with 1024 values, for each of the 1024 points on a 10-bit A/D
 

Ian0

Joined Aug 7, 2020
9,667
I do not know the constants of stenhart hart equation. I cannot wrap my head around if I can calculate my own constants based on the RT table that I have.
Start with the standard equation:
\(
R=R_0e^{B (\frac {1}{T}-\frac {1}{T_0})}
\)
and fill in the points for T=298K and T=273K, that will give the best accuracy between 0°C and 25°C, with the two resistance values for 273K and 298K which are 27494 and 10000
\(
27494=10000e^{B (\frac {1}{273}-\frac {1}{298})}
\)
then
\(
log (\frac{27494}{10000})=B (\frac {1}{273}-\frac {1}{298})
\)
\(
B=\frac {log (\frac{27494}{10000})}{\frac {1}{273}-\frac {1}{298})}
\)
B=3291
 

Thread Starter

zazas321

Joined Nov 29, 2015
936
Start with the standard equation:
\(
R=R_0e^{B (\frac {1}{T}-\frac {1}{T_0})}
\)
and fill in the points for T=298K and T=273K, that will give the best accuracy between 0°C and 25°C, with the two resistance values for 273K and 298K which are 27494 and 10000
\(
27494=10000e^{B (\frac {1}{273}-\frac {1}{298})}
\)
then
\(
log (\frac{27494}{10000})=B (\frac {1}{273}-\frac {1}{298})
\)
\(
B=\frac {log (\frac{27494}{10000})}{\frac {1}{273}-\frac {1}{298})}
\)
B=3291


Ok, but even knowing the value of B, im not sure how it will help me because the only thing that my microtonroller sees is the adc voltage. I must know the ratio between the temperature resistance output and the voltage that my ADC pin will see
 

ericgibbs

Joined Jan 29, 2010
18,766
hi z,
The equation is not really a problem.
I tried to find a interactive Thermo Plot I did on another Site sometime ago, unfortunately it has not been maintained correctly!

Clip of what's left, it may help you understand the equation.

E
 

Attachments

Ian0

Joined Aug 7, 2020
9,667
Ok, but even knowing the value of B, im not sure how it will help me because the only thing that my microtonroller sees is the adc voltage. I must know the ratio between the temperature resistance output and the voltage that my ADC pin will see
What is your A/D resolution?
 

Thread Starter

zazas321

Joined Nov 29, 2015
936
hi z,
The equation is not really a problem.
I tried to find a interactive Thermo Plot I did on another Site sometime ago, unfortunately it has not been maintained correctly!

Clip of what's left, it may help you understand the equation.

E
I will look into that more, that looks like the circuit in my application

1634286916715.png
 

ericgibbs

Joined Jan 29, 2010
18,766
hi z,
If you only know the R0=10k at say Tkelvin 273C +25C, assume a Beta of say 4K.

Write a dummy test program for your PC, to get the table listing, over the temperature range of interest, using that assumed Beta value and then compare with your known Table values.
Modify Beta as required to get a close match.

Do you follow that OK.?
E
 

Thread Starter

zazas321

Joined Nov 29, 2015
936
hi z,
If you only know the R0=10k at say Tkelvin 273C +25C, assume a Beta of say 4K.

Write a dummy test program for your PC, to get the table listing, over the temperature range of interest, using that assumed Beta value and then compare with your known Table values.
Modify Beta as required to get a close match.

Do you follow that OK.?
E

I know all the resistance values for any given temperature because I have the RT table.

So when the R is 34307 I know that the temperature is -5
When the R 10785 I know that the temperature is 23 degrees.

What I am concerned with, is how do I map these values with my ADC readings. For example my ADC votlage is 0,92V
According to the RT table, that should correspond to 29 degrees. Now how my program should know that 0,92V corresponds to 29 degrees and not something else? I assume the only possible way is to have a lookup table for each value. I thought that it would be possible to avoid using lookup table and come up with an exponential formula instead to calculate a temperature value for any given adc voltage.


I have figured that I do not need the resolution of 0.1 since I have thought of workaround. I will just take 100 readings and make an average. For example if the temperature is fluctuating between 40 and 39 degrees, my average would be something like 39.5
 
Top