🛠 Surveiller température et fréquence sous charge quad-core
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
- Raspberry Pi 2 Model B with a healthy power supply (drops in 5 V also cause throttling)
- Optional heatsink (the board works bare but heats up)
- SSH terminal or console
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
- Interpreting 0x50005 or 0x30002: the bitmap is cumulative (bits 16+ = history); clear it with
vcgencmd set_throttled=0if supported, otherwise reboot. - Blaming the temperature when the cause is electrical: quad-core transients cause a marginal 5 V supply to drop — check the undervoltage bit first.
- Forgetting that the threshold depends on the firmware: 85 °C is the standard ceiling for the Pi 2 family.
- Comparing v1.1 and v1.2: the BCM2837 (A53) on v1.2 boards are faster per cycle than the BCM2836 (A7); the figures are not interchangeable.
Other tutorials for this board
Code examples for this board
led_blink.pyPythonbutton_led.pyPythonservo_sweep.pyPythondht_temp.pyPythonoled_i2c.pyPythonmcp3008_read.pyPython