3 pin pc fan control via mosfet

Greetings.
For several weeks now I have been struggling with a trivial task - controlling several PC fans using ESPHome.

In general, there are a couple of the most common fans for a 120x120 case. They have a 3 pin connection. I just want to control them via Home Assistant → ESPHome. That is, change the speed min-max and turn it off completely.

After watching a bunch of videos, looking at various forums and sketches, I still couldn’t find the answer to my problem. I use an IRFZ44N mossfet for this task, with a couple of resistors and a capacitor to keep the fan from stopping and beeping at low speeds.

But I still can’t get the fan to correctly reduce the speed to almost the minimum, even at 1% it spins at about 40-50% speed + the power, even when turned off, remains somewhere around 6-8 volts, from -why the fan windings start to burn (yes, maybe a relay is needed here).

I’m using an ESP8266 and the most basic code, the frequency has almost no effect on anything.

output:
  - platform: esp8266_pwm
    pin: GPIO4
    frequency: 100 Hz
    id: pwm_output_d2
    min_power: 0%
    max_power: 100%

fan:
  - platform: speed
    speed_count: 100
    output: pwm_output_d2
    name: "pc test fan"
    id: "pc_test_fan"

My connection scheme looks something like this. The yellow wire is the speed sensor

In the end, the idea is that 2 more DS18B20 temperature sensors will be connected, which will measure the temperature, and based on their readings, you need to turn on/off/change the speed of the fans. But I was still stuck at the initial stage. :disappointed_relieved:

That’s not a logic level mosfet, it’s not going to work.
IRLZ44N is logic level mosfet and it might work, even if gate voltage should be >4V.
Mosfet module with drive circuit for 3.3V is what you need.

Working on the same right now.

Try these:
https://a.aliexpress.com/_EGBJvfV

Same problem with those you linked (FQP30N06).
You should look for FQP30N06L


do you mean such a module?

Yes, as far it’s for 3.3V gate voltage (not that in imagine).
I would recommend this:


is this possible?

It should be ok. One I linked is better choice.

Don’t take me wrong. Your actual is not going to work! But bare IRLZ44N could work well. Problem is that its declared >4V, so with luck one could work with 3.3V but another might not… Mine are all working well.

Okay, thanks for the tip, I ordered lr7843 modules on AliExpress, I just have to wait.

one more small clarification: will this module be able to completely turn off the power supply? those. Will the fan windings burn? Or is it worth ordering a relay?

Thanks @Karosm will change that MOSFET :grin:

I noticed TS is using a capacitor near the fans. I understand why (spin down), but is that really required?

Of yes, which do I need?

When you don’t need to control speed (you do it separately with pwm pin), I would go with relay module of NPN transistor

Actually there should be flyback diode.

image

Anyway, (also for @MARK2580 )if you just have a small 0.2A cooling fan, you can drive it with common NPN transistor like BC337. Better than mosfet.

Not sure if I can follow you on the BC337. Not all PWM fans go to a full stop when PWM = 0. That’s when the MOSFET kicks in to just remove power.

Found this: make fan stop spinning at zero · Issue #17 · patrickcollins12/esphome-fan-controller · GitHub

A flyback diode (1N4007) is also recommended in this thread.

That’s when NPN transistor do it better than mosfet.

Wiring is same, difference is that BC337 is ok up to max 0.8A where mosfet can go up to 100+A. But 99% of mosfets are not able to turn on with arduino voltages, only partially.
You only need BC337 (or 2n2222) and ~500ohm base resistor

1 Like

So that would lead to this?

1 Like

if pin4 is GND for fan.
And your fan current is within limits.
In perfect design you put also flyback diode(if not already inside that fan)

Ah, yeah… forgot about the flyback. Added now in the post before.

Fan is 12v. Pin 4 is ground.

Getting somewhere. Thanks a lot @Karosm

You added short circuit!

Going over the limits of what I understand about electronics :face_with_diagonal_mouth:. In other words; I’m learning :grin:

But the flyback should be on the 12v rail, if I understand correctly. As the flyback prevents load to flow back.

So not between the 12v and ground.