🛠 Lire l'ADC 12 bits et le capteur de température interne du RP2350

RP2350 (generic / RP2350-based boards) · debutant · Schéma : IMG-rp2350-generic-debutant-3-rp2350-adc-capteur-interne.svg — carte RP2350 générique, potentiomètre entre 3V3, GND et curseur sur GP26 (ADC0), puce RP2350 avec bloc ADC 12-bit SAR 500 kSPS et canal température interne, graphique des valeurs 0..4095

Objectives

The RP2350 features a 12-bit SAR ADC, 500 kSPS, with 4 channels on the RP2350A / 8 on the RP2350B, plus an internal temperature channel — but no DAC (RP2350 datasheet). Official SDK examples map ADC channels 0..3 to GP26..GP28. This tutorial covers reading an external voltage with a potentiometer, reading the core temperature, and properly handling the RP2350 ADC's 12-bit scale (0..4095).

Hardware

Full Code

# adc_temp.py — ADC0 (GP26) + canal température interne
from machine import ADC, Pin
import time

# Canal 4 = capteur thermique interne (comme sur RP2040)
sense = ADC(4)
# ADC0 : sur le port rp2, ADC(0) cible l'entrée analogique ADC0 = GP26
pot = ADC(0)

REF = 3.3            # pleine échelle = alimentation IO, ici 3,3 V
FULL = 4095          # l'ADC du RP2350 est nativement 12 bits

def tension(adc):
    return adc.read * REF / FULL        # read = valeur brute 12 bits

def temperature:
    v = tension(sense)
    # formule datasheet famille RP2 : 0,706 V à 27 °C, pente -1,721 mV/°C
    return 27.0 - (v - 0.706) / 0.001721

while True:
    print('pot: %4d  %.3f V   coeur: %.1f C'
          % (pot.read, tension(pot), temperature))
    time.sleep_ms(500)

Expected Verification

Turn the potentiometer: the raw value follows 0 → 4095 and the voltage 0 → 3.3 V linearly. Place your finger on the RP2350: the core temperature rises by a few degrees in a few seconds, then drops back down. The formula 27.0 - (v - 0.706) / 0.001721 is the one for the RP2 family (sensor voltage 0.706 V at 27 °C, slope 1.721 mV/°C) — it gives the core temperature (internal diode), not the ambient temperature: 30–35 °C when held in hand is normal.

Common Errors

Other tutorials for this board

Code examples for this board

← Back to the board 🛠 All tutorials