Whether you need a fan or not will probably depend on what sort of case
you have. If it provides good airflow, or incorporates some sort or
heatsink, then running pCP/LMS isn't, in my experience, going to
overheat the CPU.
I have my PI4 inside an amplifier enclosure, where the ambient
temperature can get quite high but the airflow is reasonable. I have a
fan set to come on at 68 degrees, and I find that the fan is not coming
on at all now that it's winter. At the height of summer, and perhaps
with the sun falling on the amp through the window, the fan would
occasionally come on.
I control my fan with my own script (fan.sh), which I launch as a User
Command from the pCP 'Tweaks' section (/home/tc/fan.sh -g 4 -t 68 -s 5
-l). In case anyone else might find it useful, my script is as
follows:
Code:
--------------------
# Ctrl-C handler for clean shutdown
shutdown()
{
# turn fan off
echo "0" > /sys/class/gpio/gpio$pin/value
echo -e "\nStopping Fan"
exit 0
}
usage()
{
echo " usage: $0 [-g] [-t] [-s] [-l] [-v]"
echo " -g GPIO output pin to control fan (BCM)"
echo " -t Temperature to turn fan on"
echo " -s Update rate in seconds"
echo " -l Log data to file (e.g.
/home/tc/fanlogs/fan_$(date +%d-%m-%Y)).log"
echo " -v Verbose"
echo ""
echo " The turn-on temperature is stored in
/home/tc/ontemp.dat"
echo " To set a new temperature while the script
is running,"
echo " edit that file, or run
/home/tc/SetFanTemp.sh <new temp>"
echo ""
exit 1
}
# Trap Ctrl-C, call 'shutdown'
trap shutdown SIGINT
# defaults
pin=4
ontemp=58
nsecs=2
log=0
verbose=0
# handle command line parameters
if [ "$1" == "" ] || [ "$1" == "--help" ]; then # no command line parameters,
or --help
usage
exit
fi
while getopts "g:t:s:lvh" opt; do
case ${opt} in
g )
# fan control pin (GPIO BCM)
pin=$OPTARG
;;
t )
# CPU temp to turn fan on
ontemp=$OPTARG
;;
s )
# Update rate in seconds
nsecs=$OPTARG
;;
l )
# Log data to file
log=1
;;
v )
# verbose = report every 2 seconds
verbose=1
;;
h )
usage
;;
esac
done
# save ontemp to file, so that value can be changed externally
echo $ontemp > /home/tc/ontemp.dat
if [ $verbose == 1 ]; then
echo "ontemp = $ontemp (stored in /home/tc/ontemp.dat)"
echo "pin = $pin"
echo "update rate = $nsecs"
fi
# initialise duty cycle variables
intvls=0
intvls_on=0
# Export pin to userspace
if [ ! -e /sys/class/gpio/gpio$pin ]; then
echo "$pin" > /sys/class/gpio/export
fi
# set control pin to output mode
echo "out" > /sys/class/gpio/gpio$pin/direction
# set pin to "0" to turn fan off initially
echo "0" > /sys/class/gpio/gpio$pin/value
fanstate="OFF"
# check temperature once every nsecs and set fan accordingly
while true; do
# read ontemp from file
ontemp=$(cat /home/tc/ontemp.dat)
# CPU temp to turn fan off - set to one degree lower to reduce on/off
frequency
offtemp=$(( $ontemp-1 ))
# read current CPU temperature
cpu_temp=$(cat /sys/devices/virtual/thermal/thermal_zone0/temp)
cpu_temp=$(( ($cpu_temp+500)/1000 )) # get nearest integer
if [ "$cpu_temp" -ge $ontemp ]; then
# turn fan on
echo "1" > /sys/class/gpio/gpio$pin/value
fanstate="ON "
fi
if [ "$cpu_temp" -lt $offtemp ]; then
# turn fan off
echo "0" > /sys/class/gpio/gpio$pin/value
fanstate="OFF"
fi
# calculate duty
intvls=$((intvls+1))
if [ $fanstate == "ON" ]; then
intvls_on=$((intvls_on+1))
fi
duty=$((100*intvls_on/intvls))
timestamp=$(date +"%T")
# datestamp=$(date +"%d/%m/%y")
# verbose output to terminal
if [ $verbose == 1 ]; then
echo "$timestamp CPU Temperature = "$cpu_temp"/$ontemp; Fan =
$fanstate; Duty = $duty% of $((intvls*$nsecs)) seconds"
fi
# concise output to logfile
if [ $log == 1 ]; then
# logfile name reconstructed for every output, so that a new
file is created every day
logfile="/home/tc/fanlogs/fan_"$(date +%d-%m-%Y)".log"
echo "$timestamp $cpu_temp/$ontemp $fanstate" >> "$logfile"
fi
sleep $nsecs
done
--------------------
------------------------------------------------------------------------
chill's Profile: http://forums.slimdevices.com/member.php?userid=10839
View this thread: http://forums.slimdevices.com/showthread.php?t=110727
_______________________________________________
unix mailing list
[email protected]
http://lists.slimdevices.com/mailman/listinfo/unix