Ssaurus
Posts: 5
Joined: Wed Jul 15, 2020 7:59 pm

turn off fan by shutdown only

Fri Sep 04, 2020 2:59 am

So I have a question.

How do I turn off the fan when I shut down the pi without unplugging the power?

pcmanbob
Posts: 11958
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: turn off fan by shutdown only

Fri Sep 04, 2020 2:15 pm

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.
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

User avatar
mahjongg
Forum Moderator
Forum Moderator
Posts: 14230
Joined: Sun Mar 11, 2012 12:19 am
Location: South Holland, The Netherlands

Re: turn off fan by shutdown only

Fri Sep 04, 2020 2:28 pm

some versions of the RPI turn of power to the USB ports when shutdown, you might try powering the fan through an USB port.

NimbUx
Posts: 285
Joined: Fri Jan 03, 2020 10:33 am

Re: turn off fan by shutdown only

Fri Sep 04, 2020 2:43 pm

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 ...

alphanumeric
Posts: 3052
Joined: Tue Jan 19, 2016 2:17 pm
Location: Sydney, Nova Scotia, Canada

Re: turn off fan by shutdown only

Fri Sep 04, 2020 7:46 pm

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.

Ssaurus
Posts: 5
Joined: Wed Jul 15, 2020 7:59 pm

Re: turn off fan by shutdown only

Wed Sep 09, 2020 6:24 pm

alphanumeric wrote:
Fri Sep 04, 2020 7:46 pm
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.
well I have a cankit fan from the cankit rpi 4 set

alphanumeric
Posts: 3052
Joined: Tue Jan 19, 2016 2:17 pm
Location: Sydney, Nova Scotia, Canada

Re: turn off fan by shutdown only

Wed Sep 09, 2020 7:50 pm

A link to that specific fan would help.

pcmanbob
Posts: 11958
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: turn off fan by shutdown only

Thu Sep 10, 2020 10:53 am

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

Image

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

User avatar
Botspot
Posts: 1780
Joined: Thu Jan 17, 2019 9:47 pm
Location: Texas
Contact: Website

Re: turn off fan by shutdown only

Thu Sep 10, 2020 4:59 pm

NimbUx wrote:
Fri Sep 04, 2020 2:43 pm
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 ...
This.
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 apps on your Pi with Pi-Apps! Over 500k users.
Includes two Zoom desktop apps, 3 ways to run Minecraft, 10 web browsers, appearance themes, and 105 more.
More info: https://github.com/Botspot/pi-apps

PieterG
Posts: 33
Joined: Thu Nov 10, 2016 4:41 pm

Re: turn off fan by shutdown only

Sun Nov 01, 2020 11:57 am

@Botspot

But it won't start on GPIO anymore.

For those adding a button to start stop on GPIO this will not work.

ricardopaiva
Posts: 1
Joined: Fri Nov 27, 2020 4:33 pm

Re: turn off fan by shutdown only

Fri Nov 27, 2020 4:37 pm

NimbUx wrote:
Fri Sep 04, 2020 2:43 pm
- noise almost imperceptible,
- what you OP asked for : fan stops when the Pi shuts down.
Thank you very much for that. The fan noise was annoying me a lot!!! You solved both of my main issues. Thank you!

User avatar
TerryC
Posts: 6
Joined: Tue Dec 03, 2019 1:13 pm

Re: turn off fan by shutdown only

Thu Dec 03, 2020 1:02 am

pcmanbob wrote:
Thu Sep 10, 2020 10:53 am
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

Image

You can use any gpio pin for control , example chosen for clear diagram.
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.

Image

Image

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
The fan activates at 55°C and cuts off when the temp drops to 45°C. I don't know if there's a way to change the cutoff temp, and don't see the need anyway. 10° spread is fine.

Hope this is helpful.

User avatar
TerryC
Posts: 6
Joined: Tue Dec 03, 2019 1:13 pm

Re: turn off fan by shutdown only

Thu Dec 03, 2020 1:15 am

PieterG wrote:
Sun Nov 01, 2020 11:57 am
@Botspot

But it won't start on GPIO anymore.

For those adding a button to start stop on GPIO this will not work.
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
Shuts down and restarts every time. If the fan is running when the button is pressed it will shut down with the Pi.

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.

Return to “Beginners”