-
Notifications
You must be signed in to change notification settings - Fork 5
Chip Temperature
Frank edited this page Mar 18, 2020
·
13 revisions
The internal temperature can be read out at different resolutions. Try changing the resolution and you will get very different results. Also, the readout values have to be treated with a calibration function using an intercept and a slope. These have to be empirically derived using a reference thermometer. It seems the intercept and slope values differ largely between individual Teensys.
void setup() {
while (!Serial);
analogReadResolution(16);
}
void loop() {
float temperature;
// for 10bit resolution
//temperature = -1.8626 * analogRead(70) + 434.5;
// for 16bit resolution
temperature = -0.0293 * analogRead(70) + 440.5;
Serial.print(temperature);
Serial.println("°C");
delay(500);
}
The Teensy 4 core has an inbuilt function:
extern float tempmonGetTemp(void);
void setup() {
while (!Serial);
}
void loop() {
Serial.print( tempmonGetTemp() );
Serial.println("°C");
delay(500);
}
Note: Temperature conversion formula from degree Celsius to Fahrenheit is given by
F = (C * 9.0f / 5.0f) + 32.0f
Teensy is a PJRC trademark. Notes here are for reference and will typically refer to the ARM variants unless noted.