🛠 Surveillance thermique et fréquence : DVFS, seuils et bridage
Objectives
Understand the thermal management of the Pi 4B: the hardware limit is 85°C, ARM throttling occurs strangely between 80 and 85°C, there is no software limit (unlike the 3B+), and the DVFS engine uses steps of 1500/1000/750/600 MHz. You will build a monitor that logs temperature, frequency, and throttling bits.
Hardware
- Raspberry Pi 4B (heatsink or fan strongly recommended)
- sudo apt install stress-ng
- Terminal or SSH session
Complete code
#!/usr/bin/env bash
# thermal-log.sh - journalise temperature, frequence DVFS et etat de bridage
while true; do
T=$(vcgencmd measure_temp | cut -d= -f2)
F=$(cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq)
TH=$(vcgencmd get_throttled | cut -d= -f2)
V=$(vcgencmd pmic_read_adc | grep EXT5V_V | awk '{print $NF}')
echo "$(date +%T) temp=$T freq=${F}Hz throttled=$TH 5V=${V}"
sleep 1
done
# Dans un autre terminal, monter en charge :
sudo stress-ng --cpu 4 --timeout 120s
# Decoder get_throttled : bit0 sous-tension, bit2 bridage thermique,
# bit3 frequence sous le max, bit16 sous-tension passee, bit20 bridage passe.
Expected verification
Under stress-ng, the frequency drops in steps (1500 then 1000 MHz) when the temperature approaches 80°C, get_throttled becomes 0x50005 (thermal throttling + frequency capped), then returns to 0x0 upon cooling. EXT5V_V should remain close to 5.0 V.
Common errors
- Believing there is a hardware throttle at 80°C: the hard cut is at 85°C, the 80-85°C zone is progressive throttling.
- Not reading get_throttled: bits 16/20 signal past incidents that are otherwise invisible.
- Closed case without a heatsink: the Pi 4 runs hot, this is documented.
- Confusing scaling_cur_freq (instantaneous) with the configured max frequency arm_freq=1500.
- Underpowering: undervoltage causes the same throttling as heat.
Other tutorials for this board
Code examples for this board
led_blink.pyPythonbutton_led.pyPythonservo_sweep.pyPythondht_temp.pyPythonoled_i2c.pyPythonmcp3008_read.pyPython