ESPHome ESP32 Led Strip Controller

Hi, I just found this question and that’s exactly what I built after searching for a long while. Hope this helps @radinski or anyone else considering this.
In my case, I bought a ready made kit, but the controller and power supply were so under-dimensioned that they almost started a fire. Then I decided to build.

The components I used:
LED: RGB, non-addressable, 60 LEDs/m, 4W/m, SMD5050, 12V, waterproof
ESP32 WROOM
4-channel IRF540 MOSFET board
ATX computer power supply (12V power supply capable of powering all the LEDs you intend to use, I just happen to have this)

The connection is rather simple (diagram below)

The code in ESPHome:

# LedStrips - output pins
output:
  - platform: ledc
    pin: GPIO21
    id: gpio_21
    frequency: 100 Hz
    max_power: 100%
  - platform: ledc
    pin: GPIO19
    id: gpio_19
    frequency: 100 Hz
    max_power: 100%
  - platform: ledc
    pin: GPIO18
    id: gpio_18
    frequency: 100 Hz
    max_power: 100%

# Usage of ledc in lights
light:
  - platform: rgb
    red: gpio_4
    green: gpio_2
    blue: gpio_16
    name: "RGB strip porta"
    id: strip_porta
    effects:
      # Use default parameters:
      - random:
      # Customize parameters
      - random:
          name: "Slow Random Effect"
          transition_length: 30s
          update_interval: 30s
      - random:
          name: "Fast Random Effect"
          transition_length: 4s
          update_interval: 5s
      - strobe:
      - strobe:
          name: Strobe Effect With Custom Values
          colors:
            - state: True
              brightness: 100%
              red: 100%
              green: 90%
              blue: 0%
              duration: 500ms
            - state: False
              duration: 250ms
            - state: True
              brightness: 100%
              red: 0%
              green: 100%
              blue: 0%
              duration: 500ms
      - flicker:
      - flicker:
          name: Flicker Effect With Custom Values
          alpha: 95%
          intensity: 1.5%
      - lambda:
          name: My Custom Effect
          update_interval: 1s
          lambda: |-
            static int state = 0;
            auto call = id(strip_porta).turn_on();
            // Transtion of 1000ms = 1s
            call.set_transition_length(1000);
            if (state == 0) {
              call.set_rgb(1.0, 1.0, 1.0);
            } else if (state == 1) {
              call.set_rgb(1.0, 0.0, 1.0);
            } else if (state == 2) {
              call.set_rgb(0.0, 0.0, 1.0);
            } else {
              call.set_rgb(1.0, 0.0, 0.0);
            }
            call.perform();
            state += 1;
            if (state == 4)
              state = 0;

This has been working for over a year now (actually, a bit more complex project, with four strips, but this here started it all). Hope it helps

7 Likes