视频加载失败

【树莓派】温控风扇脚本(shell版)

146 字
1 分钟
【树莓派】温控风扇脚本(shell版)
【树莓派】温控风扇脚本(shell版)

一个简单的脚本,和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

支持与分享

如果这篇文章对你有帮助,欢迎分享给更多人或打赏支持!

打赏
【树莓派】温控风扇脚本(shell版)
https://rehtt.com/posts/235/
作者
Rehtt
发布于
2020-09-06
许可协议
CC BY-NC-SA 4.0

评论区

Profile Image of the Author
Rehtt
Hello, I'm Rehtt.
公告
欢迎来到我的博客!
分类
标签
最新动态
站点统计
文章
150
分类
17
标签
73
总字数
67,772
运行时长
0 天
最后活动
0 天前
站点信息
构建平台
Local
博客版本
Firefly v6.16.8
文章许可
CC BY-NC-SA 4.0
文章目录