Skip to Content

AC Dimmer with Home Assistant: ESPHome and DimmerLink Guide

Two paths to control an AC dimmer from Home Assistant: the standard ESPHome ac_dimmer platform (quick setup, but risky on ESP32+WiFi) and the DimmerLink ESPHome component (recommended for reliability).

TL;DR: Two integration paths exist. Path A (standard ESPHome ac_dimmer platform) is simple but causes ISR/WiFi conflicts on dual-core ESP32. Path B (DimmerLink ESPHome component) offloads TRIAC timing to a dedicated controller — no ISR, no conflicts, works on any platform including ESP32-C3, Raspberry Pi, and HA OS.



Which Path Should You Use?

Criteria Path A: Standard ESPHome Path B: DimmerLink
Board ESP8266 (safe), ESP32 (risky) Any ESP32, RPi, any SBC
YAML complexity ~10 lines ~30 lines
WiFi stability May flicker with WiFi load No conflict (I2C only)
Single-core ESP32 Not supported Supported
Additional hardware None DimmerLink module
Dimming quality Good Excellent (hardware timing)

⚠️ Why ESP32 is risky with Path A: the standard ac_dimmer platform uses a software ISR on ESP32. When WiFi or the HA API is active, ISR timing is disrupted, causing visible flickering or dimmer freezes. Use Path B to eliminate the ISR entirely.

Choose Path A if you are using ESP8266 and want the simplest setup.

Choose Path B if you are using ESP32 (any variant), Raspberry Pi, HA OS on x86, or need reliable dimming with WiFi/MQTT active.




Path A: Standard ESPHome ac_dimmer Platform


Wiring (ESP8266 / ESP32)

text
Dimmer module   →   ESP8266 (NodeMCU)
──────────────────────────────────────
ZC-OUT          →   D1 (GPIO5)
DIM             →   D2 (GPIO4)
VCC             →   3.3V
GND             →   GND

For ESP32, any GPIO can be used for both ZC and DIM.


ESPHome YAML

yaml
esphome:
  name: ac-dimmer
  platform: ESP8266      # or ESP32
  board: nodemcuv2       # adjust for your board
wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password
api:
  encryption:
    key: !secret api_key
ota:
  password: !secret ota_password
output:
  - platform: ac_dimmer
    id: dimmer_out
    gate_pin: GPIO4
    zero_cross_pin:
      number: GPIO5
      mode: INPUT
      inverted: yes
    method: leading_pulse  # default; use 'trailing' for MOSFET
    min_power: 0.01
light:
  - platform: monochromatic
    output: dimmer_out
    name: "AC Dimmer"
    gamma_correct: 0       # set 0 for linear, 2.8 for LED perceived


Dimming methods

Method method: value Use with
Leading pulse (default) leading_pulse TRIAC modules
Leading (gate held) leading TRIAC — alternative
Trailing trailing MOSFET-based modules only


Known issue: ESP32 + WiFi

⚠️ The standard ac_dimmer platform uses a software ISR on the ESP32. When WiFi is active (especially with HA API or OTA), the ISR can be delayed, causing visible flickering or dimmer freezes.

This is the same root cause as crashes with the RBDdimmer C++ library. See: ESP32 + AC Dimmer: IRAM_ATTR Causes and Fix

Solution: Use Path B (DimmerLink) for ESP32-based HA installs.




Path B: DimmerLink ESPHome Component

DimmerLink is a dedicated controller with a Cortex-M0+ processor that handles zero-cross detection and TRIAC gate timing internally. Your ESP32 sends a brightness value (0–100%) via I2C — no ISR on the MCU.


Wiring

text
DimmerLink   →   ESP32
─────────────────────────
VCC          →   3.3V
GND          →   GND
SDA          →   GPIO21
SCL          →   GPIO22

DimmerLink → AC load wiring is identical to the standard module. See: Hardware Connection Guide


Install the ESPHome component

Add the external component to your YAML:

yaml
external_components:
  - source:
      type: git
      url: https://github.com/robotdyn-dimmer/DimmerLink
      ref: main
    components: [dimmerlink]

Component source and docs: github.com/robotdyn-dimmer/DimmerLink/tree/main/components


Minimal YAML (~30 lines)

yaml
esphome:
  name: dimmerlink-ha
  platform: ESP32
  board: esp32dev
wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password
api:
  encryption:
    key: !secret api_key
ota:
  password: !secret ota_password
external_components:
  - source:
      type: git
      url: https://github.com/robotdyn-dimmer/DimmerLink
      ref: main
    components: [dimmerlink]
i2c:
  sda: GPIO21
  scl: GPIO22
  frequency: 100kHz
light:
  - platform: dimmerlink
    name: "Dimmer"
    address: 0x50

Flash this, add to HA, done.


Standard YAML — with sensors and curve selector

yaml
# (external_components + i2c as above)
light:
  - platform: dimmerlink
    name: "Dimmer"
    address: 0x50
sensor:
  - platform: dimmerlink
    address: 0x50
    frequency:
      name: "AC Frequency"
    brightness:
      name: "Dimmer Brightness"
select:
  - platform: dimmerlink
    address: 0x50
    dimming_curve:
      name: "Dimming Curve"
      # Options: LINEAR, RMS, LOGARITHMIC
binary_sensor:
  - platform: dimmerlink
    address: 0x50
    status:
      name: "Dimmer Status"


Dimming curves

Curve Best for
LINEAR Heating elements, resistive loads
RMS Incandescent and halogen bulbs
LOGARITHMIC Dimmable LED bulbs



Home Assistant Device View

After flashing and adding the ESPHome device to HA:

  • Path A creates one light entity with a brightness slider (0–255 mapped from 0–100%)
  • Path B creates a light entity plus optional sensor entities (AC frequency, brightness %, firmware version) and a dimming curve selector — all shown on one HA device card



Multi-Channel with DimmerLink

Each DimmerLink module handles one AC load at one I2C address (set via address jumpers on the board). To control two loads, connect two separate DimmerLink modules on the same I2C bus with different addresses:

yaml
light:
  - platform: dimmerlink
    name: "Channel 1"
    address: 0x50
  - platform: dimmerlink
    name: "Channel 2"
    address: 0x51



Related Articles



Still have questions?

Ask on forum.rbdimmer.com or open a GitHub Issue.

Share this post
Sign in to leave a comment