Basic question, usb cable, relay, and 5v fan

Just wanting to check if the following is OK to do, or if I'm likely to melt/explode something/someone. Have not used a relay before!

I want to power a tiny 5v fan, in a cabinet. When the door is closed the fan is on, but turns off while the door is open. The problem is the fan draws 150ma.

I figure this means I need to power it externally from the Arduino and control the on/off using a relay or mosfet. I think I grasped the concept of a relay (slightly) better than a MOSFET, which is why I've gone down that route. The relay in question is one of these:

I am wondering if I can hook the relay into the USB cable powering the Arduino, or if this would cause problems?

I figure if I splice a USB cable and join the ground wire of the motor to the earth of the USB cable, and then join a connection to the USB power wire which runs to the relay NO port, this should work? (with 5v,gnd and a digital IO on the other side of the relay connected to the Arduino for controlling off/on).

Fan and relay pictured below:

Any help or suggestions appreciated.

Why use a relay...it's unnecessary. A small-signal MOSFET will do. Even a 2n7000 would work here, especially it's a 5V Arduino (which you didn't specify).


Left half of the diagram applies to your case. Place a diode parallel to the fan ('load') with the cathode connected to Vdd.

As to powering the fan: you've got an Arduino and a USB adapter, just plug in USB to Arduino and connect the fan + to the Vin on the Arduino (preferably not the 5V, although it wouldn't even hurt in this case). Again, assuming the topology of a typical UNO, Nano, etc. For more accurate into, tell us what Arduino you're using.

I haven't specified the Arduino as I haven't decided yet,still planning at this stage. It will be a 5v though, I'd completely overlooked that I could connect to the vin/5v, mistakenly thought they'd have the same low current load as the gpio pins! Thank you!

Is there a reason you recommend connecting to the Vin and not 5v?

I'll need to do more reading on the mosfet, my electrical knowledge and understanding really is very slim (why I started doing Arduino stuff is to try and improve) making the jump from turning LEDs on and off and reading sensors to powering things is proving a challenge.

Sorry, it depends on the Arduino you use. I was thinking of a Nano, where Vin = USB 5V. On e.g. an UNO I wouldn't use Vin to connect 5V peripherals to. I shouldn't have said anything about this anyway since you didn't specify the Arduino to be used; as you noticed, it depends a bit on what you choose.

Just google 'mosfet low side switch' and lots of stuff pops up.
A relay isn't necessarily wrong to use here, but it's just massive overkill for the job. It's like using a crowbar to open a jar of marmelade. It'll work, but it's just awkward.

1 Like

Thanks.

Would I need a flyback diode if I used a relay? The one I was thinking about mentions back emf protection which I assumed made it a handy all in one solution, even if it is a crowbar :wink:

I'll try and get to my electronics store sometime and pick up some mosfets (they seem to have the one you recommended:https://www.jaycar.co.nz/2n7000-n-channel-fet/p/ZT2400?pos=1&queryId=098880d04530ee57e5329ade203d3def) , I get the impression I'll be needing them sooner or later.

Not really, especially not with this fan. At least, not on the fan. You would need one on the relay, but your module already has it on its little PCB. It's right next to the relay.

Back EMF protection and crowbar protection are completely different things, with different implementations and to deal with different problems. They have nothing in common except that semiconductors are in there somewhere.

Good news :slight_smile: 2n7000 is a common type, which is why I mentioned it. In case you can get BSS138, that's also a very suitable one - even better, as it's a logic-level type which is more suitable for an Arduino environment (to put it simply). The problem is that I think it only comes in SMD form whereas 2n7000 is a convenient TO92 package.

Yeah, they're cheap and often useful. It's always a good idea to have a dozen or so (or a hundred...) on stock.

Rubbish! :astonished:

Presumably you were actually thinking of a WeMOS D1 Mini.

Nope.
Not rubbish.
Bye.

"Vin" on a Nano goes to the input of the regulator. Nothing to do with USB.

Still, if you imagine otherwise ... :roll_eyes:

Ok.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.