3

I'm interested in adding a fan to my Raspberry Pi 4, but I would like to be able to control when it is on/off programatically. However, what I see is that most of the fans suitable for Raspberry Pi come with 2 pins to connect to 3.3/5V and ground pin, which means you cannot control them unless you add some additional circuitry.

Is it possible to use a fan that has 4-pins, and not add any additional circuitry at all?

  • 3
    The fans you refer to (4-pins) is it the PC fans? If yes, then the FANS is 12 volt and then is some electronic interface/driver necessary. – Mats Karlsson Nov 9 '20 at 12:03
  • 4
    You'll always need additional circuitry to drive a fan on a Raspberry Pi (except if you hard-wire it to the 5V rail). That is because you cannot drive a fan from a GPIO pin. That would fry your Pi quite rapidly. You need at least a transistor as current amplifier. – PMF Nov 9 '20 at 15:20
  • PMF is correct, you cannot power a fan from a GPIO; at a minimum in order to use PWM you'd have to use a transistor on one of the power lines. However, a four pin fan may not require that (three pin ones do); it appears they use a control chip and an additional signal line. The third one, though, is still probably an analog input to measure the speed (or not!, see Sim Son's answer), so you'd need an ADC. I've edited this question to make it fit better with our no shopping restrictions. – goldilocks Nov 9 '20 at 16:50
  • @PMF What you mean by hardwire to the 5V rail? – terett Nov 14 '20 at 13:17
  • @terett : Just connect the 5V fan to the +5V (and GND) pins of the Pi. These deliver enough power to drive a fan. Of course, there won't be any regulation like this. But see the other answers, my comment may not be really precise when it comes to 4-Wire fans. – PMF Nov 14 '20 at 15:18
2

Yes, if you find a fan which supports 3.3V levels on speed control pin, there is no reason it wouldn't work from a GPIO. I'd expect 5V fans also work in this way if you power them with 3.3V, albeit with a reduced max speed.

Personally, I invested some time into finding a simple 2-pin fan which is really quiet, and simply keep it running all the time. Pi 4 consumes 2.7W doing absolutely nothing, and while you don't strictly need active cooling at 2.7W, it's not useless either. On the other hand, Pi 4 SoC consumption maxes out at 6.4W, so you don't need a huge airflow to keep the temperature in check.

  • May I ask you which fan you are using? – terett Nov 10 '20 at 14:42
2

Erm,... Yes you can, but you shouldn't.

There are a few 3V fans that fit that description, even one by some Chinese firm that could be powered by the GPIO pin. Do not expect it to create a significant airflow though.

If you're afraid of soldering, there is a PWM controlled fan hat. Or you can use female jumper wires.

---EDIT--- There are a number of four wire fans available that use 5V for power and 3.3V for the PWM input. Some newer boxed Intel processors have them (older seem to use 5V for the PWM input)

You would then use

pin1 - gnd
pin2 - +5V
pin3 - sense
pin4 - pwm

But also that is difficult to realize without soldering:

  • the connector will probably not fit over the header connector
  • you should protect the GPIO pins (sense and pwm) with a 3.3V zener diode
  • 2
    Do you know any PWM controlled fan hat that is as small as possible? Or any guide that shows how to do it with female jumpers? I just want to avoid soldering. – terett Nov 9 '20 at 17:54
  • We generally do not give shopping advice, but the design on howchoo.com/g/ote2mjkzzta/… is doable with jumpwires and waveshare.com/fan-hat.htm gives a fan-hat. I never tried them, so it is just what I found googleing. – Ljm Dullaart Nov 10 '20 at 7:50
  • In most cases, the level of Vcc is irrelevant because the PWM input typically is a open collector input compliant with TTL levels. So you can indeed simply connect Fan-Vcc to 12V and PWM to a GPIO without problems (that's the case for all fans I worked with so far) – Sim Son Nov 15 '20 at 11:06
  • With 5V, you can use the power supply of the Pi; with 12V you need a separate power supply. – Ljm Dullaart Nov 16 '20 at 16:29
2

You can typically simply connect the PWM input to a GPIO providing a 25kHz PWM signal. I don't agree with the other answers, which all mention to keep Vcc within the logic level of the Pi, which from my experience is not neccessary! Fan controllers in 4-pin fans have an open collector input for PWM control and thus are made to be controlled by typical logic levels, newer models of reputable brand are sometimes explicitly compatible with 3.3V logic using pullups to 3.3V, respectively.

There are many products on the market and to be absolutely sure if your individual fan is fine to work with in this way, you should connect PWM to ground through a large resistor (10kOhm) and measure the voltage at the PWM pin when the fan is connected to 12V and GND. If the PWM pin within you logic level, you're fine to go.

Also, unlike mentioned in a comment, you don't need an ADC to read the tacho signal: it's a pulse signal (also open collector signal) that generates to drops to GND per revolution. All you need to control a 4-pin fan is 1 (or maybe 2) pullups of around 10kOhm.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.