I'm trying to make a HomeKit device that will turn a component on and off. The component's power supply is 12v at 2amps. I figured I'd put the NodeMCU inline with the power (the component's power adapter into the NodeMCU, then the NodeMCU switches the rest of the power on/off to the device). I'm using a L7805CV 5v voltage regulator to give the NodeMCU 5v off that power. So far so good.

Next I'm using an IRF740 MOSFET to switch the power on/off to the component.

The problem is the NodeMCU pin only provides 3.3v, which is not enough power to trigger the MOSFET for the voltage/amps the component needs. If I jump the gate pin to the 5v, the MOSFET works.

So, I need to somehow have the 3.3v pin from the NodeMCU trigger 5v into the gate of the MOSFET.

Is there an easy way to do this without using a logic level shifter? I'm trying to keep this as simple as possible with as few components as possible. Can I somehow use another IRF740 to trigger the 5v? I'm not sure how to do that, as the MOSFETs are switching on the grounded side of the circuit (12v into component, component's ground into MOSFET).


1 Answer 1


You have 2 options:

1) Use a 3.3V logic level MOSFET designed to be interfaced with 3v3 systems.

2) Tie the MOSFETs gate to +5V using a 10k pull up resistor, and use a NPN transistor to ground the MOSFET via the NodeMCU when required. This is not going to give you spectacular switching characteristics but will work in low speed switching.

It should be easy enough to understand how this works: The 10K resistor is used to turn the MOSFET on when the transistor Q2 is off. To turn the MOSFET off you turn the transistor on, which shorts the MOSFET gate to ground.

See image below (Image not mine, rather googled "NPN MOSFET driver"), replace +12V with +5V

Image not mine, rather googled "NPN MOSFET driver"

  • \$\begingroup\$ Option 2 sounds workable and only adds a resistor and a transistor, both of which I have handy. Don't care about speed at all, so it sounds like a good option. I should get my hands on some 3v3 mosfets though for future use. Got a bag of 100 of these IRF740's on the cheap a while back, so I'm trying to use those for now. I'll report back later once I have a chance to try it out. \$\endgroup\$ Jan 23, 2017 at 19:26
  • \$\begingroup\$ Sort of related - can you recommend a good 3.3v mosfet? There are so many options I've no idea where to even start looking. \$\endgroup\$ Jan 23, 2017 at 19:27
  • 1
    \$\begingroup\$ Rather than recommending a specific one, its better to understand the rationale behind making a choice. Mosfet datasheets list a parameter called Vgs(th). This is the voltage required between gate and source to turn the mosfet on. So go through the datasheet and find one that has a Vgs (th) listed somewhere below 3.3V. Here is one: dlnmh9ip6v2uc.cloudfront.net/datasheets/Components/General/… \$\endgroup\$
    – MAM
    Jan 23, 2017 at 19:36
  • \$\begingroup\$ This is not fail safe. If the power is on but the nodemcu is off and non functioning, the output of the mosfet will be held on. Need to put in something, or another transistor to keep it switched off in this state, so it only runs when commanded to \$\endgroup\$ Sep 10, 2022 at 23:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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