I am currently exploring a project that allows me to control high-power RGB LEDs using PWM from an ESP32 microcontroller. In this way, I plan to create a simple LED panel for canopy illumination that can provide multispectral light outputs using PWM from the MCU.

For starters, I tried testing one color strip by having three of these high power LEDs in series powered using a XL4015 buck converter in current control with a supply of 12 V and a constant 650 mA from the buck (I am using a 12 V, 20 A power supply in this case).

For the PWM, I came across AOD4184A power N-MOSFET modules that can easily interface with 3.3-5 V logic to drive about 40 V load. I chose this since I wanted to deviate from customizing my own drivers for now and interface the high-power LEDs using off-the-shelf modules.

I also added a PC817C optocoupler for isolating the main circuit from the MCU. In this case, I am planning to multiply this configuration by having them in parallel with each strip having its own buck converter, MOSFET, and optocoupler module to somehow be able to build an LED panel that I can easily interface with the ESP32 by probably having the modules on a prototype PCB to perhaps creating multiple channels to address each RGB color. The current circuit design I have for now is shown below.

![enter image description here

The RGB LEDs have forward voltage ranges of 2.2-2.6 V for the red and 3.2-3.6 V for both green and blue LEDs that can be driven at around 600-700 mA forward current. I am also planning to extend the series connection to six in series and having two of them in parallel using one buck converter using up about 3.9 A from the buck since it can handle 5 A load current based on the datasheet.

 650 mA x 3 (RGB) x 2 (parallel) = 3.9 A

This would be the case once I get my hands on the 24 V supply I've ordered although for now I am just using the 12 V I have and scale afterwards.

At this point, I am quite lost in appropriately completing the circuit. My questions are as follows:

1.) Is the present circuit for driving an individual series of LEDs good enough? I looked into papers designing their own LED drivers and with my current skills, I could only adapt to having off-the-shelf components and a basic-to-novice electronics design with prototype PCBs.

3.) As mentioned also earlier, one RGB LED strip would mean three individual strips in parallel, hence, making up triple the mentioned forward current. Using 650 mA just for starters, would having the three wirings in parallel ensure stability since I am individually modulating them with the MOSFET module? I've read some articles and lectures on using a transistor to answer this but I am still lost with this concept and I am not sure how I can possibly integrate that along with the other modules.

I hope I am clear with my intended goal here and I am still a bit novice in such components but I do have experience in tinkering with basic circuit designs for quite a while now, mostly resistor based networks, low-powered switching circuits, and logic-level interfacing with sensors and actuators using microcontrollers. I am quite nervous about dealing with high-power components especially on safety issues and possible problems I might encounter with my design since I've mostly worked around low-level applications.

Any further suggestions or comments would be very much appreciated along with the answers to the problems I am still currently researching and exploring.

  • \$\begingroup\$ What is pin 4 of the optocoupler connected to? \$\endgroup\$ Dec 28, 2021 at 12:58
  • \$\begingroup\$ That would be the common pin of the transistor I believe. \$\endgroup\$
    – Guorishix
    Dec 28, 2021 at 13:03
  • \$\begingroup\$ ...and you plan to connect that to ground, +5, +12 or leave unconnected (as shown). \$\endgroup\$ Dec 28, 2021 at 13:38
  • \$\begingroup\$ Sorry I wasn't clear. As mentioned on question 2, I initially planned using series resistor and connect it directly from 12V, but obviously this wouldn't be proper and I am currently trying to look for other ways I can have a connection there. The common-emitter current for the coupler has max 50mA based on datasheet and I am not sure how to supply such low current coming from my supply. \$\endgroup\$
    – Guorishix
    Dec 28, 2021 at 13:57
  • \$\begingroup\$ Why would it not be ‘proper’? The current is determined predominantly by R4 and the led. Use Ohms law to calculate this. \$\endgroup\$
    – Kartman
    Dec 28, 2021 at 14:17

1 Answer 1


Problems: XL4015 requires an output cap, and if you wire it in current source mode, the current sense resistor is on the low side.

If you wire it in current source mode, when your MOSFET disconnects the load, it will still try to generate current. It will then charge up its output capacitor to the maximum allowed voltage. When the PWM MOSFET turns back on, the LEDs will receive the capacitor voltage, which will create a high current spike. Then, after a while, as the capacitor discharges, XL4015 will return to current control mode. This may or may not be damaging, it depends on capacitor value, but it sure will increase losses.

If your LEDs were all the same color, you could use the usual trick of adjusting the 12V to "about 3 LEDs worth of Vf plus one or two volts" and just PWM with MOSFETs and resistors. But your LEDs are RGB, they will have very different voltages for each color, so doing that would waste a lot of power in the resistors.

I'd recommend using one buck LED driver chip per channel. These have two features that make them more practical than XL4015: direct current sensing with a low value resistor for low losses, and a PWM or analog dimming input that you can use directly.

  • \$\begingroup\$ Thank you for your feedback. Upon recommendation, I came across with these 1W 350mA LED driver modules using XL400E1 chips with the module providing PWM dimming input. I'll probably try these ones and see how I can make it work with my prototype. \$\endgroup\$
    – Guorishix
    Jan 3, 2022 at 9:15
  • 1
    \$\begingroup\$ That should work much better. There's no XL400E1 on xlsemi website though. I had a quick look, if it's XL4001 it'll be pretty inefficient due to bipolar switch and high voltage drop on sense resistor. If it's XL3001 then that would be a good choice. You can change the current from 350mA to higher by changing the sense resistor, if the inductor handles it. \$\endgroup\$
    – bobflux
    Jan 3, 2022 at 14:40
  • 1
    \$\begingroup\$ Fount it. It's XL4001. Would recommend the second board on this link instead, the one without the SO-8. It'll be more efficient. Consider adding a small capacitor like 100nF ceramic between LED- and GND on back of board for EMI suppression. Schematics: datasheetcafe.com/pt4115-datasheet-led-driver \$\endgroup\$
    – bobflux
    Jan 3, 2022 at 14:50

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.