Erhan Alankus
Published © MIT

Orange Pi Zero Fan Controller

A small circuit that turns on the fan when the soc temperature is higher than the defined limit. Controlled by a bash script run by cron.

AdvancedFull instructions provided3 hours9,724
Orange Pi Zero Fan Controller

Things used in this project

Hardware components

S8050 NPN Transistor
×1
LED (generic)
LED (generic)
×2
Male & female header pins
×1
5V DC Fan
×1
Orange Pi Zero
×1

Story

Read more

Schematics

Schematics

Code

fan-control.sh

SH
Create this file in your home folder. Follow the instructions in the story section to set the cron job that will run this script.
#!/bin/bash

gpio mode 8 out
gpio mode 9 out

temperature=$(< /sys/devices/virtual/thermal/thermal_zone1/temp)
lineToLog="FAN-"

if [ $temperature -gt 45 ]
then
    lineToLog+="ON-"
    lineToLog+="$temperature"
    echo $lineToLog $(date) >> logfan.txt                                   
    gpio write 8 1
    gpio write 9 0                                                      
else
#    lineToLog+="OFF-"
#    lineToLog+="$temperature"
#    echo $lineToLog $(date) >> logfan.txt
    gpio write 8 0                                                          
    gpio write 9 1                                                      
fi

Credits

Erhan Alankus

Erhan Alankus

2 projects • 4 followers

Comments