Thomas shares makes

2019-01-01

EspHome LED Lighting

controller
controller

I hand-built several LED strip controllers with Wemos D1 mini boards and prototyping board. We used them to light our living room.

Electronics

I used pieces of perforated circuit board to host a Wemos D1 mini and a Wemos D1 mini switching power supply. I included a power NFET to drive the white LEDs using PWM, and a signal NFET to levelshift the 3v3 I/O level to 5V which the WS2811 recognises.

controller

Each light fixture has two natural white strips and a WS2811-based strip that has three RGB leds per WS2811 chip.

controller

Living room

Our previous living room used to have 4 LED strips:

  • on top of a large mirror
  • above two windows
  • on top of a cabinet.
controller

Software

Each of the controllers has it's own yaml file:

substitutions:
  hostname: living_spiegel
  numleds: "10"
<<: !include esp_ledstrip.yaml

This way, the common parts are easily reused:

esphome:
  name: ${hostname}
  platform: ESP8266
  board: nodemcuv2
  on_boot:
    priority: -10
    then:
      - light.turn_on:
          id: ${hostname}_wit
          brightness: 100%

wifi:
  ssid: "kingdomkong"
  password: !secret wlan
  domain: ".thouters.be"

# Enable logging
logger:

# Enable Home Assistant API
api:
  password: !secret api

ota:
  password: !secret ota

light:
  - id: ${hostname}_kleuren
    type: BRG
    platform: neopixelbus
    variant: WS2812
    method: BIT_BANG
    pin: GPIO13
    num_leds: ${numleds}
  - id: ${hostname}_wit
    platform: monochromatic
    output: white_led_strip

output:
  - platform: esp8266_pwm
    id: white_led_strip
    pin: GPIO4

There also is a secrets file, which isn't added to version control:

ssid: "myssid"
wlan: "mypsk"
api: "myapikey"
ota: "myotakey"
domain: ".myself.tld"

Christmas tree

controller

Christmas tree, with WS2811 led strip

I fitted our Christmas tree with a 'neopixel' WS2812 RGB 12mm LED daisy chain. It's also controlled with a LOLIN D1 Mini running esphome.

controller

The 12mm LED chain used

The controller's main job is to set the LED's to a colorful pattern at startup. This is achieved with an on_boot automation on the esp itself:

esphome:
  name: ${hostname}
  platform: ESP8266
  board: nodemcuv2
  on_boot:
    priority: -10
    then:
      - light.turn_on:
          id: ${hostname}_kleuren
          brightness: 100%
          effect: eighties

This 'eighties' color pattern is generated with a piece of inline C++ code, a so-called lambda function. The function will repeat a pattern in a vector that expects a color for each LED.

I also added an orange-yellow color that I used with a long LED chain on the garden shed.

light:
  - name: ${hostname}_kleuren
    id: ${hostname}_kleuren
    type: RGB
    platform: neopixelbus
    variant: WS2812
    method: BIT_BANG
    pin: D7
    num_leds: ${numleds}
    effects:
      - addressable_lambda:
          name: "eighties"
          update_interval: 10s
          lambda: |-
            for (int i = it.size() - 1; i > 0; i--) {
              switch(i%5)
              {
                case 0: it[i] = ESPColor (0xff, 0x00, 0x00); break; // red
                case 1: it[i] = ESPColor (0xff, 0xd0, 0x00); break; // yellow?
                case 2: it[i] = ESPColor (0x00, 0x00, 0xff); break; // blue
                case 3: it[i] = ESPColor (0x00, 0xff, 0x00); break; // green
                case 4: it[i] = ESPColor (0xff, 0xff, 0xdf); break; // white
                default: it[i] = ESPColor (0x80, 0x80, 0x80); break;
              }
            }
      - addressable_lambda:
          name: "amber"
          update_interval: 10s
          lambda: |-
            for (int i = it.size() - 1; i > 0; i--) {
                it[i] = ESPColor (0xff, 0xa8, 0x47);
            }

Liked something? Worked on something similar? Let me know what you think on Mastodon!
You can direct-message me, or mention me @thouters@hsnl.social
Follow me on Mastodon!