1
\$\begingroup\$

I am pretty familiar with Arduino, and I will be using a NodeMCU for an upcoming project I'm doing. I have never used a NodeMCU before. I am using it along with a few sensors to turn on and off some 12v DC Solenoid valves to water my garden. Anyways, I was trying to figure out how to control the solenoid valves with the NodeMCU, as I am more familiar with 5v than the 3.3v from the NodeMCU. I was planning on using a MOSFET, but I can't find any other NodeMCU projects that use MOSFETs. They seem to all use those relay boards. What is a good MOSFET for this purpose? The solenoid only draws less than an amp, but im planning on using this mosfet for a go to for other projects in the future, so maybe somewhere in the 3-6A range. The most important thing is working with the 3.3v from the NodeMCU. And can I just connect the base of the MOSFET directly to the NodeMCU pin or do I need a resistor?

\$\endgroup\$
  • 3
    \$\begingroup\$ I think you need to remove "NodeMCU" from your search, just try to find any 3.3V microcontroller using MOSFET's, the circuit should be the same. \$\endgroup\$ – Ron Beyer Mar 15 at 22:58
6
\$\begingroup\$

If you ask 10 people here, you will probably get 10 different answers.

This is what I use as a hobbyist. The TO-220 package is friendly for home use. Low ON resistance is more important than maximum current. You want to oversize for low voltage drop and so you won't need a heatsink for most use. This part is rated at 60A, but I wouldn't use it at more than 10A or so with a 3.3V gate drive.

If you are building a ton of these, you might want to look for something lower cost. Learn to understand the curve that specifies voltage drop vs current for various gate voltages.

For a simple switch you generally don't need a series gate resistor. But you probably do want a resistor to ground. Otherwise, if your MCU isn't initialized before 12V is applied, you may drift into a linear region and stress the MOSFET.

schematic

simulate this circuit – Schematic created using CircuitLab

| improve this answer | |
\$\endgroup\$
  • \$\begingroup\$ Thank you, that answered part of my question! Which specific TO-220 MOSFET would you recommend? \$\endgroup\$ – Randomaker Mar 16 at 0:41
  • 3
    \$\begingroup\$ The part number is on the schematic. \$\endgroup\$ – Mattman944 Mar 16 at 0:53
  • \$\begingroup\$ ok I missed that you had the number on the schematic, thanks so much this helps a lot! \$\endgroup\$ – Randomaker Mar 16 at 13:17
2
\$\begingroup\$

Adding to the answer of @Mattman944, and answering your question about gate resistance:

Series Gate resistance: Unless you are going to switch on and off several times, as it is the case of SMPSs, the gate resistance should not be necessary. I can think of two reasons which could require a gate resistance: a) in a SMPS, it can be used to slow down the dI/dt of the MOSFET, thus reducing EMC problems. b) in old technologies, the MOSFET's gate capacitance was prone to be destroyed if the inrush current was not limited.

Because of the highly inductive load, make sure to decouple (via capacitors) the supply voltage of the NodeMCU and the one from the solenoid, in order to prevent interference and voltage drops of their voltage supplies. In some cases it can even shut down the MCU.

| improve this answer | |
\$\endgroup\$
  • \$\begingroup\$ I think you have your solenoids and relays mixed up. A solenoid is a linear actuator that moves with an electromagnet. They are used for many applications, but the one I am using is connected to a water valve, so it is basically an electrically controlled water valve. Here is a link to the one I am using- aliexpress.com/item/… I am looking for a transistor to control a solenoid from a 3.3v microcontroller. Your information still helps though! Thanks! \$\endgroup\$ – Randomaker Mar 16 at 0:37
  • \$\begingroup\$ My bad. It was late already when I answered the question. I will amend my answer. The proposal sent by @Mattman944 should be the one what you are looking for. \$\endgroup\$ – vtolentino Mar 16 at 6:51

Not the answer you're looking for? Browse other questions tagged or ask your own question.