← - ESP-IDF framework C guide and examples. | Contents | Next: Tasmota Configuration →
ESPHome Component
The ac_dimmer component allows you to connect a dimmable light or other load that supports phase control dimming to your ESPHome project.
Example Configuration
# Example configuration entry
output:
- platform: ac_dimmer
id: dimmer1
gate_pin: 7
zero_cross_pin:
number: 6
mode:
input: true
inverted: yes
light:
- platform: monochromatic
output: dimmer1
name: Dimmerized Light
Configuration Variables
Required Parameters
- gate_pin (Required, Pin): The pin used to control the Triac or Mosfet
- zero_cross_pin (Required, Pin): The pin used to sense the AC Zero cross event. You can have several dimmers controlled with the same zero cross detector. In such cases, duplicate the
zero_cross_pinconfig on each output
Optional Parameters
- method (Optional): Set the method for dimming, which can be:
leading pulse(default): A short pulse to trigger a TRIACleading: Gate pin driven high until the zero-cross is detected-
trailing: Gate pin is driven high from zero-cross until dimming period. This method is suitable for MOSFET dimmers only -
init_with_half_cycle (Optional, boolean): Will send the first full half AC cycle. Try to use this for dimmable LED lights, it might help to turn on at low brightness levels. On gas (halogen) lamps it might show an initial flicker. Defaults to
false -
id (Optional, ID): Manually specify the ID used for code generation
-
All other options from Output
Connection Table
| MCU | INPUT Pin Zero Cross | OUTPUT Pin |
|---|---|---|
| ESP8266 | D1(GPIO5), D5(GPIO14), D7(GPIO13), D2(GPIO4), D6(GPIO12), D8(GPIO15) | D0(GPIO16), D2(GPIO4), D6(GPIO12), D8(GPIO15), D1(GPIO5), D5(GPIO14), D7(GPIO13) |
| ESP32 | GPIO: 36, 39, 32, 25, 27, 12, 7, 2, 4, 17, 18, 21, 22, 34, 35, 33, 26, 14, 13, 15, 0, 16, 5, 19, 1, 23 | GPIO: 32, 25, 27, 12, 15, 0, 16, 5, 19, 3, 22, 33, 26, 14, 13, 2, 4, 17, 18, 21, 1, 23 |
Fine-Tuning Dimming Behavior
Dimming lights with phase control can be tricky. The minimum level your light turns on might be different from other lights, and the perceived light level might not correlate to the percentage output set to the light.
To minimize these behaviors, you can tweak:
- min_power - from the output component
- gamma_correct - from the monochromatic light component
Additional Resources
Links to Examples
← - ESP-IDF framework C guide and examples. | Contents | Next: Tasmota Configuration →