Using ESP32 to control a fan with PWM - Replacing Current MOSFET

@TangoOversway
From what read in the other thread, this is all you need.

Is this something that, as someone still new to actually building circuits, I could have found? I'm thinking you must have used search engine for parts where you could specify the tolerances. Is that what you did?

And, at this point, I'm using Fritzing, since it works on a Mac and does breadboarding, PCB, and schematics, but I don't know what else is out there that actually works well. What did you use to do that sketch?

Yes. Both Digi-Key and Mouser will list most of the important parameters for a device that you can select for a search.

That schematis was drawn with LTSpice but it's only used for simulations. If I want to create a PCB I will use KiCAD. Many people use EasyEDA.

I also use Fritzing to do a breadboard view of a circuit for people who don't quite understand how to read a schematic.

I found the datasheet on the BC547C. There's one concern, and part of that is about if I measured the current correctly. I used a DMM set milliamps and put the ground probe on the ground connection on the MOSFET switch (the original one - I have a photo with wiring marked on it in the first post on this thread) and the + probe on the VOUT+ connection on the gate. That's where I got the .23mA reading.

Did I do that correctly, or would that be a better place to measure the current? (I'm keeping that in mind with the following questions.)

I'm not sure how to read the data sheet. I was looking for the max current and voltage that the base can handle and what it would take to turn it on, as well as the max current and voltage that can go through the gate when it's open. I couldn't find that - so what should I be looking at, instead, or how are those ratings labelled?

For now I'm using it because it's the first one I found and easy enough to figure out. I'm sure there are many advanced capabilities that I don't know how to use on the others at this point. This is my start - so, likely not the one I'll stay with. But, for now, it's made my breadboarding easier.

I did see KiCAD. I think it's one I looked at and said, "Okay, keep in mind for when I know more about what I'm doing. I remember, during one of those times when I had a few months and was trying to learn more about electronics, finding Spice as a package on a Linux system. That was probably around 2000 or 2001. If I remember, at that time, Spice was not graphical and required a text file to describe the circuit. But I could mis-remember.

Slight variation in the topic. Is this page a good guide for starting to learn how to pick out a MOSFET?

You did it correctly.

All the parameters in the data sheet are important. Explaining how to select the right transistor for a specific application would get a little complicated, for me it's basically a matter of experience.

This is a great place to learn basics electronics

Go to the chapter on Bipolar Junction Transistors.

These are the parameters you should look at first when selecting a transistor
Max current. Ic
Max voltage, Vceo
Max power (device) dissipation.

If your circuit requires less than than the maximum ratings then that transistor is probably a good choice. However now you need to consider Vebo, Vebo, Vbe(sat), Vce(sat) Vbe(sat), Hfe, and ft.
If you are designing an amplifier, there are additional parameters to consider.

1 Like

First you need to understand how they work.
This website has good tutorials on MOSFETs and Transistors
https://www.electronics-tutorials.ws/transistor/tran_7.html

Thank you! For this, and the other post, with links and good information overall. I know it's only a start, but it gives me information to absorb and work with so I know more about what I'm doing, but also so I get an idea of just how much I don't know and need to learn!

You will learn a lot if you build some simple circuits to see how they work. A transisor, LED and a few resistors controlled by arduino PWM is a good project.

1 Like

FYI:
The reason I chose a transistor and not a MOSFET is because most MOSFETs that will work with a 3.3V gate signal are tiny SMD types and not so easy to use with a breadboard.

1 Like

I'm working on doing that. The issue, right now, is that I have something I have to get up and running quickly. (This is for a vent fan controller for a vent so I can use a laser on my CNC without setting off smoke alarms or getting smoke on everything in my shop.) When I get things working, I'll be focused on stuff that's more "business hours only" kind of thing and will have a lot more time to experiment. This is the kind of thing I've wanted to learn for a long time.

That's a big help. For now I'm doing this on a breadboard and, for a while, it'll be running on a breadboard, but I want to make a circuit board (another reason for the vent system I'm making - so copper dust from etching circuit boards on the CNC doesn't spread around the shop - it might not all get sucked up, but with the hood, it won't be floating around in the room). It's helpful to have something I can use for breadboarding and later put on a PCB.

@jim-p:

One more question. I've read, from others who have made similar controllers, that the PWM signal had to have a full +10V input to make the fan go at 100% speed. They claim with lower voltage, it won't go as fast. I see you have a 10K resistor between the +10V source. Won't that drop the supply voltage? And will it be enough to effect the PWM signal?

(I also realize you know this topic well, so it's quite possible that those talking about the need for the full 10V are likely less experienced hobbyists.)

PWM (Pulse Width Modulation) is a method of encoding information by varying the duty cycle of a squarewave type signal. The amplitude is constant, in this case 10V, only the width (duty cycle) of the pulse is varied hence PWM. It is the varying pulse that controls the speed not the voltage, 0% is OFF, 100% full speed.

xx

I knew the important point was the duty cycle, not the amplitude. If that's the case, is it possible a direct connection from the 3.3V line from the ESP32 would be enough to control it?

It might be but without knowing what the actual circuit is inside the fan, you run the risk of applying 10V to the ESP and damaging it.

So a big reason for a MOSFET or transistor in there is about protecting the ESP32 and the rest of that circuit?

No, not actually. From the other thread I see that they made it work with a 10V PWM signal. Since the ESP can't generate 10V we need another circuit that can take the 3.3V PWM signal from the ESP and turn it into a 10V PWM signal for the fan. It's not a matter of protection but of generating a 10V PWM from a 3.3V PWM

It may well work with a 3.3V PWM signal but as I said I not sure about the circuit inside the fan. It may have a pullup to 10V so you could danage the ESP if you connect it directly

1 Like

Are you talking about another thread here? (Sometimes I use the wrong search terms and miss things!) Or on another forum?

I have it working now, controlling both fans with the transistor in the circuit.

I'm still going to add a couple things for safety, then use it in breadboard form for a while to make sure I don't let the magic smoke out of any components and, if it makes it through that, then design a PCB. I'm looking forward to making a PCB on my CNC - it'll be the first time I've ever done any kind of circuit work (in this case, more putting together parts of what others have done and advice from people here), breadboarded it, then gone from breadboard to PCB (and in a printed case, so it'll be in one container and look like something professional).

Thank you for all the help and advice!

The one you mention in post #1
Glad it worked!