Controlling 12v fans from esp32 witohut PWM

I have a set of “dumb” 12v fans like this: GDSTIME 3 x 120mm Computer Rack Fan 360mm Cabinet Inverter Cooling Fan with AC 220V 230V 240V UK Plug DC 4V 5V 12V Adjustable Speed Control Dual Ball Bearing PC Fans for Chassis Server Workstation : Amazon.co.uk: Computers & Accessories

Simple knob to adjust speed which I want to control from HA and esphome.

Endless projects around all which use of course PWM fans so none of that helps me as these fans actually have a DC plug on them (just + and - wires inside) no tacho/pwm

I plan to keep using this 12v PSU to drive an esp32 (using a 12v to 5v adapter) and something like this? WINGONEER 5Pcs IRF520 MOSFET Driver Module : Amazon.co.uk: Business, Industry & Science (which I read that it doesn’t actually work in reality as found by some forum members)
Anyone can shed some light on what things I need other than the above? And idealy a proper MOS board that can drive these 5 fans I have?

Can’t see why you can’t still use PWM, you just won’t get the speed feedback and speed will always be an approximation but may be adequate depending on your needs.

Well there is no pwm pin on these fans, so would just need to increase and decrease the voltage directly as that’s how they currently work right now, the knob just goes 3.6v to 12v

That mosfet is not logic level one and it’s very questionable how it works with 3v3 on gate, if at all.
Pick some other module, one of those that have optocoupler circuit on trigger side.

And place flyback diode across mosfet output (fan supply).

Just a random search not sure how good or bad they are

That should work. It has optocoupler on trigger feeding half of the supply voltage to gate (6V here).

I’m pretty newbie with motor control, and many are critical of the old technology L298N use, but I find the package convenient.

You can feed it 12V, power a esp off of the 5V output, and add speed control via the pwm.

I’ve controlled small two wire motors and pumps with them.

https://howtomechatronics.com/tutorials/arduino/arduino-dc-motor-control-tutorial-l298n-pwm-h-bridge/

Oh NO! :scream:
Now we know who to blame for climate change…

:smile:
I recall you mentioning they aren’t very efficient.
I even went looking for modern alternatives after the last time I was chastised on the forum:)
Last time I looked I just couldn’t find anything in as a convenient package and a comparable price point, especially being able to power an esp. So I just keep going back to this golden oldy:)

Obviously I was joking here, but if you want dirty cheap mosfet alternative, look for tb6612fng.

OP doesn’t need H-bridge, but for low current application one could use it as well.

That’s the one that always pops up for me on an alternative search, but I don’t believe you can power an esp at 5v off it when using it at 12v ? I think you’d need separate buck?

It works all fine with esp. Your l298n has certain limitations that TB doesn’t.
If you want to study more about it, I link Pololu page here ($1 AE boards do not much difference)

But you’d need a separate buck or 5v power supply right?

Why would you need it if logic voltage is 2.7 V to 5.5 V ? Esp has 3.3V so there’s no conflict.

My understanding is as follows.

If using a L298N you only need one power supply.
You power the L298N with (Say) 12V, and it can the provide 5v to the esp and 12v to the motors.

If you use a tb6612fng, you need 2 power supplies. Supply tb6612fng with 12v, then separate 5v (or 3v3) supply (or buck) for esp.

Happy to be told I’ve got this muddled up, but that’s my understanding.

You are correct, L298 has linear voltage regulator to power MCU at 5V from up to 12V supply.
On the other hand common esp32 devkit has regulator to power it from 12V as well.
So it depends, in some cases L298 can be convenient..

So I would wire my fans + and - to the motor power on the board? i.e. GND and VMOT pins and then ignore all the AO,BO, etc?
How about the PWM pins on the other side? Needed? The fans only have + and -

I am the l298n fanboy so I don’t know about the tb6612fng :wink:

But yes, my understanding is as yours. Yes I think you would still hook up the pwm to the esp as that would control voltage to the fan.

No.
You connect your 12V power supply to VMOT/GND and your fan to AO1/AO2.
AIN1/2 are used for direction and PWMA for speed control.
VCC to esp32 3.3V pin and GND to GND.

So wiring is just like for L298 when you don’t use the onboard regulator (esp powered from USB or external power supply).

Additionally there’s STBY to put the driver to standby mode.