Created
February 22, 2019 19:11
-
-
Save Kalvisan/0036c59c5b1aa7801d96672e9bdf516e to your computer and use it in GitHub Desktop.
Super simple fan controller. I'm using WiringPI library for gpio command
This file contains hidden or 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 | |
| MAX_TEMP=40 | |
| PIN=1 | |
| temp_mili=$(cat /sys/devices/virtual/thermal/thermal_zone0/temp) | |
| temp=$((temp_mili/1000)) | |
| echo "Current temperature: ${temp}C" | |
| echo "Given max temp value ${MAX_TEMP}C" | |
| # prepare GPIO pins | |
| gpio mode $PIN out | |
| if [ "$temp" -ge "$MAX_TEMP" ] ; then | |
| echo "Turning on fan! ${temp}C" | |
| gpio write $PIN 1 | |
| else | |
| echo "Turning OFF fan! ${temp}C" | |
| gpio write $PIN 0 | |
| fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment