Reading Teensy internal temperature sensor

Status
Not open for further replies.

WMXZ

Well-known member
I wanted to read on a T3.6 the internal temperature sensor.
So, I said: lets see the tutorial.

In fact there is an example "TemperatureScaled"
Only, I do not get it working.

first, there is an analogRead(1), which gives me random varying values
second, once I changed it to analogRead(70) (according to analog.c, 70 is the temperature 'pin' for T3.6)
I get stable values, but -0.somthing Celsius, It is cold outside but not soo cold, and inside my home temperature should be around 20C.

Are these tutorials any good?

OK, I can read the K66 documentation....
 
Last edited:
My guess is that the examples need to be updated for the different boards.
If I looked at section 39.5.8 for the Temp stuff. It shows something like:
The following equation provides an approximate transfer function of the temperature
sensor.
Temp = 25 - ((Vtemp - VTemp25)/m)
Equation 2. Approximate transfer function of the temperature sensor
where:
• VTEMP is the voltage of the temperature sensor channel at the ambient temperature.
• VTEMP25 is the voltage of the temperature sensor channel at 25 °C.
• m is referred as temperature sensor slope in the device data sheet. It is the hot or cold
voltage versus temperature slope in V/°C.
For temperature calculations, use the VTEMP25 and temperature sensor slope values from
the ADC Electricals table.

Looking at the Electrical PDF for T3.6, I think m is in the range 1.55-1.69 nominal 1.62 mV/C
And Temp25 is in the range 706-726 nominal 716
 
My guess is that the examples need to be updated for the different boards.
If I looked at section 39.5.8 for the Temp stuff. It shows something like:


Looking at the Electrical PDF for T3.6, I think m is in the range 1.55-1.69 nominal 1.62 mV/C
And Temp25 is in the range 706-726 nominal 716

@KurtE,
thanks for doing my homework.
 
I recommend putting the Teensy in the freezer for 30 minutes, then with a thermometer/probe measure the temperature of the MCU and record the analogRead(70) values as the MCU warms to room temperature and higher. Then do a least-squares fit to get coefficients for linear equation. For one of my T3.6, my equation ended as float c = -0.00825*analogRead(70) +351.15; // using analogReadResolution(16)

I found coefficients vary from chip to chip.
 
Last edited:
I recommend putting the Teensy in the freezer for 30 minutes, then with a thermometer/probe measure the temperature of the MCU and record the analogRead(70) values as the MCU warms to room temperature and higher. Then do a least-squares fit to get coefficients for linear equation. For one of my T3.6, my equation ended as float c = -0.00825*analogRead(70) +351.15; I found coefficients vary from chip to chip.

Yes, I guess, I should go this road, as the values from the manual generate unrealistic results.
 
Hi!

today I tried the internal temperature sensor and got very different results when I calibrated the sensor in my room (23 degrees), in the refrigerator (4 degrees) and in the fridge (-18 degrees):

for 10bit resolution, the analogRead(70) produced figures between 219 and 244
for 16 bit resolution, the analogRead(70) produced figures between 14232 and 15638

For both I estimated slope and intercept by linear regression (well, not so accurate with only three points ;-)):

Code:
analogReadResolution(16);
  // for 10bit resolution
  //temperature = -1.8626 * analogRead(70) + 434.5;
  // for 16bit resolution
  temperature = -0.0293 * analogRead(70) + 440.5;

It remains to be seen how much sense this makes for temperature measurement, if individual Teensys differ so much.

All the best,

Frank
 
Last edited:
Status
Not open for further replies.
Back
Top