Skip to content

Commit 4ca5f77

Browse files
committed
readme edited - wiring schematic included
1 parent 77c8698 commit 4ca5f77

File tree

4 files changed

+25
-5
lines changed

4 files changed

+25
-5
lines changed

GPIO.png

202 KB
Loading

README.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,23 @@
11
# raspberrypi-fan-controller
2+
3+
This program serves to turn your 5v-fan on/off when the pi reaches a certain temperature. This is set to 60°c by default and will turn off when cooled to 45°c. The script utilizes a controlled infinte loop to consisitantly monitor the temperature every 10 seconds. It therefore should be setup so as to run when the pi is first turned on.
4+
5+
## Setup
6+
7+
There are numerous methods you can use, this is just the way i've applied it. You can use an S8050 transistor to communicate with the pi & control the fan. The below schematic shows the basic layout, controls are applied via GPIO14.
8+
9+
![schematic](wiring_schematic.png)
10+
11+
## Adjusting settings
12+
13+
Alter the GPIO pin if GPIO14 is already in use.
14+
15+
fanPin = 16
16+
17+
You can change the temperature which engages the fan by changing the if statements, the below example changes the script so the fan engages at 70°c.
18+
19+
20+
if temperature >= 70.0:
21+
GPIO.output(14,True) #turns the fan on
22+
if temperature < 45.0:
23+
GPIO.output(14,False) #turns the fan off

fan_script.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,12 @@
1313
def fanOn():
1414
tempRaw = subprocess.check_output("vcgencmd measure_temp", shell=True).strip()
1515
tempString = tempRaw.decode("utf-8") #decodes the output into a string
16-
#print(tempString)
1716
tempStrLeft = tempString.lstrip("btemop=")
1817
tempStrRight = tempStrLeft.rstrip("'C")
19-
tempreture = float(tempStrRight)
20-
if tempreture >= 60.0:
21-
#print("hot hot hot")
18+
temperature = float(tempStrRight)
19+
if temperature >= 60.0:
2220
GPIO.output(14,True) #turns the fan on
23-
if tempreture < 45.0:
21+
if temperature < 45.0:
2422
GPIO.output(14,False) #turns the fan off
2523

2624
schedule.every(10).seconds.do(fanOn) #runs the fan_on task every ten seconds

wiring_schematic.png

9.71 KB
Loading

0 commit comments

Comments
 (0)