ESP32 monitoring highpower LEDs

Good morning,

I’d like some help with a small project I’m working on. I want to use an ESP32 to do two things:

  • control dozens of HIGH POWER LEDs of this type: XLamp® XM LEDs Archives - Cree LED so that I can turn them on and off whenever I want
  • from a digital camera, activate the latter’s triggering for each LED when it’s ON.

However, I’m not entirely sure what I need to connect my LEDs to, so I imagine I’ll need an external source to power them. I’ve thought of using a BUCK-style converter for my non-isolated power supply, but it’s still all a bit hazy for me: how do I connect my ESP in all this, and what type of converter do I need? Should my LEDs be in series or parallel? Which mosfet should I choose, and do I need one for all my LEDs?
I’ve read about similar projects that used components such as a WS2811, but I don’t think it’s really necessary here. I’m a bit rusty on electronics, but I’d like your opinion.

1 Like

Hi @LeIdir

Welcome! :slight_smile:

Lot’s to cover.
But before I address all those questions maybe it’s worth digging in to how commercial addressable LED strips work. That might give us some inspiration :smiley: :zap: :bulb:

So you want to build an Addressable LED Strip…

Commercial strips like this WS2812b strip are made up of these “Intelligent LED modules”.

They are connected * in series * like this :

Then they listen for a 24bit colour codes.

Once they receive their 24bit colour code, they latch that 3 bytes and and carry the next 24bits are sent to the neighboring WS2812 LED. This way, you can send a single data_stream through the entire strip, controlling all of them at once.

This datastream is handled by a microcontroller, like your ESP32 or sometimes a chip like the WS2801 below. (and WS2811 like you mentioned).

So what about me?

The key takeaway from the above is that the commercial LEDs have a latch-carry option. I did some searches through the X LAMP XM-L3 datasheet and it doesn’t seem like these are addressable in the same way.

The answer to your questions above, in my opinion, depend on how many LEDs you want to control. Are we talking 2 dozen or 6 dozen?
I think 24-36 would be doable… an epic undertaking, but doable. :slight_smile:
If you want to go higher… I dunno maybe someone else will weigh in with a fantastic idea.

Let’s tackle those questions.


Some of the models are RGB and they receive data.
For instance, this one is colourable
If you can send data to each of them individually, then setting them to black will reduce the current towards zero. Have a look at this datasheet below. You can see that the current decreases in a near-linear relationship to the brightness (kinda, luminous flux is tied to current so it’s not that simple but you get the idea).
This will mean you don’t need to cut power to the LED to turn it “off”, just set each colour to zero. This means you won’t need dozens of Mosfets :slight_smile:

GPIO is going to be a premium. but they make boards that have lot’s of pins!
You could try multiple ESP32s that are synchronized.
That’s a solution :slight_smile: Lot’s of code, but it’d work.

Buddy system

Another option is to buddy up the LEDS. So maybe you have 36 LEDs, but only 12 data pins to go around. It’s cool, each GPIO controls THREE LEDs. That means those buddy LEDS are going to be the same colour. If they’re evenly spaced, that means your patern repeats every 12 leds in your 36 led chain. Maybe that doesn’t matter to you. Lot’s of patterns have repeats.

What if we just… build a WS2812 system.

You could build you own latch and carry system using D Flip like the 74LS74 with some AND gates (maybe the 74LS08
Each LED has a gate, which means it is it’s turn to receive the colour data. When it’s done, you bang the resets on the chain of latches, and then increment the chain of D flip flop latches (shift it). A rolling cycle of LATCH and CARRY. That would be awesome. (do it I dare you). :man_mage:

Mono-colour Leds.

Ok, but maybe the LEDs you’re using are single colour… ON or OFF.
If that’s the case, you could use the MOSFETS.


Suppose we have a row of LEDs each with a mosfet for power. So to turn on the LED, we can just bring the GATE of the MOSFET HIGH (depending on the FET).

To save pins, you might want to use something like 74HC595. This can be controlled with a few as 4 pins and allows you to control 8 BUS outs. You can dovetail them to produce as many dataouts as you need (2 dozen for example). That allows us to addressable power an arbitrary number of MOSFETs with only 4 pins. Voilà! You have addressable LEDs. This will allow you to use more affordable boards that don’t have 36 GPIOs. (although they do exist).


Alternative you could use RELAYS.

You’d need a lot of them, and again, you may run out of pins depending on your board.
In exchange, it might be cheaper and easy.

Should my LEDs be in series or parallel?

Almost certainly series but this can depend on the specs of your power supply.
Feel free to post a photo of the power supply you have in mind :slight_smile:

Good Luck. Pix :heavy_heart_exclamation:


Thanks for your answer @Pixmusix, it was really interesting.

Finally I don’t need RGB so for the choice of LEDs I’ll go for XM-L2 leds.

I need to take a photo for each lit LED (and be able to take photos for several lit LEDs) so the LEDs need to be in a high state for a certain amount of time (on the order of seconds) for the camera to trigger and take the photo.
So I don’t really have a time limit for the light to reach full brightness.

However, the LED chosen (XM-L2) has a data input like the LED model you’ve attached (XLamp® XM-L® Color Gen 2 LEDs).

So making a system based on the operation of the WS2812b sounds interesting! (It’ll also solve my problem with the number of GPIOs on my ESP32, because if I’ve understood correctly, I only need two for carry and data).

From what I’ve understood (correct me if I’ve misunderstood), when an LED on the WS2812b strip has received its 3 bytes of data, it carries the rest of the data output to the next LED, which will only LATCH the next 24 bits, and so on.

Let’s go back to your diagram:

I could then set all the LEDs to the desired state (0 or around 4500K) by sending all my data codes to the chain and then change my input data once the photo has been taken.

On the other hand, I don’t see any XML LEDs with inputs like the WS2812b’s LEDs in the datasheets, so I was wondering how the AND gate output would work with this type of helper (but where is D_IN). .

I need 8 to 24 LEDs maximum and I still have no idea how I’m going to power them…

Thanks again!


Clarifying how WS2812b works … as best as I understand it.

I think it works more like Last In Serves First.
Let’s find the simplest case which is just 2 WS2812b LEDs in a row.
If I want the first RED and the second PURPLE I need to send
20 A0 F0 00 FF 12 ; GRB (little endian)
The first LED receives three bytes for purple.
Then the first LED receives a second set of three bytes for red. It’s buffer overflows, which pushes the first three bytes for purple out to the second LED.
That’s how I understand it from the diagram.

I’m sure there is a way to replicate the WS2812b format.
HOWEVER! Adafruit had a restriction you DON’T have.
They had to make their LEDs infinitely scalable. They might have chains of 350 LEDs or more.

You know ahead of time how many you want in your chain, so you might be able to afford simpler designs.

Clarifying my idea.

What I’m suggesting in my diagram above is to combine a SHIFT REGISTER with a string of GATEs.

  1. Each LED is assigned a Gate.
  2. A single data pin sends your bytes to ALL the leds in series with their Gate.
  3. Each Gate is paired with a Latch that opens and closes the gate. All latches start LOW.
  4. The latches are strung together into a shift register.
  5. Latch in a HIGH to the first bit of the register.
  6. This opens the first GATE and only the first gate.
  7. When you punch data out the data GPIO it will only pass through to the first LED with an open gate.
  8. Shift the HIGH bit from the first latch to the second latch.
  9. First gate is now closed, second gate is now open.
  10. Punch out the data; only the second led has an open gate and receives data.
  11. Repeat step 6-8 until you reach the end of your chain of latches.
  12. When you reach the end go back to step 3.

I’ve used AND gates in my thought experiment, but you could use transistors.
I also recommended D style latches at first, but thinking on it I guess you could just use a shift register instead. It’s more code, but they make libraries that handle it all for you.

Shift out logic is actually built into Arduino IDE if you can believe that!
I wrote this header file for another project I’m working on. Feel free to steal it.

There might be a BETTER idea.

I came up with this thought in 2 minutes lying in bed sick. Chances are good that my idea is NOT optimal. :stuck_out_tongue:
Think about some other ideas that might suit you. :slight_smile:
For example, maybe you give each LED a tri-state buffer. That way you only have to punch out data when you want to change the LED (rather than every time like my first idea). The buffer can remember you data for you.

Do they make 16+bit tristate buffers? I dunno :man_shrugging:
Anyway maybe this is a better plan :thinking:
Guess it is personal preference.


Seems like you don’t need all those Relays, but you might a BIG Boy power supply.
I’m sorry but I don’t have much experience with High powered LEDs but maybe someone else will chime in with a power recommendation.

Shoot us some photos when you’re done!!
Pix :heavy_heart_exclamation:


I’m coming back to you Pix, having studied the system a little more I realize that the leds don’t have any data input but it was only a code to specify the type of led you wanted when you bought it.
I need to think of a new way of addressing these leds, so I’m going back to one of my original ideas, which is to use the WS2811 RGB Driver Chip :

This chip receives power-on or power-off commands from the Arduino and activates a MOSFET that switches the high-power LED. I only intend to use one output from this chip, but it can easily control a high-power RGB LED for multispectral RTI.
his chip is the one inside ws2812b leds strip and allow an long chain of leds to be addressed individually.
So, as expected in the circuit we thought of earlier, I’m going to separate the power supply and control of my leds.
I’ve found a circuit diagram that would allow me to do what I’d like, but I don’t know how to understand it or read it like a normal diagram.


If anyone could enlighten me as to how this one works, bearing in mind that typical schematics for using the component are as follows:

1 Like

Oh as in the bin number wasn’t a binary but a literal category?
Lol how confusing.

I’ve never personally used a WS2811. I think I would contact the manufacturers and ask for advice.
Let me think on this. Is RGB important to you?

The RGB isn’t important, on the contrary, I don’t use it.

1 Like

What’s wrong with my thoughts on mono-colour leds, saving pins, and relays? :slight_smile:

1 Like

So, I’d kind of forgotten about this proposal by you, I wanted to take up the challenge of recreating a kind of strip-like system.
However, although this approach may be cheaper in terms of components than using individually addressable LEDs (with the WS2811), especially if you need a large number of LEDs. I have a hunch that I’ll save more time using this component in terms of wiring and coding time by using a library like fastLED, maybe I’m wrong and correct me, besides I don’t really understand how relays will be important here, what are they going to be used for in the setup you have in mind.
Thanks a lot!



That’s awesome. Love that attitude :slight_smile:

Uh… yeah maybe, not sure. :man_shrugging:
If you draw a circuit you could calculate it.
If money is a concern, it’s worth the R&D investment.

Gotta trust your gut on these things. Everyone is different.
I think you’ll learn a lot.

They’re just a potential alternative to the MOSFET. :slight_smile:

I’m not entirely sure how the WS2811 is going to interface with the specific LED you’re choosing.
Excited to see what you come up with :slight_smile:

Pix :heavy_heart_exclamation:

1 Like

Hi @LeIdir,

Just an idea I had for controlling large number of LED’s using a limited number of control pins.
By using wither relays or MOSFET’s in a matrix array you could potentially cut down on the number control pins needed.
You could potentially get 25 LED’s controlled using control 10 pins. 5 positive lines and 5 negative lines. Similar to this example:


I’m also curious, What is this project being used for? I have a few idea for what I could use a system like this for but I’m very interested to hear your use for this system.

1 Like

Hi @Aaron,

I’m trying to build an RTI (reflectance transformation imaging) system, without using a dome as is often the case.

Thx for your exemple I’ll take a look on it !


Hi All

The word “potential” could be important here.
Although relays are pretty useful insofar they can be isolated and be used on high side or low side switching everyone is aware aren’t they that they are relatively slow. About the best you will do with the “normal” type is about 10mS operate and 10mS release times. Reed types might be a bit quicker but might still be slow for some applications. If you go along with the practise of using 5V devices at 3.3V this could be much worse.
Cheers Bob