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.

RGB LEDs.

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.

SAVING PINS

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).

RELAYS

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:

1 Like

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:
image

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!

1 Like

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.

Power.

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:

2 Likes