Page 1 of 1
External Fan
Posted: Mon Apr 13, 2020 5:53 pm
by tn13
I'm looking for some advice on how to connect and control a fan. I do not intend for this fan to cool the Pi. It's for external use. I tried googling but mostly found posts about cooling the Pi itself. Does anyone have advice for the easiest way to do this?
Project:
I have a plastic tub that is used to breed crickets. My problem is that it gets a little too hot in the room we keep them in and there's no airflow in the tub. I'd like to cut out a space in the tub and install a fan to be controlled by the raspberry pi along with a temperature sensor.
Raspberry Pi:
I have a Raspberry Pi 3B+, 4B, and ZeroW
Fans:
I found a 3-wire 5v case fan left over from another project. I also have a USB case fan, but I'm not sure if that can be controlled from the Pi. I'm open to suggestions for any other type of fan.
Re: External Fan
Posted: Mon Apr 13, 2020 9:12 pm
by LTolledo
for the 3 wire fan, check first which wire are the power leads...then verify using a separate 5v power supply.
once you've confirmed that, you can use a transistor circuit (others will insist a MOSFET solution) to drive the fan.
in your code, you will have to specify at what temp the fan will turn ON and what temp to turn OFF.
as this is just a "simple" project... a microcontroller (Attiny85, etc) might be better.... as a RPi may be a bit of an "overkill"
Re: External Fan
Posted: Tue Apr 14, 2020 12:07 pm
by pcmanbob
Hi.
Here is a typical example of driving a fan from the pi using a transistor control circuit.
Awaiting the cry of " USE A MOSFET "

Re: External Fan
Posted: Tue Apr 14, 2020 2:38 pm
by davidcoton
Just for @pcmanbob:
"Use a MOSFET"
It will save a whole resistor (as long as you like living dangerously) for very little extra benefit.
Seriously, go with what you know and what you have available.
Re: External Fan
Posted: Tue Apr 14, 2020 9:26 pm
by LTolledo
davidcoton wrote:
It will save a whole resistor (as long as you like living dangerously) for very little extra benefit.
hmmmm.... I didnt know resistors have gotten more expensive than semiconductor active components...
davidcoton wrote:
Seriously, go with what you know and what you have available.
Yes... definitely follow @davidcoton's advice for desired uptime and results....
I'd do the same....always has.... always will....
Re: External Fan
Posted: Tue Apr 14, 2020 10:16 pm
by davidcoton
LTolledo wrote: ↑Tue Apr 14, 2020 9:26 pm
davidcoton wrote:
It will save a whole resistor (as long as you like living dangerously) for very little extra benefit.
hmmmm.... I didnt know resistors have gotten more expensive than semiconductor active components...
But it's not a resistor instead of transistor, it's a whole extra resistor (unless you follow the advice to protect the Pi by having the resistor present even in a FET circuit).
On one site:
- Cheapest SMT resistor £0.005 ea (100+)
- Cheapest wire end resistor £0.014 (10+)
- Cheapest SMT bipolar transistor £0.02 (10+)
- Cheapest SMT FET £0.03 (10+)
Re: External Fan
Posted: Wed Apr 15, 2020 9:13 am
by pcmanbob
At the end of the day , its not really the transistor you are really worried about protecting , after all a small transistor is at the most £1 each , what your really want to protect is the pi gpio and so the pi its self.
would you want to damage or even kill your pi for the cost of a resistor ?
I try to always publish circuits that will not only work with the pi gpio but that are safe to use with the pi gpio,
yes some consider PNP/NPN transistors to be old technology in comparison to mosfets , but as
davidcoton wrote:
Seriously, go with what you know and what you have available.
its what I know and have/use and as the 2N2222 transistor has been around for a long time its available cheaply just about any were in the world.
Re: External Fan
Posted: Wed Apr 15, 2020 10:56 am
by LTolledo
pcmanbob wrote: ↑Wed Apr 15, 2020 9:13 am
... and as the 2N2222 transistor has been around for a long time....
AFAIR the very first transistor that I ever "played" with was a pair of 2N2222 in TO-18 metal package (during my elementary days)
my current stock is more on the 2N3904 (TO-92) and its complementary 2N3906... also have SMT version (buried under the 2N2222)

- my transistor box.jpg (211.13 KiB) Viewed 212 times
the 2N2222 is a wee bit more expensive than the the 2N3904 from my fave supplier, and haven't used any one ...yet.
whatever transistor is/are required by a certain project, I'll just dig in to the one that I have that is applicable...
but for multiple transistor usage.... those transistor arrays are much better.... and cheaper!
(never seen a MOSFET array chip yet... please correct me on this, links?)