So I have a question.
How do I turn off the fan when I shut down the pi without unplugging the power?
Re: turn off fan by shutdown only
Hi.
If your fan is just plugged in to the 5V and ground gpio header pins then you cant, as long as 5v is connected to pi 5V gpio header pin will be live.
if you want to control the fan then you need to add a resistor/transistor circuit and some code to switch it off.
If your fan is just plugged in to the 5V and ground gpio header pins then you cant, as long as 5v is connected to pi 5V gpio header pin will be live.
if you want to control the fan then you need to add a resistor/transistor circuit and some code to switch it off.
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported
The use of crystal balls & mind reading are not supported
- mahjongg
- Forum Moderator
- Posts: 15050
- Joined: Sun Mar 11, 2012 12:19 am
- Location: South Holland, The Netherlands
Re: turn off fan by shutdown only
some versions of the RPI turn of power to the USB ports when shutdown, you might try powering the fan through an USB port.
Re: turn off fan by shutdown only
I know it's frowned upon by some, but (on the Rpi-4 at least) I have the - nominally 5 V - fan fed from the Pi's 3.3 V.
It has worked flawlessly since installed this way, with 2 big advantages :
- noise almost imperceptible,
- what you OP asked for : fan stops when the Pi shuts down.
The last point needs a change from the default firmware configuration. Please search this forum for keywords: EEPROM WAKE_ON_GPIO POWER_OFF_ON_HALT ...
It has worked flawlessly since installed this way, with 2 big advantages :
- noise almost imperceptible,
- what you OP asked for : fan stops when the Pi shuts down.
The last point needs a change from the default firmware configuration. Please search this forum for keywords: EEPROM WAKE_ON_GPIO POWER_OFF_ON_HALT ...
-
- Posts: 3161
- Joined: Tue Jan 19, 2016 2:17 pm
- Location: Sydney, Nova Scotia, Canada
Re: turn off fan by shutdown only
It can be done with a fan that has fan control circuity. I modified my Pimoroni Fan Shim so the fan shuts off when the Pi shuts down. It only runs when commanded on by a GPIO pin being pulled low. This fan is temperature controlled.
Re: turn off fan by shutdown only
well I have a cankit fan from the cankit rpi 4 setalphanumeric wrote: ↑Fri Sep 04, 2020 7:46 pmIt can be done with a fan that has fan control circuity. I modified my Pimoroni Fan Shim so the fan shuts off when the Pi shuts down. It only runs when commanded on by a GPIO pin being pulled low. This fan is temperature controlled.
-
- Posts: 3161
- Joined: Tue Jan 19, 2016 2:17 pm
- Location: Sydney, Nova Scotia, Canada
Re: turn off fan by shutdown only
A link to that specific fan would help.
Re: turn off fan by shutdown only
From memory when helping other users the canal kit fan is rated at 5V , 0.12A.
So a 2N2222 transistor, 470 ohm resistor & 1N4001 diode is all you need.
just wire it like this

You can use any gpio pin for control , example chosen for clear diagram.
So a 2N2222 transistor, 470 ohm resistor & 1N4001 diode is all you need.
just wire it like this

You can use any gpio pin for control , example chosen for clear diagram.
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported
The use of crystal balls & mind reading are not supported
Re: turn off fan by shutdown only
This.NimbUx wrote: ↑Fri Sep 04, 2020 2:43 pmI know it's frowned upon by some, but (on the Rpi-4 at least) I have the - nominally 5 V - fan fed from the Pi's 3.3 V.
It has worked flawlessly since installed this way, with 2 big advantages :
- noise almost imperceptible,
- what you OP asked for : fan stops when the Pi shuts down.
The last point needs a change from the default firmware configuration. Please search this forum for keywords: EEPROM WAKE_ON_GPIO POWER_OFF_ON_HALT ...
The Pi4 won't turn off the 5v pin when it's shut down, but with the help of an EEPROM flag, it will turn off the 3.3v pin on shutdown.
Then simply connect the fan from 3.3v to ground. The 1-inch fan+heatsink setup I use is completely silent running on 3.3v, and best of all it turns off on shutdown, without the help of any mosfets, transistors, or soldering.
Easily install anything on your Pi using Pi-Apps. Over 2 million users.
Over 200 apps including image editors, IDEs, games, web browsers, appearance themes, and more to upgrade your Raspberry Pi desktop.
More info: https://github.com/Botspot/pi-apps
Over 200 apps including image editors, IDEs, games, web browsers, appearance themes, and more to upgrade your Raspberry Pi desktop.
More info: https://github.com/Botspot/pi-apps
Re: turn off fan by shutdown only
@Botspot
But it won't start on GPIO anymore.
For those adding a button to start stop on GPIO this will not work.
But it won't start on GPIO anymore.
For those adding a button to start stop on GPIO this will not work.
-
- Posts: 1
- Joined: Fri Nov 27, 2020 4:33 pm
Re: turn off fan by shutdown only
This is exactly what I did, except my resistor is 680 ohm. It's built on a piece of protoboard cut 4 holes x 5 holes, and insulated with heat shrink tubing after assembly.


It's fastened to the lid of my case (Canakit) next to the fan with servo tape. You just have to make sure it is secured in place and the fan connected to the pins before connecting to the Pi. Control is on the ground side of the fan, there's a constant 5V on the positive pin.
Red wire to pin 4
Black wire to pin 30
Grey wire to pin 32
I added the following to /boot/config.txt:
Code: Select all
# cooling fan control circuit on GPIO12 (pin 32)
# set at 55°C (131°F)
dtoverlay=gpio-fan,gpiopin=12,temp=55000
Hope this is helpful.
Re: turn off fan by shutdown only
I have a pushbutton switch connected along with with the fan controller I just posted.
Switch leads are connected to pins 5 and 6, with the following added to /boot/config.txt:
Code: Select all
# Enable shutdown/restart with momentary switch bridging pins 5 & 6
dtoverlay=gpio-shutdown,gpio_pin=3,active_low=1,gpio_pull=up
I suppose you could switch the red wire on the fan controller from the 5V pin to a 3.3V pin if you really wanted to power the fan at a lower speed.