I have a Power Button and Fan plugged into my Raspberry Pi 3 running OSMC, Is there a way to turn off the fan with the Power button

I decided to start a Media Server, and I decided to use OSMC as I have experience with it and personally I think it is the best Raspberry Pi OS out there. I plugged in a power button to the GPIO and added this code into the config.txt file

dtoverlay=gpio-shutdown

I also added a cooling fan since it was getting quite hot. When I press the power button it turns off the OS but not the cooling fan. I was wondering if there is any way to turn off both the fan and the OS with the power button

Thanks,
Famous8

I suspect it depends on the fan that you have, and whether it supports control via GPIO. If it does, you could configure a shut down script.

But if it’s simply tied into the power rails of the Pi then so long as the Pi board is receiving power the fan will continue to spin.

If you want your fan to be off and on able then powering from GPIO is your best chance.

If it’s conrolled by GPIO, there is an overlay, gpio-fan, that, by default, will switch the fan on at 55C and off again at 45C. linux/gpio-fan-overlay.dts at rpi-4.19.y · raspberrypi/linux · GitHub

The overlay is part of the standard OSMC kernel build but the kernel lacks CONFIG_SENSORS_GPIO_FAN=m to allow it to work.

BTW The Fan is plugged into gpio with a Ground pin no. 14 and Power pin no. 2
Also the Power Button is plugged into pins 5 and 6
I am looking for a script that will shutdown the fan when the power button is pressed.
Thanks,
Famous8

P.S here are some pictures, yes the case is made out of Lego (even though thats not related to this)

Thanks, but not what I’m looking for

Pin 2 and 14 is not GPIO, it is power that (I believe) is directly connected to the USB power input. As jb2cool already pointed out above the fan will spin whenever the USB is receiving power. To actually control the fan it would need a circuit that was attached to a GPIO pin that could then control the 5v input from pin 2.

Honestly I highly doubt you even need a fan. They are designed to run fairly warm and throttle back if the temps get too high. If you don’t have an issue with it throttling then the fan seems rather pointless. If you want a bit better than stock there are heatsinks you can buy, including quite large ones that would actually be more effective than the fan you are currently using (the CPU is mostly under the fans hub so I would assume minimal effectiveness).

2 Likes

You are correct pin 2 and 14 are power and ground pins. Do you know how I could change the circuit to be able to controlled via GPIO
Thanks,
Famous8

This is out of scope for OSMC, maybe ask on the Raspberry Pi forums.

2 Likes

Yeah I know but my account wasnt working. Ill try again