🛠 Surveiller température et fréquence sous charge quad-core

Raspberry Pi 2 Model B (2015) — Board Sheet · avance · Schéma : IMG-model-2b-avance-2-model2b-thermique.svg — les 4 cœurs Cortex-A7 du Pi 2 en charge, sonde de température affichant le seuil de throttling à 85 °C et courbe de fréquence qui plafonne

Objectives

The Pi 2 is the first quad-core Raspberry Pi: its four Cortex-A7 cores running at 900 MHz heat up more than the Pi 1 and throttle above 85 °C (or in case of undervoltage). This tutorial teaches you how to measure temperature, frequency, and throttling flags with vcgencmd, load the four cores with a multiprocessing test, and interpret the get_throttled bitmap.

Hardware

Full code

# Suivi temps reel : temperature + frequency + etat de bridage
watch -n 1 'vcgencmd measure_temp; vcgencmd measure_clock arm; vcgencmd get_throttled'
#!/usr/bin/env python3
"""burn.py — teste les 4 cœurs : serial vs parallel (Pi 2 quad-core)."""
import multiprocessing as mp
import time

def burn(n):
    x = 0
    for i in range(n):
        x += i * i
    return x

if __name__ == "__main__":
    jobs = [20_000_000] * 4
    t0 = time.time
    for _ in map(burn, jobs):                 # reference serielle
        pass
    serial = time.time - t0
    t0 = time.time
    with mp.Pool(4) as pool:                  # 4 cœurs, 1 tâche chacun
        pool.map(burn, jobs)
    parallel = time.time - t0
    print(f"serial {serial:.1f}s vs parallel {parallel:.1f}s "
          f"(speedup {serial/parallel:.1f}x on {mp.cpu_count} cores)")

Expected verification

At idle: ~40-45 °C, clock at 900000000 Hz, get_throttled = 0x0. During a full quad-core burn: the temperature rises; if it reaches 85 °C, measure_clock drops below 900 MHz and get_throttled displays 0x2 (thermal throttling). A 0x1 or 0x5 indicates undervoltage: change the power supply before blaming the cooling. The parallel speedup should approach 3-4×.

Common errors

Other tutorials for this board

Code examples for this board

← Back to the board 🛠 All tutorials