Creating a Smart LED Dimmer

Creating a Smart LED Dimmer

April 28, 2022

Table of Contents


I frequently see cheap battery-operated monochrome string lights on clearance at stores locally such as Walmart. I wanted to be able to take advantage of these deals, but most of the lighting equipment that I own is "smart" and tied into the Home Assistant home automation system. I wanted to be able to bring these lights into my home automation system to control them more easily and tie them into my automations. There is the QuinLED controller, but it was a little overkill for these types of cheap monochrome string lights.

Solution Proposal

I was looking for a device to satisfy the following requirements:

  1. The device should be able to control at least one set of string lights (bonus points for multiple sets).
  2. The device should be able to control the brightness of the lights.
  3. The device should be able to control them via Home Assistant.
  4. Bonus points for extra headers for peripheral devices such as a PIR Motion Sensor.
  5. Bonus points for an onboard temperature sensor. They're cheap and can serve a variety of purposes for automations.

I created the following solution.


Smart LED Dimmer Schematic

PCB Layout

Smart LED Dimmer PCB Layout Front
Smart LED Dimmer PCB Layout Back

Parts List

These are the parts I decided to go with for my build. It was purely based on availability and cost. I was not familiar with many of these brands (other than Sensirion) before using them, but I have not had any issues with my device.

NameDesignatorFootprintQuantityManufacturer PartManufacturerSupplierSupplier Part
Header-Male-2.54_1x10H1HDR-TH_10P-P2.54-V-M-11Headers Pins2.54mm1*10PLCSCC57369
ESP32 LeftP1HDR-TH_8P-P2.54-V-F-11Female headerHDR1X8-2.54BOOMELELCSCC27438
ESP32 RightP2HDR-TH_8P-P2.54-V-F-11Female headerHDR1X8-2.54BOOMELELCSCC27438
Screw Terminal BlockU1CONN-TH_JL301-50004U011JL301-50004U01JILN(锦凌)LCSCC1509680

Other than that, you will also need a WeMos D1 MINI ESP32 or WeMos D1 ESP8266. The device is designed to work with either, but I have found it to work best with the ESP32 as it is more powerful and the ESP32 LEDC Output is a much better solution than the ESP8266 Software PWM Output.

Digital Render

This is a digital render of the board using MeshLab.

Smart LED Dimmer Digital Render


For the software to control the onboard ESP32 (or ESP8266), I decided to go with ESPHome due to its ease of use, especially with Home Assistant. This is an example that I wrote which treats both LED outputs as one controller, that way two sets of lights can be controlled simultaneously. It can also read the value of the onboard SHTC3 and report back to Home Assistant.

  devicename: bld-v2-01
  friendly_name: Hallway Mirror Lights

  name: ${devicename}
  platform: ESP32
  board: wemos_d1_mini32

  ssid: !secret wifi_ssid
  password: !secret wifi_password
  fast_connect: true
    ssid: ESP-${devicename}
    password: !secret fallback_password


  port: 80
    username: !secret web_username
    password: !secret web_password

  password: !secret api_password

  password: !secret ota_password
  safe_mode: True

  sda: GPIO21
  scl: GPIO22
  scan: true
  id: bus_a

  - platform: shtcx
      name: ${friendly_name} Temperature
      - lambda: return x * (9.0/5.0) + 32.0;
      unit_of_measurement: "°F"
      name: ${friendly_name} Humidity
    update_interval: 60s

  - platform: monochromatic
    name: ${friendly_name}
    output: LD1_LD2
    id: main_light
    gamma_correct: false
    restore_mode: RESTORE_DEFAULT_OFF

  - platform: template
    id: LD1_LD2
    type: float
      - output.set_level:
          id: LD1
          level: !lambda return state;
      - output.set_level:
          id: LD2
          level: !lambda return state;
  - platform: ledc
    id: LD1
    pin: GPIO26
    # You may want to configure a maximum power output depending on your particular lights, to ensure they are not damaged by being over-powered.
    # max_power: 0.60
    frequency: 1220Hz
  - platform: ledc
    id: LD2
    pin: GPIO23
    # You may want to configure a maximum power output depending on your particular lights, to ensure they are not damaged by being over-powered.
    # max_power: 0.60
    frequency: 1220Hz

Final Results

I sent the final design files to JLCPCB for production. They are by far the cheapest PCB manufacturer to my knowledge, and I am satisfied with the build quality for these types of projects.

Smart LED Dimmer Physical Device 1
Smart LED Dimmer Physical Device 2
It works great for controlling a variety of lights, with Wi-Fi and dimming support, it works great for my use case. If you have any questions about the design or software, feel free to reach out at [my name] and I'd be happy to help out.
©️ 2020-2024 JeffResc Last built 3 minutes ago