pcmanbob
Posts: 5276
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: Adding a 5V Fan to a Raspberry Pi 3 Model B and having control of it

Sun Dec 24, 2017 12:00 am

2N2222A is the same transistor.
What's the rating on your fan ? May be current drawn by fan is to much for transistor.
Are you sure it's connected correctly?
Remember we want information.......................no information no help
The use of crystal balls & mind reading is not supported

lcamilo
Posts: 5
Joined: Mon Dec 18, 2017 6:59 pm

Re: Adding a 5V Fan to a Raspberry Pi 3 Model B and having control of it

Sun Dec 24, 2017 12:26 am

pcmanbob wrote:
Sun Dec 24, 2017 12:00 am
2N2222A is the same transistor.
What's the rating on your fan ? May be current drawn by fan is to much for transistor.
Are you sure it's connected correctly?
Yes, every things conecte correctly. Is a ver small fan, but I don't know the rating.
20171223_222027-min.jpg
20171223_222027-min.jpg (246.76 KiB) Viewed 3008 times
20171223_222232-min.jpg
20171223_222232-min.jpg (204.38 KiB) Viewed 3008 times

pcmanbob
Posts: 5276
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: Adding a 5V Fan to a Raspberry Pi 3 Model B and having control of it

Sun Dec 24, 2017 11:49 am

Cant be sure because I cant see clearly but Ii think you might have things connected wrong.

your circuit should look like this ( diode left out for clarity )

Image

which matches this diagram

Image

for reference.

Image
Remember we want information.......................no information no help
The use of crystal balls & mind reading is not supported

User avatar
Burngate
Posts: 5716
Joined: Thu Sep 29, 2011 4:34 pm
Location: Berkshire UK Tralfamadore
Contact: Website

Re: Adding a 5V Fan to a Raspberry Pi 3 Model B and having control of it

Sun Dec 24, 2017 12:07 pm

The resistor shouldn't be less than 140 ohms to protect the Pi, and the fan shouldn't draw more than 800mA to protect the transistor.

I got those figures from the 2N2222A data sheet.
Ic max = 800mA
At Ic = 500mA and Ib = 50mA, HFE min = 30, Vce max = 1v, and Vbe max = 2v
At Ic = 150mA and Ib = 15mA, Vce max = 0.3v, and Vbe max = 1.2v

140 ohms, with the GPIO at 3v3 and the transistor base at 1v2, takes 15mA from the GPIO into the base.
The transistor should then be able to supply 30 times that current, or 450mA.

If your fan wants more than that, choose a different transistor!

lcamilo
Posts: 5
Joined: Mon Dec 18, 2017 6:59 pm

Re: Adding a 5V Fan to a Raspberry Pi 3 Model B and having control of it

Sun Dec 24, 2017 1:57 pm

pcmanbob wrote:
Sun Dec 24, 2017 11:49 am
Cant be sure because I cant see clearly but Ii think you might have things connected wrong.

your circuit should look like this ( diode left out for clarity )

Image

which matches this diagram

Image

for reference.

Image
😓

I inverted the emitter / collector terminals. I saw a reference to an npn transistor and took it into consideration. After I connected the terminals correctly, it ran smoothly with the 470 ohm resistor as well.
Sorry by waste your time. Thank you very much for your assistance.

User avatar
mahjongg
Forum Moderator
Forum Moderator
Posts: 11445
Joined: Sun Mar 11, 2012 12:19 am
Location: South Holland, The Netherlands

Re: Adding a 5V Fan to a Raspberry Pi 3 Model B and having control of it

Wed Dec 27, 2017 2:15 pm

If you are still not satisfied with the lowly 2n2222(a), try a 2n3904, its a little better suited for this task.

toldcodger
Posts: 22
Joined: Sat Feb 25, 2017 7:15 pm

Re: Adding a 5V Fan to a Raspberry Pi 3 Model B and having control of it

Tue May 29, 2018 8:15 pm

Firstly, thanks for this info.

I had a tiny 5 volt fan so I got the transistor, diode and resistor and set it up. The fan wasn’t actually up to the job, so it wouldn’t go below 75% speed.

I bought a couple of 5 volt fans from Pi Hut and using the same circuit, I tried again. I hacked some code together to use the cpu temperature to control the speed. I can now control the fan from 0, 25%, 50%, 75%, and of course full speed.

Thanks again.

Dave
You should always keep the prime objective in mind.
However, when you’re up to your ass in alligators, it’s hard to remember that you came to drain the swamp. :D

Mortifis
Posts: 6
Joined: Sat Mar 17, 2018 12:19 pm

Re: Adding a 5V Fan to a Raspberry Pi 3 Model B and having control of it

Sun Jun 10, 2018 4:24 pm

I just took a CPU fan from an old PC motherboard and wired it to a usb cable and run it off a usb port on the pi, works perfect and I have all of GPIO pins available :)

CodeOhms
Posts: 5
Joined: Sat Jul 07, 2018 8:27 am

Re: Adding a 5V Fan to a Raspberry Pi 3 Model B and having control of it

Thu Jul 12, 2018 6:40 am

Just thought I'd add a shameless self promo :roll:.
Lightweight program in C++, which automatically installs a systemd file for starting at boot. Can be customised for different speeds at different temps.
It has a script for easy install, and soon a deb installer. Also includes a description on how to wire a fan to be compatible.
viewtopic.php?f=41&t=217607&p=1339897#p1339897.

TxRider
Posts: 15
Joined: Tue Aug 14, 2018 4:45 pm

Re: Adding a 5V Fan to a Raspberry Pi 3 Model B and having control of it

Sat Sep 29, 2018 6:03 am

Does anyone know if there is an aftermarket ic board that I can buy that already has the components on it so I do not have to use a breadboard? If not, I can design one myself but thought I would check first.

Thanks,
TxRider

User avatar
Imperf3kt
Posts: 1913
Joined: Tue Jun 20, 2017 12:16 am
Location: Australia

Re: Adding a 5V Fan to a Raspberry Pi 3 Model B and having control of it

Sun Sep 30, 2018 9:13 am

Probably, but why pay for something you can make yourself with a transistor and a resistor (and probably a ceramic capacitor if you wanted to add that)
Google is ubiquitous - learn to use it!
https://opensource.com/life/16/10/how-ask-technical-questions

npaisnel
Posts: 62
Joined: Sun Aug 05, 2018 4:23 pm

Re: Adding a 5V Fan to a Raspberry Pi 3 Model B and having control of it

Mon Jan 28, 2019 4:24 am

MarkR wrote:
Wed Oct 04, 2017 4:07 pm
It's a bad idea to plug the fan connectors directly to the RPI GPIO pins because the fan needs a burst of current when it starts running and it's also dangerous when it stops because it may send a harmful current to the ground pin

Yes, it is a very bad idea to plug a fan (or other, high-current inductive load) into a gpio pin. Doing so will probably break your Pi.
😱
Oh hell ! Is this true ! I just bought a case, complete with fan and heatsinks. It comes with wires and plug to power fan direct from the row of pins on the Pi, which I believe are called the GPIO Pins.
Am I going to trash my Pi if I use this fan ?
There are no other obvious components, or control circuit, just a bare fan with connection to go direct to two pins.

Will await your reply before plugging the fan in

One of these

Smraza Black Case for Raspberry Pi 3 B+ with Fan + Heatsinks + 2.5A Power Adapter + w/On Off Switch for Pi 3B plus, 3 Model B https://www.amazon.co.uk/dp/B07C68QNLM/ ... tCbDKGCY7Z


Edit, I actually bought two of them , and only found the second one recently . I forgot I already have the other running since August 'ish'
Last edited by npaisnel on Tue Jan 29, 2019 7:56 pm, edited 1 time in total.

User avatar
Burngate
Posts: 5716
Joined: Thu Sep 29, 2011 4:34 pm
Location: Berkshire UK Tralfamadore
Contact: Website

Re: Adding a 5V Fan to a Raspberry Pi 3 Model B and having control of it

Mon Jan 28, 2019 12:07 pm

npaisnel wrote:
Mon Jan 28, 2019 4:24 am
MarkR wrote:
Wed Oct 04, 2017 4:07 pm
It's a bad idea to plug the fan connectors directly to the RPI GPIO pins because the fan needs a burst of current when it starts running and it's also dangerous when it stops because it may send a harmful current to the ground pin

Yes, it is a very bad idea to plug a fan (or other, high-current inductive load) into a gpio pin. Doing so will probably break your Pi.
I just bought a case, complete with fan and heatsinks. It comes with wires and plug to power fan direct from the row of pins on the Pi, which I believe are called the GPIO Pins.
Am I going to trash my Pi if I use this fan ?
There are no other obvious components, or control circuit, just a bare fan with connection to go direct to two pins.
https://www.amazon.co.uk/dp/B07C68QNLM/ ... tCbDKGCY7Z
It shouldn't kill your Pi, given that it's sold as part of the kit, but no details are provided in that page, so we just don't know.

I can't make out what the PSU is like, so I can't say whether it's capable of supplying what the Pi needs.
But since it's shown with an in-line switch in the 5v line, known to be a Bad Idea, I wouldn't trust this supplier.

Also, no details as to what current the fan takes, so no idea whether or not it's safe.

The Pi has an in-line polyfuse that will blow if you try to take too much current.
If the fan takes more than is left over after the Pi has had its share and any USB devices have had theirs, either the Pi's polyfuse will blow, or the PSU will brown-out if it's not man enough for the job.

User avatar
Imperf3kt
Posts: 1913
Joined: Tue Jun 20, 2017 12:16 am
Location: Australia

Re: Adding a 5V Fan to a Raspberry Pi 3 Model B and having control of it

Mon Jan 28, 2019 1:30 pm

Burngate wrote:
Mon Jan 28, 2019 12:07 pm
The Pi has an in-line polyfuse that will blow if you try to take too much current.
If the fan takes more than is left over after the Pi has had its share and any USB devices have had theirs, either the Pi's polyfuse will blow, or the PSU will brown-out if it's not man enough for the job.
No it shouldn't.
The polyfuse will only blow if you apply too much voltage or there is a short circuit somewhere.

Trying to draw too much current will only cause the voltage the Pi sees, to drop, which will first cause an unstable state and data might be corrupted. If it continues to drop, USB, ethernet and HDMI will shut off, after which not long after, the whole Pi will turn off unexpectedly.

No damage will come of it, but you do risk corrupting any data on any device that was connected to the Pi.

But there is another danger from using a fan directly which is caused by the collapsing magnetic field when the fan turns off. A voltage spike occurs which could damage the GPIO and consequently, destroy the Pi.
The risk is minimal, but there.
Google is ubiquitous - learn to use it!
https://opensource.com/life/16/10/how-ask-technical-questions

npaisnel
Posts: 62
Joined: Sun Aug 05, 2018 4:23 pm

Re: Adding a 5V Fan to a Raspberry Pi 3 Model B and having control of it

Mon Jan 28, 2019 3:55 pm

Think PSU is 2.5 amp from memory

Won't be using the inline switch to power it off until it has shut down properly.

I'd say an inline switch is a very good idea. It means once you have shut down properly via sudo shutdown now or GUI button, then you can remove power form the board to swap ouT SD cards without having to remove that horrid little micro USB style connector. I can see constant plugin and unplugging that will lead to eventual failure of on board socket.


I had been looking at an external GPIO switch to trigger the "sudo shutdown now" command. I have seen articles about this, but yet to action it!
Last edited by npaisnel on Tue Jan 29, 2019 7:54 pm, edited 1 time in total.

User avatar
Burngate
Posts: 5716
Joined: Thu Sep 29, 2011 4:34 pm
Location: Berkshire UK Tralfamadore
Contact: Website

Re: Adding a 5V Fan to a Raspberry Pi 3 Model B and having control of it

Mon Jan 28, 2019 5:54 pm

1st point: an in-line switch introduces resistance.
Even if it's not been used, the contacts won't be perfect - that is, not as perfect as a piece of copper wire.
And any resistance is bad, because you're wanting a variable current up to 2.5A to flow while keeping the end voltage within about 0.5v.
V = IR means R has to be less than 0.2Ω, including the cable, connectors, the polyfuse, etc.

So an in-line switch is a Bad Idea - better to use a switched mains socket.

Point 2: the polyfuse will blow if you apply more than about 6v because the Pi has a transorb that'll conduct, act like a short circuit, take lots of current, and blow it.
It will also blow if you try to take more current than it wants to handle - not just proper a short circuit , but also a load through the USB or on the header that wants more than is available through the polyfuse.
Together with a large USB load, a fan on the header could blow it.

But given the state of many PSUs I've seen, you're more likely to brown-out the PSU than blow the polyfuse.

User avatar
Imperf3kt
Posts: 1913
Joined: Tue Jun 20, 2017 12:16 am
Location: Australia

Re: Adding a 5V Fan to a Raspberry Pi 3 Model B and having control of it

Mon Jan 28, 2019 6:11 pm

npaisnel wrote:
Mon Jan 28, 2019 3:55 pm
I'd say an inline switch is a very good idea. It means once you have shut down properly via sudo shutdown now or GUI button, then you can remove power form the board to swap ouT SD cards without having to remove that horrid little micro USB style connector. I can see constant plugin and unplugging that will lead to eventual failure of on board socket.
I wouldn't particularly worry about wearing it out.
Standard USB has a minimum rated lifetime of 1,500 cycles of insertion and removal,[4] the mini-USB receptacle increases this to 5,000 cycles,[4] and the newer Micro-USB[4] and USB-C receptacles are both designed for a minimum rated lifetime of 10,000 cycles of insertion and removal.

The Micro plug design is rated for at least 10,000 connect-disconnect cycles, which is more than the Mini plug design.[15][18] The Micro connector is also designed to reduce the mechanical wear on the device; instead the easier-to-replace cable is designed to bear the mechanical wear of connection and disconnection.
https://en.wikipedia.org/wiki/USB_(Physical)
Google is ubiquitous - learn to use it!
https://opensource.com/life/16/10/how-ask-technical-questions

npaisnel
Posts: 62
Joined: Sun Aug 05, 2018 4:23 pm

Re: Adding a 5V Fan to a Raspberry Pi 3 Model B and having control of it

Tue Jan 29, 2019 1:37 pm

Imperf3kt wrote:
Mon Jan 28, 2019 6:11 pm

I wouldn't particularly worry about wearing it out.

Not wearing out as such, but damage the bloody thing/ bend a pin or damage it, or cause solder failure of the socket on the board. It does happen. I have the same sockets and plugs on my motorcycle intercom headsets. Over the years I have had to fix or replace these very same sockets or plugs on the wire part to he mic or earphones or external power multiple times or just scrap the intercom units when the solder of the socket to the PCB has been cracked on the PCB I have six of them dead now from myself or mates plus the two working ones..and one of those is on its way out too They are delicate unreliable shit when constantly plugged and unplugged.

The design criteria and wearing them out will only be looking at wearing the contacts/ plating..not taking in to account poor insertion technique, / accidentally bending stuff, bending the bloody thing while inserted, , the 'frame' pulling out of the plastic moulding etc etc , when trying to put it back /remove it in when leaning around the back of a cabinet or in the half dark of under a desk or similar.



Yes there will be some resistance loss on the switch contacts, but probably more on the micro contacts of the actual plug/socket combo. Switch is bigger, and almost certainly going to have greater contact area than the little plugs.

Here in the UK all our mains wall sockets are fitted as standard with an on/off switch, but doing that, powering off the device from the mains ..and yes I have done that is, you have to wait of the caps to discharge in the PSU, and pit out a lower and lower voltage till the RaspPi LED's slowly fade out, rather than go out instantly as the power switch on the 5v side is turned off.


All this talk made me think...I actually bough two of those cases with the fan running on the GPIO pins...where was the other one, I had forgotten about it. I had a think and remembered where it was, it is in use in my attic on the Pi that is running my Home Assistant /Philips Hue to Alexa Bridge and SDR radio system. Not been running long...August time I guess, but it is still running , current Uptime 95 day. So far so good. Fan is on permanent speed, no fan control and the thing does not get a reboot ...

While I am laid up with this broken leg..I might have to look at otherwise of powering the fan..give me something to do ! and create a GPIO button press for proper power down too. Currently SSH to it from the phone and re boot if from CLI..it is headless system with RTL-SDR USB stick and an X-10 CM11 home control unit
Last edited by npaisnel on Tue Jan 29, 2019 7:57 pm, edited 1 time in total.

User avatar
Imperf3kt
Posts: 1913
Joined: Tue Jun 20, 2017 12:16 am
Location: Australia

Re: Adding a 5V Fan to a Raspberry Pi 3 Model B and having control of it

Tue Jan 29, 2019 1:46 pm

Your experience with micro usb sadly differs from mine.
It doesn't matter what I do, I cannot seem to break the socket and believe me, I've done some stuff that really ought to have destroyed it but didn't.

Anyway, you can use a 5v switch, it's not going to cause any concern as long as it's appropriately rated and attached and you perform a proper shutdown first before throwing the switch. I use two in series myself on a battery powered Pi3A+ with no troubles whatsoever, even when running something as intensive as CPUburn A53.

Some posters here just like to blame the technology without considering specifications.
Google is ubiquitous - learn to use it!
https://opensource.com/life/16/10/how-ask-technical-questions

npaisnel
Posts: 62
Joined: Sun Aug 05, 2018 4:23 pm

Re: Adding a 5V Fan to a Raspberry Pi 3 Model B and having control of it

Tue Jan 29, 2019 2:14 pm

My experience with them is in a harsher environment to be fair. Plugged in to a waterproof intercom unit on the side of a helmet, with the cable running to either a recharge / or bater pack battery or to the mic and earpiece inside the helmet. Designed to be removable, so the wire is exposed, .so when helmet gets put down then, later picked up and the wire has got caught on something , it gets pulled etc. To be fair is the bad design of the intercom system and probably using th plugs in a way they were not designed for that caused the issues. But my experience with them has clouded my judgement and every time i have taken it out and plugged it back in on the Pi it alway makes me wince, which is why I like the PSU with switched power. I actually ws going to cut the cable of the one PSU I do have without a switch and fitting one myself.

User avatar
Burngate
Posts: 5716
Joined: Thu Sep 29, 2011 4:34 pm
Location: Berkshire UK Tralfamadore
Contact: Website

Re: Adding a 5V Fan to a Raspberry Pi 3 Model B and having control of it

Tue Jan 29, 2019 6:01 pm

npaisnel - Just as an aside, the last two times you've quoted someone, you've managed to miss the forward slash (/) in the end-quote mark. Quite how you managed it I don't know, but it messes up the prettiness of the thread!
Totally off-topic, I know, but I don't care!

npaisnel
Posts: 62
Joined: Sun Aug 05, 2018 4:23 pm

Re: Adding a 5V Fan to a Raspberry Pi 3 Model B and having control of it

Tue Jan 29, 2019 7:52 pm

Did I ,oops, sorry
The joy of replying on iPhone SE
Thanks for letting me know
Will get up there and edit them... and use Preview button !

npaisnel
Posts: 62
Joined: Sun Aug 05, 2018 4:23 pm

Re: Adding a 5V Fan to a Raspberry Pi 3 Model B and having control of it

Tue Jan 29, 2019 7:59 pm

Burngate wrote:
Tue Jan 29, 2019 6:01 pm
npaisnel - Just as an aside, the last two times you've quoted someone, you've managed to miss the forward slash (/) in the end-quote mark. Quite how you managed it I don't know, but it messes up the prettiness of the thread!
Totally off-topic, I know, but I don't care!
Corrected and other crap typos edited too. And I lied above... I think i did those posts on the Mac, trying to touch type or type too quickly and not proof reading.
That sort of thing upsets me when I see it too. Cheers for telling me,

Regards

Neil

User avatar
Burngate
Posts: 5716
Joined: Thu Sep 29, 2011 4:34 pm
Location: Berkshire UK Tralfamadore
Contact: Website

Re: Adding a 5V Fan to a Raspberry Pi 3 Model B and having control of it

Wed Jan 30, 2019 9:51 am

I used to not notice things, but at one point my wife was a proof-reader, and I think things sort of rubbed off on me.

npaisnel
Posts: 62
Joined: Sun Aug 05, 2018 4:23 pm

Re: Adding a 5V Fan to a Raspberry Pi 3 Model B and having control of it

Wed Jan 30, 2019 10:01 am

I am the same, especially on Facebook and the terrible gramma U C their literally each day innit. like. :D

Only one thing worse that that, and that is hijacking someone else post and then starting a discussion on a subject in no way connected to the OP's original post.....damn... :oops: :D

Return to “Other projects”