Integrating a 5V dual white led strip

Hi all,
to the birth of our son we got a nice little night light with an acrylic glass. Unfortunately, the switch really sucks. It’s one of this kind

You can dim and change the color of the light (warm white, cold white or neutral white) and the brightness. However, to turn it on, we always have to press the power button. It does not remember the last state nor dim level, or auto turn-on when power is connected. Otherwise, I would just use a wifi plug to switch it with my favorite setting. Now, since that is not working and we always have to use this switch, I think I’ll make this my first ESPHome project.

I could not find the LED strip in this light anywhere on aliexpress, so here’s a photo

I did some research on ESPHome and if I interpret it correctly, it should be a cwww type light, right? What kind of microcontroller would I best use for controlling this strip? It’s short with only 10 led’s (5 of each kind). Power consumption with the original switch is 5V and 0.13A for warm white and 0.14A for neutral or cold white at maximum brightness. From that observation I reckon neutral white is just 50% of warm and cold white, i.e. constant_brightness should be set to true in cwww configuration. No idea about the color temperatures I would have to set though, so if anyone knows these strips, please let me know :slight_smile:

It’s important for me to plan this project thoroughly! Since it was a gift, I will definitely not get permission from my wife to change the switch, so I’ll have to do it when she is out of the house and I better not break it :smiley: If it has an upgrade afterwards, I’m confident she’ll be happy though.

Thanks for your help in advance.

Athom makes a lot of LED controllers with Tasmota already installed, or easily flashed with ESPHome. Try asking your question on their user forum

And report back here because I have a similar dumb light that I would like to control from Home Assistant.
.

Something you have to change, either switch or …

Anyway, from photo it looks just common anode led strip. Shelly RGBW would be easy pick. Or build some transistor driver with Esp dev board.

For “dumb” led’s like those, i use and recommend using mosfet modules like these here at Amazon

Ive used these for years and they control my kitchen cabinet upper/lower led’s, water frature led’s, and all my landscape lighting.

You can use any esp board that you have on hand and if you have none on hand, then id buy a plain esp33 D1 mini since you only need 2 gpio pins for the light so, doesnt make a lot of sense to buy a full size development board thats twice as big, just for 2 gpios…

Heres a 3 pack of Esp32’s

If you need ones with the pins already soldered on, you can find them, you just gotta look around at different listings but, they commonly come unsoldered like that.

Ahh, thanks for the hint about the transistors! I thought the GPIOs of the ESP32 can directly switch the 5V. Just found out they are only for 3V3.

I agree, I don’t need a large dev board for my project. However, the larger ones are typically narrower than the D1 mini boards. That would make it easier for me to hide the thing in the base of the lamp which is long but narrow. Well, I will have to see if I can hide this stuff anyways, as with the transistors, I will probably need to add some small stripboard, too.

About the transistors: Now I remember, I built something similar ~5 years ago for PWM-switching an LED backlight of a small character display for a raspi. There, I used a BC337-25 transistor of which I still have some lying around. They should be fine here, too, right? And quite a bit smaller than the MOSFETs you recommended above.

And lastly a newbie question, since I’m new to ESPHome: I can also attach multiple things to a single ESP32, right? To be precise: I also want to attach a push button to be able to switch the lamp on/off physically, not only from the app.

EDIT: To make this whole thing a bit smaller, an ESP32-C3 mini should work for my use case, too, right? I found these boards which are significantly smaller than the ESP32 boards

I use them a lot for the same reason. For the current you described, they are very ok. Just make sure to use low enough base resistor to saturate it completely. 470R or 1K for example would be good.
Yes you can attach “multiple things” on esphome board. Just make sure you don’t draw too much current from it. You could NOT for example draw the ledstrip current from pins even if the voltage was correct.
C3 mini is ok if you don’t need BLE.

Sounds good. I think, I’ll get some of these ESP32 C3 mini boards to try this out. Just a question that came up when I was reading through the data sheets. Is it okay to power these boards using 5V USB? I always read they need a 3V3 power supply. Is the USB only for programming, but they need to run with 3V3 or can I also power them with 5V through USB at runtime?

If your board has USB connector, 5V USB is all you need.
The board has built in 3.3V voltage regulator that converts 5V to 3.3V to power the Esp-chip.

1 Like

Thanks. I just ordered what I need and will get at it when everything arrives :slight_smile:
Coming back to one of the start questions: Cold White + Warm White Light — ESPHome is the right component to use here? the output_components would then control the transistors

For the most part but, some dev boards can actually use 5v gpio inputs and it sometimes depends on how your using the 5v. If you need a 5v logic High to turn something on, thats a problem because it only outputs 3.3v max. If your using inverted logic and to turn something on requires sinking 5v. thats a different story than pulling an extra 1.7v out of thin are to add to a 3.3v gpio.

Im not familiar with that specific transistor but, you just have to type in Google and then add “data sheet” and thats where you will find its operation parameters and min/max specs. Transistors and mosfets are basically the same thing exactly mosfets are designed for larger loads whereas a transistor is for more logic level type stuff.

Dude… you really have no limits to how many things you can add to one so, knock yourself out and go crazy!

One piece of advice ill give you is to be sure you’re consulting the pinout sheet for your specific board so that you can avoid making easily available mistakes by using gpios tbat have secondary functions like ones tied to internal flash or have internal pull-ups or pull-downs activated by default, etc. Although you can still use most of those gpio pins, they do require being used in specific ways wheres “free” gpios do not have those limitations so, use free gpios first and then if you need more, people can help you understand the differences or you can just get yourself some gpio expander modules like here is a 16 port expander that gives you 16 more components to hook up if you need them.

Just a quick update. I received my ESP32-C3 mini boards and got the light working! In using the cwww component with two ledc output. The two gpio pins control transistors for the led strip. Works fine and is really fun to play with.

However, there’s one small thing that bugs me a little. If I set the brightness to <=3% the LEDs are not lighting up at all. I would like to use the whole range of 0-100% especially at night. What could be the issue here? PWM frequency?

it’s completely normal. Actually 3% is surprising low.

My girlfriend says I’ve got about 3% of what she needs and its adequate so, im gonna have to disagree with your “surprisingly low” opinion. Its how you use that 3% and not so much what the actual number is.

Lucky you! Mine left me at around 4.2%. I’m sure I was spoiling her initially with too high values.

Did you try to start with higher and then go gradually lower, there might be small improvement.

ya… you’d think they want spoiled but, in reality they really want that 3% swung around like a cowboy’s lasso and not too rough but, a solid swing right across the face is what they like much more than being spoiled… At least that’s what I think if i imagine trading places with them… and No! that doesn’t make me g@iiiiy

For most led’s that’s very normal and many of them will specify the low value at which the light will just turn off when it’s dimmed below that point. I have to agree with the person that said you were lucky to go as low as 3% because many led’s I use, they will cut off if dim them below 10%-13% and some do something similar when you get near 100% for example you may see a noticeable increase from 90-95% but in reality 95% is equal to 100% and when you actually make it 100% there’s no visable difference.

You are using the whole range it’s capable of, that’s not the problem. The problem is most lights don’t have that high of a step level and they get pretty close and some do better than others. It’s not a configuration or frequency problem that needs fixed either. It’s just how led’s work and you’re getting the full range that led allows. It just wasn’t what you thought it would be, where you could change it 1% at a time and it woud turn on at 1% brightness level… Once you ask yourself, “what do I need to use a 1% brightness for anyways?” and then come to the same conclusion as everybody else, then it suddenly isn’t quite as big of a deal as you initially thought it was!

Thanks for that clarification!

Is there a way to somehow change the scale such that it starts at 4% and anything less is off? I saw the min_power value in the output config, but don’t really understand how to use it. Would that be it?

Edit: Just tried it out and set

    min_power: 0.04
    zero_means_zero: True

but that way, 4% is much brighter than 4% without these lines :confused:

You can always find the answers with the Search box here but, sometimes it takes a little work going through older posts. Heres one i found that may help.

You could adjust it with template output between light component and ledc output. It’s just cosmetic though, it doesn’t give you any “lower dimming”.
Something like this (not tested):

  - platform: template
    id: adjustment
    type: float
    write_action:
      - if:
          condition:
            lambda: return state > 0;
          then: 
            - output.set_level:
                id: led_output
                level: !lambda |-
                  return 0.03 + 0.97 * state;
          else: 
            - output.set_level:
                id: led_output
                level: 0