I am trying to hook 12V RGB Led Strip (LTROP SMD 5050 RGB LED Light Strip) to a NodeMCU unit. I know there are many different tutorials on this and I am very new to wiring and electric circuits.

I used BUZ91A n-MOSFETs and 150 Ohm resistors for each of the RGB channels, and the board is using it's own power supply via usb.

my wiring

I use very simple code to check if the setup works:

#define REDPIN D3
#define GREENPIN D1
#define BLUEPIN D2

#define FADESPEED 5     // make this higher to slow down

void setup() {
  pinMode(REDPIN, OUTPUT);
  Serial.println("Finished setup");

void loop() {
    analogWrite(REDPIN, 800);
    analogWrite(BLUEPIN, 1020);
    analogWrite(GREENPIN, 400);

  Serial.println("Finished loop");

I suspect nothing works because NodeMCU and the LED are using different power sources and the fact they have common ground doesn't seem to be everything required.

  • What happens when you try to PWM the built-in LED? BTW, you don't have to execute analogWrite() again and again in the loop, it is enough to do that only once in setup() but that isn't the problem.
    – Chupo_cro
    Dec 12, 2016 at 0:44
  • It works fine with D0 - it changes the brightness based on value in analogWrite()
    – abolotnov
    Dec 12, 2016 at 0:51
  • The connection is OK. Which NodeMCU board/version do you have? The pin mapping may be different from the Arduino defines. For example my NodeMCU (LoLin) has built-in LED on pin 2 which is D4. D0 is pin 16 so the other pins might differ too on your board.
    – Chupo_cro
    Dec 12, 2016 at 0:58
  • Looks like version 1.0 to me. The Arduino IDE "Get Board Info" does not tell much: VID: 10C4, PID: EA60
    – abolotnov
    Dec 12, 2016 at 1:03
  • I would first try to blink a LED using digitalWrite() on D1, D2 and D3 (one by one) to see if these outputs are really associated with the pins where you connected the PWM outputs (just don't forget the current limiting resistor, max source current is 12 mA and max sink current is 20 mA). And you might first try to change the PWM frequency, for example try with analogWriteFreq(200);. The default PWM frequency is 1 kHz and that should work but nothing to loose if you try.
    – Chupo_cro
    Dec 12, 2016 at 1:15

1 Answer 1


So now we finally know the reason is MOSFET's threshold voltage is too high. The solution is to drive the gate with NPN transistor (you can use BC547 or 2N5551 or similar). You have to connect it's collector to 5 V and it's emitter to GND. Put 10k or 100k resistor between 5 V and the collector, connect the collector to MOSFET's gate and GPIO to the base of NPN transistor. Put some resistor between GPIO and the base of the transistor, maybe 4k7 or similar.

HIGH from GPIO will switch off the LED strip and LOW will switch it on.

Another solution is to use MOSFET with lower threshold voltage.

If you want to avoid adding NPN transistor you can use NTD5867NL MOSFET which has max threshold voltage 2.5 V so it will for sure work with 3.3 V at the gate but is rather expensive (about $4). Much better solution is adding cheap NPN transistor.

Here is the schematic:


simulate this circuit – Schematic created using CircuitLab

Here is the correct wiring: enter image description here

  • Can you please advise on a fitting MOSFET model to use?
    – abolotnov
    Dec 13, 2016 at 8:01
  • I'll take a look through some other MOSFETs and write you a note if I find the one which might work.
    – Chupo_cro
    Dec 13, 2016 at 8:15
  • I've edited the answer and added the data about MOSFET which will for sure work with 3.3 V.
    – Chupo_cro
    Dec 13, 2016 at 8:31
  • Thank you so much for following through on this problem with me. I wanted to ask one last question. Are there any sort of Led Strip Driver Boards I could just purchase and wire to my nodeMCU? I suck at all this wiring and circuits (you can tell) and the further I go the better I understand I'd rather stick to the programming side of things. Also, I am trying to finish by project on time for someone's Christmas gift. Again, thanks a lot for your kind help.
    – abolotnov
    Dec 13, 2016 at 15:13
  • 1
    Here you are the wiring diagram. You can use the same 12 V which you are using to power the LED strip instead of 5 V to avoid using 3 different voltages. But, as you are probably getting 3.3 V from 5 V then it isn't a problem if you use 5 V. Of course, a MOSFET must be n-channel and not as in the picture.
    – Chupo_cro
    Dec 17, 2016 at 8:54

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.