Controlling a Fan with a PWM Wire (ESP32)

Hi all, I’m a noob hoping to be pointed in the right direction.

I have a fan that is controlled using a little handheld controller with a single button that cycles through 10 different speeds. I’d like to ditch the controller and use an ESP32 to choose my speed instead.

As per the picture below, there are 3 wires that run between the fan motor and the controller - they’re labelled +10V (red), GND (black) and PWM (yellow). Seems like the motor side feeds power to the controller and it sends PWM back. I have measured the voltage on the PWM wire and it looks like setting 1 reads 1V, setting 2 reads 2V, etc., all the way up to 10V at full tilt.

Can someone help me figure out what I’d need to eliminate the controller and use a PWM pin on an ESP32 to take its place? I can run all 3 wires back to my ESP.

Should be fairly simple IF your analysis of the wiring is correct.

Just hook up the gate of an appropriate small signal MOSFET to the pin of your choice on the ESP32, connect its source to GND an its drain to one side of a 10k (for instance) resistor. That junction also goes to the PWM input of your motor.
For the supply side, all you need is a buck step-down converter or a linear regulator with a heatsink (LM317/LM350T in TO220 package would do) to step 10V down to 3V3 for your ESP32.

Keep in mind that using a MOSFET to step up the ESP32's output to the necessary 10V level also inverts the signal, so if you program a 100% duty cycle the motor will actually 'see' a 0% duty cycle and vice versa. But that's not an issue at all of course.

Thank you for your answer!

I have a MOSFET that should work for this. I am not following where the 3.3V is being stepped up to 10V though - also, what do you mean about the "Supply side" part where you're talking about stepping 10V down to 3.3V?

Sorry, forgot one crucial aspect: one end of the 10k resistor goes to the mosfet drain, the other goes to +10V. The junction of drain & resistor will have the (inverted) PWM signal with a 0-10V amplitude.

You've got 10V coming into the controller, but your ESP32 runs at 3V3. I recommend using a buck DC-DC step down converter to go from 10V to 3V3 for your ESP32.

Which one? Make sure it's a logic-level MOSFET. You can get away with a 2n7000/7002, BSS123 etc. in this application, but it's not entirely optimal. Throwing a big power MOSFET at this in a TO220 package is just silly, and forget altogether about using an IRF510/530 etc. for this as it will NOT work at all. Hence the question :wink:

1 Like

Ah, gotcha. Thanks for the clarification.

Regarding the supply side part - I figured that was what you meant. I'm already powering the ESP with a different 5V supply as it's doing a bunch of other stuff as well though, so I'm good there. Do I need to tie the ground of the ESP to anything?

The MOSFET I have that I was hoping to use was an IRLZ44N which is logic-level, but I'm guessing it's overkill like you say.

Yes, GND of the ESP needs to be connected to GND on the motor/fan.

It'll work, but indeed overkill IMO. But if that's what you have and you have no other use for it, why not? I'd grasp the opportunity and order a bag of small signal mosfets though, get some N-channel and P-channel ones, so you're good for future projects as well :wink:

Excellent. Can't wait to give it a try. Thanks for your help.

Let me know how it works out; sounds like something that shouldn't give too many problems!

1 Like

It works beautifully. You rock!

Awesome :+1: :grinning:

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.