I bought a 5v mini fan from aliexpress and got it today. Its working fine...but its a bit too loud for my taste.

enter image description here

Its connected to pins 4, 6 (??!? not sure)

enter image description here

Is there a way i can controll it by turning it on/off with a python script ? I found a script here but its not working.

I've seen some videos where they use pin 2 and 6 to control it...but i dont want to cut any cables yet before i am sure it will work. Also some suggest a transistor and a resistor should be used instead to control it (link here)...but again...not sure if that applies to my Model B.

Any help would be highly appreciated. Thank you

  • updated post...i added a relay to the equation. – Sandbird May 31 '15 at 17:22
  • There is no point "updating" an old question to turn it into a new question. When you have a new question, ask a new question. Please take the tour if you have not yet. – goldilocks Jun 1 '15 at 1:51
  • Thanks i'll do that. i read that if i needed to add a comment to just edit my post, so i thought that applied to the question as well. – Sandbird Jun 1 '15 at 8:28
  • 1
    Part of the goal here is to create Q&A's that might have a value for posterity -- this way people do not have to waste time answering the same questions over and over again, and in the process of receiving help you have that opportunity to give back to the community. If instead you ask a question, get an answer or set of answers, then edit the question to something else, those answers no longer make sense in context; the whole post becomes disposable, and while you may get something out of it, it becomes less likely that anyone else ever will because it is not clear what the Q&A is about. – goldilocks Jun 1 '15 at 10:43
  • Note this is NOT a discussion forum; threads should not evolve endlessly or involve a lot of open ended discussion. That is purposeful. Thank you for rolling back your edit! – goldilocks Jun 1 '15 at 10:43

STOP! You musn't ever connect a motor (fan etc) directly to a GPIO pin.

Your fan works fine now as its basically connected directly to the 5V supply which is fine.

The controllable GPIO pins on a Pi basically

  1. Don't have enough current to make a fan turn very well


  1. Will almost certainly cause the Pin to stop working as a motor (fan) can generate electricity as well as consuming it and it can create a high voltage (called back EMF) which will permanently damage your pin (if not the entire Pi!)

So basically you need a buffer circuit using a transistor or my personal favourite is to use a ULN2003 chip which has 7 buffers and only costs 50 pence or so

  • I got no idea how to use this chip. I studied applied computing, so i am not that good with electronic engineering stuff. I ordered a breadboard and some resistors/capasitors yesterday in order to do this: ich.wtf/blog/en-raspberry-pi-fan-gpio.php For now i will unplug the fan cause as you say...i am walking on this wire here. :) – Sandbird May 29 '15 at 8:03
  • *thin not this :P thin wire... – Sandbird May 29 '15 at 8:14

i dont want to cut any cables yet before i am sure it will work.

Simple logic says there is no way you can control this fan with that plug attached to a pi, because there is no way to control the 5V power.

You could, however, implement and test the idea with the transistor without cutting the plug by sticking some pins in it and putting it on the breadboard. Then you connect the 5V from the pi to the breadboard appropriately. This requires one extra wire than shown in the diagram.

  • so its necessary to do the transistor thing then..Some people plugging the fan on the 2-6 pin is still the same with the 4-6. No extra 'features' by doing that ? I guess i have to buy a breadboard then hehe – Sandbird May 28 '15 at 12:31
  • There's only one place you can attach that plug and it's where it is, 4-6. 2-6 is exactly the same, but you'd have to cut the plug off, and it would not help with controlling it. You need some additional electronics for that. – goldilocks May 28 '15 at 12:36

One easy way to slow it down in bits is to wire a diode (1N4001 -1N4007) is good and cheap in series with one on the leads. It provides a fixed voltage drop of 0.7 Volts, up to 1Amp. Need to go even slower? And a second diode in series. This also works when you need to dim LEDS (<1 AMP). Two diodes gives you a drop of 1.4V. Wire a switch across the two ends of the diode string and now you have High/Low settings. Easy Peasy!

  • Interesting, good to know, thanks. I wish i could do this programmatically. I have to check and see if the GPIO can alternate current – Sandbird May 29 '15 at 7:58

Diodes in series does not work to dim LEDs. They work to dim a light bulb or slow down a motor. But NOT LEDs.

  • 1
    I think you're understanding of diodes is a little bit confused. Diodes are semiconducting components that let electric current flow in one direction only. Yes they do have some resistance but acting as electrical resistance is not their primary purpose. Diodes could be used as part of an AC to DC rectification circuit which could be used to power a light bulb or motor. – Darth Vader Aug 16 '17 at 19:49

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.