If your Raspberry Pi is overheating, a common solution is to add a fan. Sometimes it's not feasible and in most cases the computer is runnning smoothly without a fan.
To limit heating, CPU throttling is a solution which keeps your computer not crashing during long compiles or so, but gives out the peak performance for shorter period of times. It depends of your application, if this is good enough solution. For me it is. I like my computer with no moving parts even though it sometimes leads to throttling.
CPU speeds speed_throttle
and speed_max
are for Raspberry Pi 4 and
tuned for my environment. To check available frequencies, see file
/sys/devices/system/cpu/cpufreq/policy0/scaling_available_frequencies
.
gcc -Wall -o throttle throttle.c
License: Public domain