Skip to content

PCB and enclosure design of a trailing edge light bulbs dimmer

License

Notifications You must be signed in to change notification settings

VasilKalchev/LEDDs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

9 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

LEDDs

trailing-edge dimmer for LED bulbs

schematic_pcb firmware chassis

LEDDs is an open-source hardware, DIY, smart dimmer for 230 V LED bulbs. It is built around the ESP32-C3-12F and is designed to sit on a desk or table, replacing standard inline cord switches.

The project consists of a PCB, a 3D-printable chassis, and a top plate designed as a PCB. It runs ESPHome for integration with Home Assistant and features a rotary encoder so it can be controlled easily or used as a standalone device.

ledds

Caution

MAINS VOLTAGE: This device operates at 230 VAC. Touching live components can result in serious injury or death.

  • Only build if you have relevant experience with high-voltage electronics.
  • Always unplug before opening!
  • While the design includes safety features (fuse, MOVs), it is not a certified design and should be treated with caution.

Table of contents


Is this project for you?

This project is suitable if you:

  • have experience with mains-powered electronics
  • want a LED bulbs dimmer for a desk

This project is NOT suitable if you:

  • are new to electronics
  • need a certified wall dimmer

Why trailing-edge?

Most dimmers use leading-edge (TRIAC) dimming (designed for incandescent bulbs). They modulate power to the load by cutting the beginning of the AC half cycle. This creates a voltage spike that can cause buzzing and reduced lifespan in the capacitive power supplies found in LED bulbs.

LEDDs uses trailing-edge dimming. By using MOSFETs to cut the waveform at the end of the AC cycle, there isn't a positive voltage spike. This results in:

  • reduced electrical noise and buzzing
  • smoother dimming with reduced flicker
  • lower minimum brightness levels

The schematic and PCB can be viewed in KiCanvas.

⭐ Features

  • ESP32-C3 based with ESPHome firmware for integration with Home Assistant
  • Standalone operation, doesn't require Home Assistant
  • Rotary encoder control: rotate to dim, press+rotate for effects, press for on/off
  • LEDs: red (rotation feedback), blue (status indicator), white (ambient)
  • Included enclosure design: 100 mm Γ— 51 mm Γ— 25 mm - ideal for desk lamp modifications
  • Low idle power: ~0.3 W
  • Open source: MIT licensed

πŸ“ Specifications

Parameter Value
Input voltage 230 VAC
Maximum output power 100 W
Idle power draw ~0.3 W
Protections fuse and MOVs
Microcontroller module ESP32-C3-12F 1
Dimensions 100 Γ— 51 Γ— 25 mm (W Γ— D Γ— H)
Connectivity Wi-Fi, USB-C (programming)

Important

Designed for 230 VAC at 50 Hz.

Usage with 120 VAC at 60 Hz will probably require adjusting the component values of the zero-cross and the voltage regulator circuits.


Release/fabrication of v2.0

Status: Stable

Status: Verified working. The fabricated board from this release is fully functional. Minor issues may exist but do not affect operation: /doc/releaselog.md v2.0.

πŸ“ Recommended for fabrication.


πŸ“‚ Repository structure


β”œβ”€β”€ hw/                       # main PCB design (KiCad project)
β”‚   β”œβ”€β”€ lib/                  # symbols and footprints
β”‚   β”œβ”€β”€ assets/               # fonts and graphics
β”‚   └── export/               # scripts for exporting gerbers, BOM and schematics/PCB PDFs
β”œβ”€β”€ fw/                       # ESPHome YAML configurations and firmware binaries
β”œβ”€β”€ doc/                      # additional documentation
β”‚   β”œβ”€β”€ releaselog.md         # main PCB release log
β”‚   β”œβ”€β”€ changelog.md          # main PCB change log
β”œβ”€β”€ enclosure/
β”‚   β”œβ”€β”€ chassis/              # 3D printable chassis
β”‚   β”‚   β”œβ”€β”€ releaselog.md     # chassis release log
β”‚   β”‚   β”œβ”€β”€ changelog.md      # chassis change log
β”‚   β”‚   β”œβ”€β”€ vX.Y-variant_a/
β”‚   β”‚   └── vX.Y-variant_b/
β”‚   └── top_plate/            # top plate design (KiCad project)
β”‚       β”œβ”€β”€ releaselog.md     # top plate release log
β”‚       β”œβ”€β”€ changelog.md      # top plate change log
β”‚       β”œβ”€β”€ vX.Y-variant_a/
β”‚       └── vX.Y-variant_b/
└── img/                      # photos and renders

πŸ’Ά Bill of materials

  • components: ~€15
  • PCB: €4 (ordered as prototype board)
  • top plate: €0-4 (can be combined with the main PCB)
  • chassis: €4-10 (when ordered)

Check out the BOM provided in the release bundle for complete components list.

πŸ”¨ Build

Overview

Building LEDDs consists of four main steps:

  1. Ordering the PCB, the chassis and the components.
  2. Assembling the PCB.
  3. Flashing and configuring the firmware.
  4. Wiring and final assembly.

Prerequisites

  • skills: soldering 2, experience with mains electricity
  • tools: soldering iron, hot air gun (recommended), 3D printer or access to 3D printing service, multimeter

Download the release bundle.

1. Ordering the components

  • PCBs: order the main PCB and the top plate PCB from your preferred fabricator
    • gerbers for JLCPCB: available in the bundle
    • for other fabricators - use KiCad to generate gerbers according to the manufacturer's instructions
  • chassis: choose a variant from the provided STL files

2. PCB assembly instructions

Tip

Use the provided interactive BOM ("ibom.html") as a soldering guide.

interactive BOM preview

Microcontroller module

ESP32-C3-12F (recommended)

esp32-c3-12f

  • solder R13
ESP8266 ESP-12F (not recommended) esp-12f
  • insulate pins 12 and 13 from the PCB pads using kapton/electrical tape
  • solder JP2
  • don't solder R13
  • don't solder R6 and D3 ("led_1")
  • don't solder R8 and D5 ("led_3")

ESP8266 doesn't support native USB and requires an external USB to serial adapter for programming.

Zero-cross optoisolator

The PCB has footprints for a choice between 2 optoisolators that connect the zero-cross signal to the MCU.

H11L1SR2M

h11l1

  • solder the optoisolator on footprint U4
  • solder C13
  • don't solder R23
PC817XI (not recommended) pc817
  • solder the optoisolator on footprint U3
  • solder R23
  • no need to solder C13

This optoisolator is the same as the one used for controlling the MOSFET's gate, but didn't work well for the zero-cross circuit.

Skipping the relay

The relay is used to power off the mains part of the circuit when the load is turned off. This is intended as a peace of mind feature and can be omitted.

relay

  • use a wire to short pin 11 to 14
  • use a wire to short pin 21 to 24
  • no need to solder C3, D2, R2 and Q1

Skipping the rotary encoder

boot button

If the rotary encoder is not required - solder a push button (SW2) so boot mode can be entered manually.

  • no need to solder R3, R4, C4, C5 and C6

A modified top plate (without a hole in the middle) is recommended for safety reasons (not currently available).

Using the UART header instead of the USB for programming (not tested)

uart

  • solder R12
  • solder header J4
  • no need to solder R9 and R10

Use a USB to serial adapter.

3. Flashing the firmware

  • Connect to the board via USB-C.
  • Use ESPHome's web flasher to upload one of the provided firmware binaries.
    • hass.bin: Home Assistant + rotary encoder
    • web_server.bin: self hosted web server + rotary encoder
    • standalone: rotary encoder only
  • Set your Wi-Fi credentials using the ESPHome web flasher.
  • Test before wiring.

Tip

The YAML configurations of the provided binaries are available under /fw/esphome/yaml/.

4. Preparing the enclosure

  • plastic chassis: install the heat-set threaded inserts in the holes using a soldering iron
  • resin chassis: no preparation needed

5. Final assembly

  • Mount a knob to the rotary encoder.
  • Place the PCB inside the chassis.
  • Screw the mains power cable to the terminal on the left (marked with a power plug). Don't connect power until fully assembled.
  • Screw the lamp socket cable to the terminal on the right (marked with a bulb).
  • Pass the screws through the top plate and place the spacers on the screws.
  • Screw the top plate through the PCB into the chassis.

πŸ’‘ Usage

Control

Directly (possible with all firmware variants):

  • press: on/off
  • rotate: brightness adjustment
  • press + rotate: cycle lighting effects

Home Assistant (included in hass.bin):

Integrating the device in Home Assistant: https://esphome.io/guides/getting_started_hassio/#connecting-your-device-to-home-assistant.

screenshot of the device in Home Assistant

The "Configuration" section allows customization of the device:

  • Bulb power rating: input the power rating of the bulb, this is used for the power estimation sensor ("Power [est]").
  • Gamma correct: Adjust the dimming curve to appear linear to the human eye.
  • Minimum level: The lowest level at which the bulb emits light. Note: this value needs to be updated every time gamma correction is changed.
  • Restore mode: Initial state of the bulb when powered.
  • Transition length: How fast the bulb changes brightness in milliseconds.
  • LED: red/blue/white: set the ambient brightness of the LEDs.

Web server (included in web_server.bin):

This is useful if you don't have Home Assistant, but want to control the device remotely.

screenshot of the web UI

LED indicators

There are three LEDs on the board:

  • red (top, led_1): ambient / rotation feedback
  • blue (top, led_2): ambient / status indicator
  • white (bottom, led_3): ambient

Default light effects

Light effects can be cycled with the rotary encoder or chosen directly from a UI.

  • Pulse (low, fast)
  • Pulse (low, slow)
  • Pulse (high, fast)
  • Pulse (high, slow)
  • Pulse (full, fast)
  • Pulse (full, slow)
  • Flicker (soft)
  • Flicker (intense)

πŸ“ƒ Versions, releases and compatibility

Each fabrication run results in a GitHub release.

  • Semantic versioning (major.minor), no patch versions.
  • PCB, chassis, and top plate are versioned independently.
  • Same major versions fit together.

β˜• Contributing

Every type of contribution is welcome, like improvements or corrections to the:

  • schematic/PCB design
  • documentation
  • enclosure (chassis and top panel) design
  • ESPHome configuration

Contributions can be made as improvements or as variants (e.g. different enclosure design, ESPHome configuration, etc.).

gitGraph
    commit tag: "v1.0"
    branch improve_x
    checkout improve_x
    commit id: "Improve x"
    commit id: "Re-generate exports"
    commit id: "Update board documentation"
    checkout main
    merge improve_x tag: "v1.1"
    branch replace_y
    checkout replace_y
    commit id: "Replace y"
    commit id: "Generate exports"
    commit id: "Compile binaries"
    commit id: "Update all documentation"
    checkout main
    merge replace_y tag: "v2.0"
Loading

You're welcome to post your builds in Discussions: Show and tell.

License

This project is licensed under the MIT License.


Disclaimer: This project involves mains voltage electricity. The author assumes no liability for injury, damage, or regulatory violations. Build and use at your own risk. Ensure compliance with local electrical codes and regulations.

Footnotes

  1. Also compatible with ESP8266 ESP-12F, but not recommended. ↩

  2. Trickiest part is the USB-C port. The board can be ordered pre-assembled. ↩