5v Arduino Control 12v LEDs


Hello!

I'm having trouble understanding how to get a 5v Arduino to control a 12v LED string of lights.

I've attached a diagram of my current set up, 12v power to buck converter to 5v to power the Arduino, 12v directly to LEDs w/ 1000uF capacitor, Arduino pin to LED string data w/ 470 ohm resistor.

From some digging I saw that I need a mosfet to help get the signal to the LEDs, so I got a mosfet and connected gate to Arduino pin, source to ground (12v-) and drain to the LED data input. This led to the Arduino getting caught in a reset cycle, I think I made a ground loop along the way. Could anyone shine some light on how the mosfet should be connected to this circuit to control the LEDs? Is the mosfet necessary or should I be using something else?

Addressable LEDs don't need a MOSFET driver because each LED has a driver built-in. Your schematic looks OK.

Except... Isn't an ESP32 a 3.3V device? In that case, you need a 3.3V power supply for the ESP32 plus a 5V supply and a level-shifter to get 5V for the data.

Ahh, I see. Okay so nix the mosfet because the LEDs already have that covered.

You're right, the esp32 is 3.3V. I've been feeding it 5v to the vcc pin and I haven't had any issues (no issues as in the Arduino boots up and I'm able to connect to it over BLE, sending and receiving data but of course the LEDs are not turning on). Would adjusting the buck convertor to 3.3v down from 5v solve this issue? And then you're saying I'd need to use a level shifter to get the data pin up to 5v to control the LEDs?

Or are you saying even though the LEDs are 12v I should just use a 5v psu to run the whole thing?

I don't know anything about the ESP32...

The WS2811 needs 12V power and 5V data. I believe the LEDs are addressed in groups of 3 rather than being individually addressed like 5V LED strips, but you'd have to check the datasheet for the particular LED strip.

I have no idea if the "regular" WS2811 or 2812 libraries work on the ESP32.

Understood, so then when the ws2811 is powered by 12v the data must be 5v so I need to level shift the esp32 data to 5v and connect that to ws2811 data. That's what I originally thought the mosfet did but I was not correct in that assumption. Do you happen to have a recommendation for a level shifting module?

In regards to the level shifter, it's beginning to sound like I'll have 3 different voltage levels in the project now. 3.3v for the esp32, 5v for the level shifter, and 12v for the LEDs. So I'll need 2 buck convertors to shift 12v to 3.3v and 12v to 5v if I want to power this all from a single 12v psu?

This ws2811 12v is individually addressed and the 'regular' libraries do work on the esp32.

Thank you so much for the guidance you've given, it's cleared up a lot of confusion on my end so far!

That would be step 1. Better to power the ESP32 through an efficient buck converter than through it's own linear regulator, but the real issue is that the ESP32 uses 3.3v logic levels, and WS2811 requires 5v logic levels. Either a level shifter or a 5v powered TTL chip (they respond just fine to 3.3v logic) can be used to achieve 5v logic levels.

Yep.

well a linear regulator would do for the level shifter, they require so little power that just a TO-92 package of a 78L05 will work just fine, or you could leave the ESP32 powered though it's VIN which takes 5v and uses it's onboard regulator to drop to 3.3v. This is such a small step that not much efficiency is lost.

That would surprise me. Ok i haven't tested it myself. But a bit-banged format should pretty much always work, though may not be compatible with wifi.
Neopixelbus compiles and does support ESP32, but i am not sure of DMA mode, but UART mode should work though and should be compatible with wifi)

The level shifter for driving the WS2811 strips with 5 V data is a 74HCT14 though a 74HC04 or even a 74HC14 will generally work. It has six inverters, you need to feed the output of one inverter into the input of a second one to invert twice and get the correct signal out. Connect the inputs (only) of the other inverters to ground unless you need them to buffer other things (such as other strips).

The 1 millifarad capacitor (often specified as 1000 µF) connected directly across the LED strip sounds fine. Note that the ground and data lines must travel together as a pair from one part to another and the 330 (or 470) Ohm resistor should also be connected at the actual data input at the strip itself. You should also keep the supply lines together with their corresponding ground.

Frankly, your present power supply sounds just fine, providing adequate 5 V for the ESP32 and the 74HCT14.