🛠 Surveiller température et fréquence du BCM2835

Raspberry Pi Model B (Rev 1, 2012) — Board Sheet · avance · Schéma : IMG-model-b-rev1-avance-2-modelb1-surveillance-thermique.svg — Boîtier du Model B Rev 1 avec son dissipateur, sonde de température, jauges vcgencmd mesure_temp et mesure_clock arm, graphique d'historique avec seuil de throttling à 85 °C

Objectives

Set up continuous monitoring of the BCM2835 SoC: temperature, current ARM frequency, and throttling indicator. The firmware throttles the CPU above 85 °C or when undervoltage is detected — no hard cutoff is documented for this board. You will use vcgencmd, log to a text database, and interpret the get_throttled flag bit by bit.

Hardware

Complete code

#!/bin/sh
# surveil.sh - journalise temperature, clock et drapeau de bridage
# format: horodatage;temp_c;arm_hz;throttled_hex
while true; do
  T=$(vcgencmd measure_temp | sed 's/temp=//;s/.C//')
  C=$(vcgencmd measure_clock arm | cut -d= -f2)
  V=$(vcgencmd get_throttled | cut -d= -f2)
  echo "$(date -Is);${T};${C};${V}" >> /var/log/pisoc.csv
  sleep 30
done

# Lecture rapide :
# vcgencmd measure_temp      -> 'temp=52.3'C (bridage au-dela de 85 C)
# vcgencmd measure_clock arm -> 700000000 au repos nominal
# vcgencmd get_throttled     -> 0x0 = rien a signaler
#   bit 0 sous-tension | bit 2 sous-tension subie | bit 3 bridage thermique
#   bit 4 bridage sous-tension | bits 16-19 = memoire des evenements passes

# Provoquer la montee (test seulement, 256 MB de RAM : pas de stress --vm) :
stress --cpu 1 --timeout 120

Expected verification

tail -f /var/log/pisoc.csv scrolls with consistent temperatures (30-60 °C at idle depending on the case). During stress --cpu 1, the temperature rises and the measured frequency may drop below 700 MHz if the 85 °C threshold is reached; get_throttled then displays a non-zero flag with bit 3 (thermal throttling) or bit 0 (undervoltage) set.

Common errors

Other tutorials for this board

Code examples for this board

← Back to the board 🛠 All tutorials