Loading...

一个简单的脚本,和python版的一样,只是去除python版的RPi库的依赖。
较为完善的是Golang版

配合crontab做定时任务

#每五分钟执行一次 */5 * * * * /home/pi/fen.sh

fen.sh文件

#!/bin/bash a=$(cat /sys/class/thermal/thermal_zone0/temp) temp=$((a/1000)) pin=14 if [ ! -d "/sys/class/gpio/gpio${pin}" ] then echo $pin > /sys/class/gpio/export fi if [ $temp -lt 50 ] then echo low > /sys/class/gpio/gpio${pin}/direction elif [ $temp -gt 55 ] then echo high > /sys/class/gpio/gpio${pin}/direction fi

新版本系统使用上述脚本失败,使用下面脚本

2025-01-04

#!/bin/bash a=$(cat /sys/class/thermal/thermal_zone0/temp) temp=$((a/1000)) pin=14 if [ $temp -lt 50 ] then pinctrl set $pin ip pd elif [ $temp -gt 55 ] then pinctrl set $pin op dh fi
Last modification:January 4, 2025
如果觉得我的文章对你有用,请随意赞赏