# Cypress Developer CommunityTM

## transfer function of a temperature sensor

Summary: 15 Replies, Latest post by mahmoud on 15 Oct 2014 04:36 PM PDT
User
121 posts

OK I am new at temperature sensors, I have a STLM20 sensor with an attached below transfer function.

according to my calculations, T should equal the following:

T=85.543*(1.8641-V0)

is this correct? because it is measuring -15.75 degrees C.

Attachments:
User
121 posts

Ok so I solved the negative temperature problem.

the problem is now it is reading too high (27.5 degrees) in a 20 degrees environment.

int main()

{

float T;

int32 voltcount;

float volt;

char str[16];

LCD_Start();

for(;;)

{

T=85.543*(1.8641-volt);

sprintf(str, "%+1.1f", T);

LCD_Position(0u,0u);

LCD_PrintString(str);

CyDelay(1000);

}

}

User
1362 posts

Is this reading by the PSoC5 or by a multimeter?

User
121 posts

by POSC5.

User
33 posts

Is the ADC reference set to a Vdd derived reference or the internal

bandgap 1.024 reference ? If former Vdd is +/- 5% typically out of

a regulator.

You need to perform a complete signal path error analysis to know

what accuracy, precision you will get.

Regards, Dana.

User
9274 posts

The equation given in the PDF is mixing units mV and V. You should take that into account when you rearrange the equation,

And where do you get the Item 85.543 from?

I calculate

Vo - 1.8663V = T[°C] * 11,8639mV/°C = T * 11.8639mV

T = (Vo - 1.8663V) / 0.011.8639 V

As you can see a calibration at the midpoint of your temperature scale could get rid of some errors.

Bob

User
33 posts
User
121 posts

dividing 1/0.0118639 yeilds 85.543.

I have used (0.0 to 2.038 single ended 0 to Vref*2) input range of the ADC with a 100K conversion rate and it gave me more reliable results. but still there is a big difference between the real value and the measured value.

I am switching to the long equation. any idea on how to get the sqaure root of a float number?

User
33 posts

The sensor tolerance is +/- 1.5 C, what are you using to determine T to

compare to PSOC result ? Ice bath one of the easy methods to cal a T

sensor at one point.

GCC and sqrt -

Normal
0

false
false
false

EN-US
X-NONE
X-NONE

MicrosoftInternetExplorer4

/* Style Definitions */
table.MsoNormalTable
{mso-style-name:"Table Normal";
mso-tstyle-rowband-size:0;
mso-tstyle-colband-size:0;
mso-style-noshow:yes;
mso-style-priority:99;
mso-style-qformat:yes;
mso-style-parent:"";
mso-padding-alt:0in 5.4pt 0in 5.4pt;
mso-para-margin-top:0in;
mso-para-margin-right:0in;
mso-para-margin-bottom:10.0pt;
mso-para-margin-left:0in;
line-height:115%;
mso-pagination:widow-orphan;
font-size:11.0pt;
font-family:"Calibri","sans-serif";
mso-ascii-font-family:Calibri;
mso-ascii-theme-font:minor-latin;
mso-fareast-font-family:"Times New Roman";
mso-fareast-theme-font:minor-fareast;
mso-hansi-font-family:Calibri;
mso-hansi-theme-font:minor-latin;}

http://forums.debian.net/viewtopic.php?f=8&t=109385

Regards, Dana.

User
121 posts

I am using an old digital thermometer that is installed in a digital watch. it is currenttly reading 26 degrees while my sensor is reading 24.5 degrees.

1.5 degrees is tolerable error. thanks everyone

User
2 posts

The first thing you should do is to use the equation for V0 that is relevant for your temperature range (given in Table 2 of the attached document). Secondly use a more accurate temperature sensor than using a digital thermometer that is installed in a watch. This will give you true temperature reading to compare with PSOC result.