Controlling fan speed with Photon and FET transistor

Hello, total beginner here.

I have yet to get an actual Photon to try this on, but I have begun sketching on a solution anyways.

So far, it looks like this:

The diode on the breadboard is a 10K.
I have loosely followed some tutorials and guides I found online.

I plan to operate this setup via a Blynk app, by using analogWrite() for PWM and a simple slider.

How far off am I with this sketch? What do I need to change?

There are definitely better people to look at this post but I’ll be happy to help.

  1. It’s not a 10k diode. It’s a resistor.
  2. What FET do you plan to use.
  3. How many amps does your little fan pull?

I’d actually seperate the 12V side of the curcuit from the Photon via an opto isolator.
Motors tend to produce a lot of noise which will still carry back into the Photon via GND.
But if you want to stay connected, you should at least add some caps and possibly a free-wheeling/flyback diode - that’d be advisable in any case tho’.


Just for nit-picking:
And please don’t use the red rails for GND - it just gives me the shivers when I see a short between red and GND :wink:

You could put the +12 on the red top rail and that respective GND on the top blue with an optional bridge (or even a 12V->5V step-down converter) down to the bottom blue (GND) and the 5V rail at bottom red and connect Vin of the Photon to bottom red and GND of the Photon to bottom blue.
While you pull all the 12V connections up to the higher level rails.

2 Likes

Just for further nit-picking… Many breadboard have a ‘break’ in the rails in the middle. In this case your 12V in wouldn’t be connected to the other components.
Just sayin’ since this has messed me up more often than I’d like to admit…

2 Likes
  1. Ah, got it!
  2. Would a solution like this (with the included FET) be good for my application? https://www.sparkfun.com/products/12959
  3. 180 mA

Would one of these do the trick? https://www.sparkfun.com/products/9118

You could use one of those, but there’s no need for a breakout.
You could just use a 4N28 or similar for a tenth of that price :wink:
https://www.conrad.se/Optokopplare-4-N-28-Vishay-4N28-DIP6-Single-Channel.htm?websale8=conrad-swe&pi=146340
https://www.bejoken.se/butik/4n28%20optokoppl%20isocom.aspx

Also that FET is fine, but again no need for the breakout, just take the transistor


https://www.conrad.se/MOSFET-transistor-Fairchild-Semiconductor.htm?websale8=conrad-swe&pi=1264199

or even this one
https://www.conrad.se/MOSFET-Vishay-IRLD120PBF-DIP-4.htm?websale8=conrad-swe&pi=597278&ci=SHOP_AREA_17339_5104021

Thanks for the extensive reply and suggestions for cheaper solutions. Much appreciated.

Last night when I googled optocoupler + Arduino I came across this instructable: http://www.instructables.com/id/Isolating-circuits-from-your-arduino-with-optocoup/

With this circuit:

Is this something that I can use for my application? Where on the circuit do I put the MOSFET?

And, for the optocouplers, what’s the real difference between one with 6 and 4 legs?

Usually the ones with 8 pin ones contain two optocouplers.
The 6 pin ones do have an additional base pin to “wire switch” in addition to the opto switching, but you’ll probably only need the 4 pin one.
The FET would go where you got the bipolar transistor in that schematic

So, this is what I have come up with so far:

Even though the schematic looks somewhat right, the breadboard sketch looks off to me. I followed the guide lines generated in Fritzing when I did the schematic sketch to place the jumpers on the BB.

And I’m still not sure about the red and blue rails.

This schematic is the best so far, IMHO. I can’t speak to the breadboard layout, since I don’t use fritzing, and am not a huge fan of breadboards in general.

How about this?


That looks more like it!

Thank you so much, really appreciate it.

So, the components I’ll need:
1 Diode 1N4148
1 Capacitor 10uF/50V
2 Resistor 120ohm
2 Resistor 100ohm (The shop I’m thinking of buying from does not have 220ohm)
1 FOD817B DIP-4 Optocoupler
1 N-Channel MOSFET 60V 30A
DC Barrel jack
12V axial fan
Wires
Breadboard

My last question is how I best can cram all this into a casing.
Im thinking something in the range of 120 to 150mm x 100 to 120mm.
Why casing? This is going to be a magnetic stir plate when it’s ready.
I feel that a bread board will have a hard time fitting in a casing like that.

The breadboards that come with the Particle kits are 80x55mm, and there are even smaller ones available.
You also might want to get medium (insertion) force breadboards if you intend to move components from time to time.
If they have no 220Ohm resistors you should also be OK with 330Ohm.
https://docs.particle.io/datasheets/kits/#photon-kit

I’ve gathered most of the materials I need.

The last thing I’m trying to come to an conclusion about is how to drive both the Particle and the fan with the same power source.

Say I connect a 12V DC adapter to the breadboard. Could I leech 5V power from that? Maybe by using one of these, or similar? https://www.conrad.se/?websale8=conrad-swe&pi=157954&rdeocl=1&rdetpl=desktop_productpage&rdebox=box1

How could I connect a USB cable to that?

@TripleJr, you can absolutely use that buck regulator (in fact, I have)! I suggest you power the Photon via the Vin pin instead of the USB connector. Make sure you add a 0.1uF decoupling capacitor between the Vin pin and GND. :wink:

1 Like

Ok, first try kind of failed.

It would not spin at all.

So, I tried bypassing the MOSFET directly to the opto coupler. That somewhat failed too.
I could get the fan to spin really slowly if I helped it start. When I put the fan directly to the power source it worked as expected though.

My DC adapter is rated at 300mA at 12V and the fan at 140mA.

Where’s the problem? :confused:

This thread looks interesting … Any luck so far ?

Just got it working as of yesterday evening!

The only problem is that the fan makes a beeping sound in lower RPMs, but that’s not something that concerns me much. Next step or an upgrade would be swapping it for some kind of brushless motor.

Thanks for the help everyone!

Hi @TripleJr,

I’m also trying the same thing but for ceiling fan AC 220V. I just saw your post. :blush: Can you please share the final schematic with their CODE ?

My schematic is: