I have several Raspberry Pi 4 with a case that includes a fan. I connected the red cable to 5v Power(Physical/Board pin 4) and the black cable to GPIO 14 (Physical/Board pin 8). I setup raspi-config to turn on fan at 60 and use GPIO 14. When the temperature goes higher than 60 degrees, I notice the GPIO gets triggered, but the FAN doesn't spin. If I connect power and ground the fan spins. I would really prefer to make a config change and have to unmount and take apart 8 Raspberry Pi.
4 Answers
I endorse joan's comments.
It is simple to control a fan with inexpensive circuit. See https://raspberrypi.stackexchange.com/a/105820/8697
See https://docs.google.com/document/d/1bxIzUXLXdrtTo7DwAYv8maLeBssYau4nWwyeAAjot-0 for a picture of my module.
-
I know it's super simple but do they sell the pieces needed already built? I have a total of 8 to do.– nyitguyCommented Apr 5, 2021 at 15:41
You should NEVER connect a GPIO to an inductive load. Eventually you will destroy the GPIO and the Pi.
You should NEVER connect a GPIO to a voltage outside the range 0 to 3.3 volts. Eventually you will destroy the GPIO and the Pi.
A GPIO can only supply (source or sink) about 20 milliamps at 3.3 volts. Nowhere near enough to power a motor even if it was safe to do so.
-
Thanks for that. If I had external power and relay switch for the power, is there a way to configure it?– nyitguyCommented Mar 24, 2021 at 23:01
-
@nyitguy Yes, using a relay (or just simply a transistor) is the common way of powering a fan. You'll find lots of tutorials on how to wire that up. I'm a bit confused that your housing does not include the relevant electronics (or at least a description on how you should do that)– PMFCommented Mar 25, 2021 at 6:47
When you use raspi-config to configure a GPIO to control a fan, you get the message "The fan on GPIO xx is enabled and will turn on at yy degrees".
That means, the GPIO will go high. So the fan would have to be connected to the GPIO with it's red wire, and the black wire would go to ground.
But, as one of the other answers says, the GPIO might not cope well with the inductive load. Also the GPIO going high will mean it will be at ca. 3.3V, which is not enough to make a 5V fan spin.
So what you need to do is add a circuit with resistor and transistor, as found elsewhere. E.g. see the circuit found in this (german language) tutorial.