ESP32 MOSFET control with button override for testing

Every year I run a small haunted house for Halloween and every year I expand a bit on a circuit to add additional functionality. It has evolved over time and right now the design has the following.

  • 12V input

  • MP1584 buck converter to 5v

  • ESP32-S3 for MCU

  • Presence detection with a microwave LD2410C

  • MOSFET IRLZ44N for controlling outputs (LED, 12v wiper motor, solenoid, etc.)

  • YX5300 for audio out

  • Output voltage selection (5v / 12v) through pin header/jumper

  • manual button to trigger MOSFET output (for troubleshooting)

  • solid LED light to show when output is triggered (1206 SMD, 3-3.2v, 20mA) either by the ESP32 or via the button pressing

  • WS2812B RGB LED status light to show what the circuit is doing (waiting for motion, output, delay time between triggers, etc.)

This year I would like to create a circuit board to clean up a bit of the wiring and make it compact. So I created a schematic with EasyEDA with the assistance of AI and some of my experiences.

I’m not confident on the section of the circuit for GPIO4 to control the MOSFET and have a bypass button override for testing purposes.

Specific questions.

  • Should there be a diode to prevent voltage / current from being supplied to the GPIO when the button is pressed?
  • If so, how do I select and size that diode?
  • Can a standard pin header support the current required for a wiper motor (2+amps)?

Any other feedback is welcome here to make sure that I am not missing anything!

I tried to use this schematic I saw in a YouTube video but I feel like I am missing something (besides the diode that is listed after GPIO5).

Note that I plan to add additional MOSFETs for added output functionality but for now I just have 1 listed.

  • GPIO4 is directly connected to the Anode of D1, bad idea !

  • There are better 3V logic level MOSFETs than the IRLZ44N.

  • The switch is wired to 5V not good since GPIO4 is also connected to the MOSFET.
    Consider using a diode OR gate.

  • GPIO4 is directly connected to the Anode of D1, bad idea !

Sorry, I am still relatively new to this (yes, even though I have done some small circuits). How should I be connecting this? Through a resistor? What is the concern here?

  • There are better 3V logic level MOSFETs than the IRLZ44N.

Do you have any other specific suggestions? What makes the other MOSFETs better? I have little to no experience here so far.

  • The switch is wired to 5V not good since GPIO4 is also connected to the MOSFET.
    Consider using a diode OR gate.

Perfect. This is what I was looking for. I will do some research to understand and select a diode OR gate (I am assuming that is one component and not a diode or a gate).

Pin current is generally measure in milli amps so that is a big fat NO. Use a mosfet or relay to control the motor and the pin controls the mosfet or relay.

Thank you for the clarification on pinheader ratings. So if I wanted to select the voltage for OUTPUT1, I should use an additional 2 MOSFETS that would be controlled based on the manual pin header selection?

Please hand-draw what you are saying, as it's too easy to misunderstand words.

  • Consider this:

EDIT

  • Made a correction.

Who will do the board assembly (solder on all the parts)?

How much current both peak and steady state does the motor draw?

  • Hopefully the OP will come back on that.

I have looked over this and this appears to be great! This is much appreciated! A couple of questions to understand this properly.

  • It appears that the IRLML2502 is for lower amperage uses (battery powered according to Gemini). So I think that I need to use a IRLZ44N for the higher amps when working with a windshield wiper motor (potential 5amp operation, maybe 10amp starting).
  • Do you have a suggestion on the type of switch at J1?
  • Is D1 the logic OR diode?
  • What type of LED is at D2? It has to be compatible with 5v and 12v? Or does the resistor R1 “make” the LED bright when 12V is selected and dimmer when 5V is selected? (I have to do the math here to understand this but wanted to get the question out there.)

I never actually measured it on my prop setups but a quick Google search is showing that the steady state could be 5amp and peak starting could be 10-12amp at 12v. I don’t use anything heavy with the wiper motors.

I will do it myself. I have soldered some other DIY boards (Quinled DigUno and DigQuad).

I think that @LarryD has solved this for me in his post.

  • Select a MOSFET that can pass the current you require for your motor.
  • It appears that the IRLML2502 is for lower amperage uses (battery powered according to Gemini). So I think that I need to use a IRLZ44N for the higher amps when working with a windshield wiper motor (potential 5amp operation, maybe 10amp starting).
    You can try the IRL44N. Just make sure Vds is a low value, i.e. the MOSFET is fully turning ON.
  • Do you have a suggestion on the type of switch at J1?
    SW1 can be any switch.
  • Is D1 the logic OR diode?
    No, D1 is the motor's kickback diode. This version does not use logic OR diode.
  • What type of LED is at D2? It has to be compatible with 5v and 12v? Or does the resistor R1 “make” the LED bright when 12V is selected and dimmer when 5V is selected? (I have to do the math here to understand this but wanted to get the question out there.)
    Use a LED you have; R1 is selected for the brightness you want on the D2 LED.
    Let's say Vcc = 12V. Assume we need 20mA to get the desired brightness.
    Therefore: 12V(supply) - 2V(LED voltage) / .02A = R1 = 500R, use 470R.

Ah, now I see what this is. Also known as a flyback diode.

That all makes sense for when 12v is selected. But when 5v is selected then you have a resistor requirement of [5v(supply) - 2v (LED voltage)]/0.02A = 150R.

Or, if you use the 470R with 5v, then you will allow allow 6mA. Will that allow the LED to work?

In writing this response, it appears that I really do not understand LED’s and I need to educate myself further on this to understand it.

Regardless, I appreciate the engagement and support on this! Thank you!

I’m still looking at your drawing and I have 2 questions in regards to the 3v3 push button bypass.

  • Should there be a 680R resistor between the 3v3 ESP32 pin and the switch?
  • Or should the connections from SW1 be moved to “before” R2?

I will try this. To confirm that the MOSFET is fully on, I should check the voltage on J2? If the voltage does not match the selection on J1, then is it safe to say that the resistor selection R2 needs to be changed (lowered)?

  • Leave the switch wiring as seen in the schematic, no 680R resistor is needed.
  • Measure the voltage across the Drain to Source of your MOSFET, what do you get ?
    Your motor must be in circuit.

  • R2, 680R should work, if Vds is large a better MOSFET would be necessary.

  • Modern LEDs often work a currents as low as 2 to 4mA.