WiFi Controlled Portable Fan using ESP32 and IRF520

I’m currently working on a project where I built a WiFi-controlled portable fan using an ESP32. I would like to share my setup and ask for feedback or suggestions to improve it.

Materials used:
ESP32 Development Board
IRF520 MOSFET Module
12V portable fan
Battery holder with three 18650 batteries (3.7V, 1200mAh each)
Jumper wires

Project description:
The ESP32 is used to control the fan through WiFi. I connected the MOSFET module to act as a switch for the fan. The GPIO pin (G25) from the ESP32 is connected to the signal pin of the MOSFET module. The fan is powered using a battery pack (3x 18650 in series), and the MOSFET controls the power going to the fan.

Connection summary:
ESP32 GPIO 25 → MOSFET SIG
ESP32 3.3V → MOSFET VCC
ESP32 GND → MOSFET GND
Battery (+) → MOSFET VIN
Fan connected to MOSFET output (V+ and V-)

Even though I uploaded the code and the ESP32 seems to be working, I’m having an issue where the fan does not spin when I try to control it over WiFi. The system powers on and the connections appear correct, but the fan does not respond to the control signal from the ESP32 through the MOSFET module. I’m not sure if the problem is with my wiring, the IRF520 MOSFET, the power from the batteries, or something in the code, so I would appreciate any help or suggestions on what might be causing this issue.

Welcome!
That sounds like a fairly advanced project that could be a lot of fun! However, we’re more than happy to help with your design or code, but we need you to make an initial attempt. Please design and write your code, then post it using code tags along with an annotated schematic and an explanation of what’s not working properly. There is also a for hire section if you want to pay for it.

  1. Show Your Work First: Before asking for assistance, make an attempt to design or write the code yourself. Share your work along with details about what isn’t working. That includes a preliminary schematic that you drew. Please realize we are not clairvoyant and cannot see, touch, feel or guess what you have.
  2. Provide Clear Documentation: Since we can’t see your project, share an annotated schematic (best) or a clear drawing of your setup. Clear Pictures are welcome, but avoid using Fritzing diagrams as they are wiring diagrams, not schematics, and are not ideal for troubleshooting.
  3. Include Technical Details: If there is specific hardware involved, include links to technical information. There are often many versions of similar components, so precise details are essential. I will assume the processor is a UNO. Many times the processor is stated as ESP32, please state which one and post a link to it.
  4. Reference Resources: For additional help, check out useful links and tutorials: Useful Links on Arduino Forum. Of course one of the better sources of information (in my opinion) is the Arduino Cookbook. Skim it cover to cover and stop on any project that interests you.

With no schematic or pictures of wiring to help out, about all I can say is that the IRF520 gate threshold voltage (the gate voltage at which the MOSFET begins to turn on) can be as high as 4V. So your 3.3V signal from the ESP32 might barely turn the MOSFET on, but just enough to put it in its linear region and soon get hot. I'd not expect a randomly chosen IRF520 to turn completely on with less than 10V on its gate. I certainly wouldn't design a circuit with less than that.