🛠 Entrées analogiques et capteur de température interne : le ADC et ses limites

Teensy 4.0 · debutant · Schéma : IMG-teensy-40-debutant-3-teensy40-analogique-temperature.svg — Teensy 4.0 : potentiomètre 10 kΩ entre 3,3 V et GND, curseur vers A0 ; encart sur la puce MIMXRT1062 avec la mention « capteur de température sur la puce » et retour du Moniteur série affichant volts et degrés.

Objectives

Leverage the 14 analog inputs and the 2 ADC converters of the Teensy 4.0, while understanding their real limitations: fixed 0–3.3 V range, no AREF pin (analogReference has NO effect), hardware resolution up to 12 bits but — quoting Paul Stoffregen — “effective number of bits is about 10” due to noise. You will also add the on-chip temperature sensor, useful for monitoring heating during overclocking.

Hardware

Complete code

// Lecture A0 + température du die.
#include <InternalTemperature.h>

void setup {
  Serial.begin(9600);
  analogReadResolution(10);      // 0..1023 ; au-delà, du bruit sur T4
}

void loop {
  int raw = analogRead(A0);                 // 0..1023
  float volts = raw * (3.3f / 1023.0f);     // référence fixe 3,3 V
  float degC = InternalTemperature.readTemperatureC;
  Serial.printf("A0 = %d (%.2f V)  die = %.1f C\n", raw, volts, degC);
  delay(500);
}

Expected verification

Turn the potentiometer: the value follows between 0 and 1023 and the volts remain below 3.30 V. Rub the chip with your finger or blow on it: the die temperature moves by a few tenths of a degree. Home calibration track: record the temperature at rest (cold board) then after a few minutes of intensive calculation — the M7 at 600 MHz heats up noticeably, which becomes critical in overclocking (≥912 MHz requires cooling according to community tests).

Common errors

Other tutorials for this board

Code examples for this board

← Back to the board 🛠 All tutorials