Hi guys I would like you to tell me how to control 2 fans mounted in parallel from GPIO pins. I saw some electric diagrams using NPN transistors and protecting resistors/led but I can't really figure them out, I'm afraid to do mistakes and burn my pi lol

I would like to connect the fans to the 5V pin to power them and use some kind of a software switch which would monitor the pi temperature and tell whether or not to turn the fan on.

Something like : if rpi_temp > 50° turn gpio x on (which would activate the fans) else turn gpio x off

I thought about doing this on the 5v pin but I'm 100% sure I shouldn't because it seems too simple and everything I saw on the net involved resistors, transistors etc.. Thanks for your help guys, and please explain me like I'm 5, I'm a very beginner in electronic stuffs ^_^

  • Are you talking about mains powered desktop fans of PC case fans? If the first then follow @milliways answer otherwise you should be able to follow any of the standard GPIO HIGH/LOW examples that will power a single fans no problem, but more than one may drain the Pi and cause problems.
    – rob
    Apr 2, 2014 at 8:30

1 Answer 1


See "Driving a relay" on http://elinux.org/Rpi_Low-level_peripherals and connect your fan instead of the relay.

If you cannot follow this, then I can't think of any way to explain it in this forum. You should look for some books on electronics. There are thousands to choose from; you can probably download some tutorials from the web.

If you have never done this before then I WOULD STRONGLY SUGGEST that you have a play with the circuitry before attempting to connect it to the Pi.

I might point out that you shouldn't need a fan. In Sydney, where the summer temperature can exceed 40℃ I have never seen my Pi exceed 50℃, even in a case.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.