Hi
I wanted to ask the experts about something that I think should not be extra hard to do but since I am an amateur in electronics it is quite baffling to me.
I have a 5V brushless fan that I would like to control with my ESP32 board. Since it uses 5V I should be able to power it with the ESP board.
I'll upload an image of the wiring I've done.
So basically I've connected +5V to the fan's positive with a diode between. and the negative side I've connected to the drain of a BS170 N channel mosfet and the source to ground. Then I connect a GPIO pin to the gate.
I am using PWM to control the fan speed, now I am only using two settings 255 or full load and 0. When I turn on the esp the fan spins at like 70%, because it's only getting like 4V because of the diode voltage drop. I use a button to toggle between 255 and 0 duty cycles, when I press the button to switch to 0 the fan slows down but does not completely stop. There is still about 1.7V going to the fan from the power source, however the voltage between source and gate is 0.
Am I hooking up the fan incorrectly? Why does it not turn off completely.
I was told that motors and fans can produce kickback that can damage the esp if it's not protected with a diode, maybe I misunderstood
But you say this mosfet is not fit for esp32, can you suggest some model that is?
I suggest you read this. Perry Bebbington did an excellent illustrated article on Flyback diodes and why you need them which includes diode placement.
Next when you find the suggested MOSFET you want about a 10K resistor gate to ground. Actually if this is a low current motor I would just consider a common NPN switching transistor like a 2N2222 rather than worry about the voltage gate source of a MOSFET. I would not power the motor using the ESP32 board.