RPi GPIO Temp Fan Switch
Zur Navigation springen
Zur Suche springen
1 #!/bin/bash
2 # I'm usin {apt get install pigpiod pigpio} for the GPIO's of the RaspberryPi
3 pigs modes 21 w #set GPIO 21 to mode output
4 while true
5 do
6 let throttle=$(vcgencmd get_throttled | egrep -o '[^|x]*[0-9]+$')
7 let temp=$(vcgencmd measure_temp | egrep -o '[^|=]*[0-9]{2}')
8 let clock=$(vcgencmd measure_clock arm | egrep -o '[^|=]*$')
9 let clockmhz=$clock/1000000
10 let fan=$throttle%80000
11 echo "_____________________________"
12 echo "|CPU Core Temp = $temp *C |"
13 echo "|CPU Throttle Byte = $fan |"
14 if [ $fan != 0 ]
15 then
16 echo "|Throttling, a fan is needed!|"
17 pigs w 21 1
18 else
19 echo "|Normal temp, all fine! |"
20 pigs w 21 0
21 fi
22 let output=$(pigs r 21)
23 echo "|FAN Switch State = $output |"
24 echo "|CPU Clock Mode = $clockmhz MHz|"
25 echo "|____________________________|"
26 sleep 5
27 done