Advertisement
Sandbird

raspberry pi fan control

Aug 22nd, 2024 (edited)
18
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. #!/bin/sh
  2. timestamp() {
  3. date +"%Y-%m-%d %T"
  4. }
  5. LOGDIR="/var/log/fan.log"
  6.  
  7. VALUE=55
  8.  
  9. TEMP=`/opt/vc/bin/vcgencmd measure_temp | cut -c6,7`
  10. STATUS=`cat /sys/class/gpio/gpio2/value`
  11.  
  12. if [ -z "${STATUS}" ]; then
  13. echo "2">/sys/class/gpio/export
  14. echo "out">/sys/class/gpio/gpio2/direction
  15. fi
  16.  
  17. #######echo `timestamp` " Info: Temperature: $TEMP">>$LOGDIR
  18. if [ $TEMP -ge $VALUE ] && [ $STATUS -eq 0 ]
  19. then
  20. #######echo `timestamp` " Warning: Fan started.">>$LOGDIR
  21. echo "1">/sys/class/gpio/gpio2/value
  22. elif [ $TEMP -le $VALUE ] && [ $STATUS -eq 1 ]
  23. then
  24. #######echo `timestamp` " Warning: Fan stopped.">>$LOGDIR
  25. echo "0">/sys/class/gpio/gpio2/value
  26. fi
  27.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement