Can I use multiple MOSFET switches?

This might make some eyes roll but I want to make sure I'm doing this correctly.

I want to control two WS2812B LED strips from the same ESP32. The ESP will be a good 6+ feet from the LED strip so I want to step the data line up to 5V. According to this tutorial I can use a MOSFET as shown. I have some IRL540N on hand and I presume these will do the job despite the schematic in the tutorial showing 2N7000. I've replaced the 2N7000 with the IRL540N in my edit of the schematic, below.


 

Here is my main question: Can I make two identical circuits, both using the same 5V source (each circuit including its own 2k2 ohm RL between 5V and a MOSFET), with each Output going to a separate LED Strip (controlled by two separate GPIO pins on the ESP)?

Would it make any difference whether or not the 5V is the same 5V source that powers the ESP?

Also, I'm new to these LED strips. I've read that a 60 LED/meter WS2812B is about 1.125 amps per foot at full brightness... The AWG calculator I've used shows I should try to keep my 16 AWG wire to about 2 amps if I'm using about 8-feet of wire at 5V, so I plan to run a unique 16 AWG +/- from my 60-watt transformer to my LED strip with solder points at about every two feet on the LED strip. Does this not seem reasonable?

On problem that I see is that your MOSFET acts as an inverter; a LOW on the input will result in a HIGH at the output (and vice versa); that will not work with WS2812B strips. So you need an additional inversion of the signal.

It's often advised to use two gates of a 74HCT14 in series; i will achieve the same as two of your circuits in series or a simple transistor to add the second inverter. My knowledge of electronics is rusty and I can't advise on how exactly to modify your circuit.

And each one obviously with the 470 Ohm resistor :wink: Yes, you can; it's also how you control multiple motors (where the motor would be RL.

1 Like

3V3 is really pushing the capability of an IRL540.

Use two N channel MOSFETS, one driving the 2nd or just use BJTs.

What can be done in code, without additional hardware.

Thank you for the reply @sterretje. I'll look into the 74HCT14.

Indeed I do intend to invert the GPIO. ESPHome makes it quite easy to do so.

Perhaps a RFP30N06LE would be better? I did test five IRL540N with an RGBWW LED strip and an ESP32 recently and they did the job (completely separate project). Should I replace them with something rated for a lower voltage? Perhaps they will strain the ESP? I see that indeed they're intended for 4-5V.

2 (two) 2N2222 or similar will work.

I have some! So, just wire them up the same way I would an IRL540N (base in the middle, on a 2N2222)?

Edit: is this for my RGBWW strip only, or also for the two WS2812B question as well?

WS2812B

R2 could be 1k

I know. But how do you tell FastLed or Adafruit_Neopixel to do that? I have no idea if there is an easy way, either in those libraries or by coding the ESP32 (that I'm not familiar with) to always invert the signal.

That's great! So, wire up two of those on separate GPIO, invert the pins, and I'm set for two WS2812B. Just to confirm, in the schematic, the Emitters go to GND, correct?

IMO it should not be too hard to find out where the signal is written to the output pin. If you can't do it yourself, isn't it worth a feature request?

So, wire up two of those on separate GPIO, invert the pins, and I'm set for two WS2812B.

  • Why two, share the output of Q1.

Just to confirm, in the schematic, the Emitters go to GND, correct?

  • Emitters to the same GND as the ESP uses and the LED stings.

I have two cabinets that I've concealed a vl53l0x inside of (one in each cabinet) so I know when each one is open. The ESP will turn on the LEDs in the cabinet when each one is open, separately.

Are the five IRL540N I'm using with an ESP32 to drive an RGBWW LED strip in need of replacement? If so, would standard transistors, like the 2N2222, do the job? Or do I need MOSFETs? Any recommendation?

If they are working, leave them as is.

I would strongly recommend that 74hct14 solution over using individual MOSFETs.

The MOSFET circuit has the same effect, theoretically, stepping up the 3.3V signal to 5V, but in practice it may not work as well, corrupting the data and causing the strip to flicker or show undesired colours, or simply not respond at all.

The reason for this is that the data signal has a frequency of around 800KHz. The MOSFET circuit relies on the resistors passively pulling the line up to 5V, and this will not happen as fast as when the MOSFET is actively pulling the line down to 0V. The result could be a sawtooth-like waveform which could cause the ws2812 chips to mis-read or fail to read the data signal.

With a chip like 74hct14 (or one of various other similar 7400 series chips), the output is driven high actively, in addition to being driven low actively, and that keeps the data signal as a neat and clean square wave which should be correctly read by the ws2812 strip.

Thank you. I have ordered some Juried Engineering SN74HC14N.

It would be nice if I could select multiple posts as solutions.

I see a schematic that was posted in another thread. I have modified it a bit. This is my plan. I presume it would be necessary to replicate it with another 74HC14 for my second LED strip, call it GPIO19.

No, there are 6 gates in the chip you have, use the same chip.

Great. And I see from this pinout that A1 outputs to Y1. So, why does Mike's schematic in my previous post show A1 outputting to Y6 (pin 12)?

pinout
 

Also, this seems to be the source of the schematic, and in that thread it is stated by some that the 74HC14 does not support 3.3V logic...