🛠 Surveiller température et fréquence CPU

Raspberry Pi Model B Revision 2 (2012) — Board Sheet · avance · Schéma : IMG-model-b-rev2-avance-2-modelb2-surveillance-thermique.svg — Model B Rev 2 avec dissipateur, sonde de température et graphique température/fréquence, seuil de throttling à 85 °C repéré sur la courbe

Objectives

Instrument the Model B Rev 2: read the temperature and the ARM11 frequency (700 MHz) via vcgencmd, understand thermal throttling above 85 °C (and in case of undervoltage), and verify an overclock from the config.txt era.

Hardware

Complete code

# Boucle de surveillance: temperature, horloge courante, drapeau de bridage
while true; do
  printf "%s " "$(date +%T)"
  vcgencmd measure_temp
  vcgencmd measure_clock arm
  vcgencmd get_throttled
  sleep 5
done
# Surcharge CPU (ARMv6 mono-cœur) pour declencher le bridage:
yes > /dev/null &
# Overclock classique Rev 2 dans /boot/config.txt (avec refroidissement):
#   arm_freq=900
#   over_voltage=4
#   force_turbo=1
/* rev.c - confirmer le modele avant d'interpretter les mesures.
   Build: gcc rev.c -o rev && ./rev */
#include <stdio.h>
#include <string.h>
int main(void) {
    char line[256];
    FILE *f = fopen("/proc/cpuinfo", "r");
    if (!f) { perror("cpuinfo"); return 1; }
    while (fgets(line, sizeof line, f))
        if (strncmp(line, "Revision", 8) == 0) printf("%s", line);
    fclose(f);
    return 0;
}

Expected verification

measure_temp rises with load then stabilizes; measure_clock arm drops below 900000000 (or 700000000) when the temperature exceeds 85 °C; get_throttled displays a non-zero flag in case of an event, with bits 16 and above signaling an undervoltage.

Common errors

Other tutorials for this board

Code examples for this board

← Back to the board 🛠 All tutorials