Created
January 7, 2017 06:47
-
-
Save tnishinaga/f3a435f82c538bef828c72d2b96e7d12 to your computer and use it in GitHub Desktop.
Auto fan control script for Raspberry Pi
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
temp_on=50000 | |
temp_off=45000 | |
#connected to GPIO18 | |
fan_gpio=18 | |
temp=`cat /sys/class/thermal/thermal_zone0/temp` | |
# init GPIO | |
gpio -g mode $fan_gpio out | |
# get status gpio | |
fan_status=`gpio -g read $fan_gpio` | |
if [ $fan_status = 0 ] && [ $temp -ge $temp_on ]; then | |
# fan start | |
gpio -g write $fan_gpio 1 | |
fi | |
if [ $fan_status = 1 ] && [ $temp -le $temp_off ]; then | |
# fan stop | |
gpio -g write $fan_gpio 0 | |
fi | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment