Challon
Published © GPL3+

NESPi Auto Variable Speed Fan and Shutdown Button

A simple Python script to monitor CPU temp and adjust the fan speed and another for the shutdown button.

BeginnerWork in progress1 hour3,452
NESPi Auto Variable Speed Fan and Shutdown Button

Things used in this project

Hardware components

Raspberry Pi 3 Model B
Raspberry Pi 3 Model B
×1
NESPi Case
×1
5v Fan 30x30x10mm
Haitronic 30x30x10mm DC 5V 3010 Quiet(24/32dB)
×1
General Purpose Transistor NPN
General Purpose Transistor NPN
2N2222A
×1
Resistor 220 ohm
Resistor 220 ohm
×1
Pushbutton switch 12mm
SparkFun Pushbutton switch 12mm
×1
Anchor Taiwan Prototype Board PCB
×1
Breadboard (generic)
Breadboard (generic)
×1
Jumper wires (generic)
Jumper wires (generic)
×1

Software apps and online services

Raspbian
Raspberry Pi Raspbian

Hand tools and fabrication machines

Soldering iron (generic)
Soldering iron (generic)

Story

Read more

Custom parts and enclosures

NESPi

The Raspberry Pi case where the fan and button is applied.

Schematics

Raspberry Pi Variable Speed Fan

Variable Speed Fan control with GPIO, Python and some simple easy to find electronics components.

Code

Install Fan Script

SH
Run the command listed in the code below and it will auto install everything you need for the fan to work. Be sure to check all of your fan connections before applying power to the board.
# INSTRUCTIONS:
# Download and run this setup script in the terminal using the following command:
curl http://pie.8bitjunkie.net/shutdown/setup-shutdown.sh | bash

shutdown.sh

SH
This is the python code will run at boot time. When the button is pushed the system will shutdown softly.
#!/bin/python

import RPi.GPIO as GPIO
import os

gpio_pin_number=3
GPIO.setmode(GPIO.BCM)
GPIO.setup(3, GPIO.IN, pull_up_down=GPIO.PUD_UP)

try:
    GPIO.wait_for_edge(3, GPIO.FALLING)
    os.system("sudo shutdown -h now")

except:
    pass

GPIO.cleanup()

Credits

Challon

Challon

1 project • 0 followers

Comments