Skip to content

Instantly share code, notes, and snippets.

View giacomolanzi's full-sized avatar
🏝️
Working remotely

Giacomo Lanzi giacomolanzi

🏝️
Working remotely
View GitHub Profile
@enwi
enwi / fan_control.sh
Last active November 17, 2019 13:55
Little shell script that reads the temperature of a raspberry pi cpu and a connected harddrive using smartctl and controls a GPIO pin where a fan should be connected.
#!/bin/bash
c_FAN=26 # gpio pin the fan is connected to
c_MIN_TEMPERATURE=45 # temperature in degrees c when fan should turn on
c_TEMPERATURE_OFFSET=2 # temperarute offset in degrees c when fan should turn off
c_HARDDRIVE="sda" # name of your harddrive
temperature_offset=$(( $c_MIN_TEMPERATURE - $c_TEMPERATURE_OFFSET ))
fan_state=0