3 pin pc fan control via mosfet

Understood. Is the BC557 the correct choice for the PNP transistor?

Something like this:

Bc557 is only ok if your fan current is below 100mA
Anyway, if you don’t have any pnp on hands and need to order, I would go with BC327 (current max 800mA).

Your circuit for pnp is not correct, remove the connection on the right side.
Also why you have 5v pullup for tach? Esp doesn’t like it.

Edit: And your diode is in short again…

Not sure if I can follow you now. But is this what you mean? Or is the grounding of the fan still incorrect?

Fixed the diode… my bad…

On the tach:
If I connect that directly to the ESP, I’m getting weird results. Fan at 60% results in 4500 RPM. While according to spec the fan cannot run faster than 1350 rpm.

I found I wasn’t the only one and followed @MrFusion 1st suggestion in this thread

In your circuit there is no ground at the moment! Or maybe there is, but not visible. So fan gnd directly to gnd, not through transistor.
For tach, you obviously pull it up to 3.3V, not 5V. Makes sense?

Yes, starting to make sense. But I am still struggling the understand how the NPN and PNP transistors are working. As I understand, the ESP switches the NPN. When the NPN is on, it switches the PNP. Is it correct that this is necessary because the ESP can’t directly switch 12v?

Here’s another overview with colored lines:

  • Brown = line
  • blue = ground
  • green = data

I rerouted the 3.3v pull-up to the 3.3v pin of the ESP. But at the same time, I am wondering why I am powering the ESP and DS18B20 over 5v. There is no reason, is there? But at the same time, this is not ‘wrong’ either?

Edit: fixed typo on the tach-line. Is indeed pullup

If you want, I can make a circuit simulation for you on falstad.com, you don’t need to create any account.
That way it’s easier to understand.

Yes, very much! Alway happy to learn!

Pullup, right?

1 Like

Exactly.
If you have good 3.3V supply, you can use that. But be aware that then you don’t have 5V pin anywhere in your setup.
5V supply is little bit safer because of voltage regulator between supply and MCU.

But DS18B20 you should power at 3.3V

You need to flip BC327 on your circuit image.
Also, it looks confusing that you route bc337 gnd to Esp.

image

I just inserted a dumb 2W load instead of fan (I don’t know specs).

https://www.falstad.com/circuit/circuitjs.html?ctz=CQAgjCAMB0l3BWcMBMcUHYMGZIA4UA2ATmIxAUgoqoQFMBaMMAKABdwU8Rs1wNCPPlQgxCYPMQSliAFgQYwlSKOiFCGBNjyQMxMKUUlkVACZ0AZgEMArgBs2LAE4hZ3XiK5CqI+CwBKru7C3lBhslTY0NhhPtAILADm-ILY2IJgAjyE3D4sEhAoCIKYKCBFqelhXOLQsvpgvMQ6xJBlZWBlMLJQdQHl+OCEIrI9YMOxrp6TMAkcmSURA9woS1RMIAxiWqMahAgI9dhkmzA4kAeQ2IqyhLIomGNwIObW9o4uCzyQY1mrPiZICwAO7LcrFcElCFA0EVSHw0pQEFgh49NDccZ5ZJwtJQ1I5WJJILZbhuKYAoFAA

1 Like

Many thanks @Karosm! You’ve been incredibly helpful and above all super patient.

I will fix the last issues you mentioned and order parts. That will take some 2 weeks. Of course will get back after that.

Thanks!

You’re welcome, did that circuit simulation make transistor circuit more understandable?
Change also transistor base resistors to 1k, it’s better for your current setup.
Be aware, that you have been abusing your Esp with 5V pullup, 5V temp sensors and especially with unknown current sinking to pwm pin. I would’t trust that board “eyes closed” anymore.

Finally an update here! I got a working PCB (took some iterations), but running into an issue.

I just tested the setup with 15 fans (all 12v) and this will break the setup. After a short period of the the board started to smell and the BC327-25 got very hot. It will burn. The setup is not prepared for so many fans.

@Karosm can you help me once again and suggest a better switch? The current power adapter I use can go up to 5A. The fans are Artic F9 which do 0.16A each according to spec (ARCTIC | Cooling, Mounts, Equipment | The Cooler Way | Cooler than ever). I need about 2.5A, so with a little overhead that makes 3A

Edit: Something like this maybe? TIP125 STMicroelectronics - Transistor: PNP | bipolaire; Darlington; 60V; 5A; 65W; TO220AB | TME - Elektronische Componenten Nederland

You forgot to tell that? I don’t remember anymore…
Anyway I wouldn’t drive more than 2 fans with that tiny transistor.
Can’t you use multiple of them? I don’t remember all details of your setup. High side switch and that’s it? Small pcb relay?

I’m afraid I didn’t tell you that. Sorry, forgive my ignorance.

I use the board to drive fans on my radiators (housewarming). So hard to split it all up. 15 fans is the biggest setup I have, and the most important one…

Here’s the switching part again…

No problem!
What’s wrong with relay? Easiest way to take care of it.
Transistors are not ideal for big loads, they are not energy efficient and that’s the reason we use mosfets for higher loads.
If you have bag of BC327 in drawer, you can use 8 of them and wire 2 fans/each.

That’s an option, but would introduce some practical challenges (mostly wiring). As I probably will need to update/redesign the board anyway (think that will be version 10+ :slight_smile: ), I would prefer to switch to a MOSFET. Would that be a simple replacement of the BC327? Or is there more involved?

If I had to choose between relay and PNP logic level mosfet, I would pick relay. Mainly for simplicity and availability (you don’t find those mosfets like you find NPN).
Fourth option would be NPN mosfet, and try to drive PWM trough diode preventing sinking 12V to pwm pin. Not that I prefer that though.

I need about 7 boards with various amounts of fans connected (between 15 and 3 fans per board). With the relay option (2 fans per BC327) that would require quite some BC327’s, fan connectors, etc. And that’s a lot of soldering, etc… I prefer a generic board that just accepts enough fans in a serial setup

What MOSFET would I need if I would go for that option (Quick Google; IRF4905BPF)? I mean, Ali has a lot these days :wink:

Or should I go for a completely different approach?