I'm working on a project where I want to control a 12V PWM fan with a 4-pin header using a Raspberry Pi.
I am aware that a Raspberry Pi does not require a fan in day to day use cases but the reasoning for doing so is that I have a 5 node kubernetes cluster running a couple of applications that use CPU which can cause the cluster temperature to increase.
However, I want to power the fan using an external 12V power supply instead of drawing power from the Raspberry Pi itself.
My Setup:
- 5 Node Kubernetes Cluster
- 2 Raspberry Pi 5 8GB with active cooler (These stay relatively cooler than the cluster)
- 2 Raspberry Pi 4 8GB
- 1 Raspberry Pi 3B+ 4GB
- 2 PWM Fans (Fourdot 8025 80mm fans https://www.amazon.in/gp/product/B092V2LMMQ/ref=ppx_yo_dt_b_asin_title_o01_s00?ie=UTF8&psc=1)
- UCTronics U6260 Enclosure
Proposed Circuit:
Power Connections:
- The fan's positive wire is connected to the 12V external power supply.
- The fan's ground is connected to the collector of an NPN transistor 2N2222.
Transistor Setup:
- The emitter of the NPN transistor is connected to the negative terminal of the external power supply.
- A diode (1N4001) is placed across the fan’s power terminals for protection (cathode to positive and anode to ground).
Control Connection:
- A resistor (1kΩ) is placed between a PWM-capable GPIO pin on the Raspberry Pi and the base of the NPN transistor.
- A pull-down resistor (10kΩ) is added between the base of the transistor and ground to ensure it turns off when the GPIO is low.
PWM Signal:
- The Raspberry Pi sends a PWM signal (around 25 kHz) to the fan's PWM pin via the GPIO pin to control fan speed.
Questions:
Does this circuit setup look correct for safely powering the fan externally while controlling it with the Raspberry Pi’s PWM output?
Are there any potential risks or improvements that should be made to this design, especially regarding isolation between the Raspberry Pi and the 12V power supply?
Do I need additional components or considerations to protect the Raspberry Pi from any back EMF or voltage spikes that could occur?
Any feedback or suggestions would be greatly appreciated!
P.S. Full disclosure, I am more of a software guy than a hardware, I understand very basics of circuit design, if i have a circuit i can solder it together and get things rolling. Also, the above circuit is designed by ChatGPT, so I don't trust it 100% but it might give a good starting point