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.

2 Likes

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:

2 Likes

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!

2 Likes

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:

3 Likes

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.

image

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!

Idir

2 Likes

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:

image

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.

2 Likes

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 !

4 Likes

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

4 Likes

Hi @Pixmusix,

So finally, I opted for the circuit that used a shift register to control mosfets, because I have not yet received the WS2811.

So, here’s the simplest possible simulation I made to understand how it works (made on falstad).
image

Now, as you know, I need more than the 5V of the simulation to power these big babies.

Each led requires around 3V and 3A if I use them to their full potential :

So, for the external power supply I’ll need a buck/boost as I thought if I a 12V DC 3A Plugpack.

I looked at the guide already on the site : How to Drive High Power LEDs – 3W Aluminum Backed Star LEDs - Tutorial Australia.

Having said that, I need to know what kind of led driver I’m going to use, knowing that when I have more than 2 leds lit, they’ll be in parallel, so I’ll need the output to supply: (number of leds lit)*3A.

So, I’d like to have a 48A output led driver, but I guess I can dream or make the biggest fire in my neighborhood. But I don’t mind limiting the number of ON LEDs to 8. The only problem I see is that each LED won’t be lit with the same intensity since they’re in parallel!

But I can’t see how to fix this problem.

2 Likes

Why do you believe this is going to happen? The only time I have observed this happening is with cheap LEDs being driven at low power, and neither of those conditions will apply in your case.

Note that your circuit is missing the current-limiting resistor in the supply for each LED.

4 Likes

Hi Leldir

Take note of that. Using the circuit you have drawn you probably Will have a fire.
This resistor is required. The thing you have to make sure of is that the supply can provide the TOTAL current required. That is @ 3A each and a possibility of 48LEDs equals 144A or @ 12V 1728W, good luck with that.

A solution to the absolute power required would be to do a rethink and restrict the maximum number of LEDs on at any one time.

As for the current limiting resistor (required but missing in your circuit) yo indicate the drop across each LED to be 3V. 12V - 3V = 9V, 9V @ 3A is 3Ω @ 27W. That will be physically quite a large resistor as you will have to go on the high side as far as Watts is concerned and the next available above 27W would probably be 50W. The whole thing would be like an oven with all the LEDs on. 27W times 48LEDs = 1296W, about half of a 3 bar radiator.

That would only drive 1 LED.

I really believe you should rethink this whole project and come up with a realistic solution. Like how many LEDs do I need on at one time and do I really need 3A. Bearing in mind there might not be much NOTICABLE difference in brightness between 3A and say 1.5A (or even 1A). Perception tends to appear non linear at high and low brightness levels. Even if you MEASURE a linear progression the human eye does not see that as linear.
Cheers Bob
Just had a look at your original post.
Exactly which model LED have you got in mind, that link covers lots. I notice that one of them is rated 12V @ 1A. Would this be a better choice?? I don’t know. The chart says 1A but a quick look through the data sheet suggests something like 380mA (or something like that). Maybe you should have another look and decide what you really want.

2 Likes

Hi !

I’ve revised some of the project requirements, so I’ll need 16 LEDs. But I’ve abandoned the idea of having to light them all at once, and I’d like to be able to light more than one at a time, as well as being able to light them one by one.

That’s why I think turning on LED 4 might be a good compromise!

Well, that doesn’t totally solve the problem, so I’ve even decided to change leds (goodbye to my greedy XML2 …) and present you with two new challengers:

ILS ILH-F501-WMWH-SC201-WIR200., OSRAM Duris S8 PowerStar LED Array, 1 White LED (5000K)

Link : ILS ILH-F501-WMWH-SC201-WIR200

ILS ILH-S601-WH70-SC221-WIR200., OSCONIQ S3030 Circular LED Array, 1 White LED (5000K)I’ll probably choose this one)

Link : ILS ILH-S601-WH70-SC221-WIR200

As far as the resistors are concerned, as I said, this was a set-up just so I could understand how the shift register worked and how I controlled my leds (if you go back a little you’ll see that this was one of the discussions I had about the project).

I plan to use a Led driver: this is a constant current regulator (they are easy to find and are often just called LED drivers). These devices can often step an input voltage up or down to whatever the LED needs, but most importantly they will lower their output in order to not go above a current limit you specify. This means when you switch it on the driver will regulate the LED at constant voltage and then when it heats up and draws more and more current, once it reaches a threshold (lets say 0.7A with our new leds) it will lower the voltage in order to maintain a maximum of 0.7A which is much better for the health of the LED.

But here I’m not totally solving my problem, let’s say I want to turn on one led I’ll have to have a configuration, but if I want to turn on 4 I’ll have to change this configuration manually, which is a shame given my goal of automating my system!

I have a very poor knowledge of power electronics, so I’m sorry if I’m saying atrocious things @Jeff105671 .

1 Like

Hi LeIdir

Yours not mine

Down. Not up. These can be likened to a variable resistor that changes to maintain a constant current with load changes. So the input voltage has to always be above what is required.

In reality each LED would have to have its own driver. If say you had a 700mA driver and 1 LED. All good and that LED would use the 700mA. Now switch another LED which would be in parallel with the first one. Then the driver would still provide 700mA but now 350mA each LED and so on. If you wanted 700mA for each of these LEDs you would have to have another driver or somehow change the one to 1400mA and so it goes on. I don’t know exactly you would do that as I don’t know much about the exact circuitry but I do know the principle and have built simple constant current sources in the past. Not too difficult.
Cheers Bob

2 Likes

That’s why a constant current driver is not appropriate for this configuration - you would need a driver for each LED. But if you have a constant voltage supply then you can use a resistor for each LED, which is much simpler and cheaper. A supply voltage that is just a little above the voltage drop of the LED means you will use a low value resistor and there is not much extra dissipation to deal with (the LED will produce much more heat than the resistor). It is common to run a parallel LED arrangement with resistors as low as 1 Ohm, but 4 or 5 Ohms might be a better choice for a little extra heat but better protection against thermal runaway if the voltage supply is not 100% stable.

4 Likes

Desktop PC Power Supplies can output heaps of current @ 3V3 & 5V!!!
“The brown wire (sometimes also orange but thinner) is the Sense terminal , it’s usually connected with the 3.3V or orange wires, and it is responsible for making sure that these outputs always have 3.3V. If the voltage is different than that, it’ll probably shut down the PSU.”, https://www.instructables.com/Laboratory-ATX-Power-Supply-Unit/s

I think you can modify the rails slightly with the “sense” wire. Cut the brown wire where it joins the orange wire, wire a pot accross 5V & 0V and feed slightly more than 3V3 to the sense wire. Then you might be able to lower the 3V3 rail to 3.0V and drive the 3V XLamp® XM LEDs?

You could even run the 6V XLamp® XM LEDs from the 5V rail! No current limiting resistors!
Feeding slightly less than 3V3 to the sense weire, you might be able to raise the 5V rail closer to 6V :wink:

On easy way to control the LEDs would be to use

“If you are using the Servo PWM Pi for low current applications, below 300mA, you can power the Servo PWM Pi through the 5V pins on the microcontroller port by bridging the “PWR Link” pads with a blob of solder.”

  • Output Current On Each Pin: 25 mA
  • Total Maximum Current: 400 mA

So, you’ll need to use FETs between the LEDs and pca9685!

FDPF16N50T work well for me @ 3V3, but will definately work for you @ 5V.
They might be overkill, but so what!

1 Like