I’m using a quite straightforward configuration for a ESP32 WROOM 32 microcontroller for dimming 12 V DC Christmas LED lights via a RFP30N06LE mosfet transistor. I’m using the ledc module for controlling the mosfet through a hardware PWM channel from the esp32, essentially nothing more than the code example from the esphome documentation for the ledc module.
But unfortunately the LEDs are flickering unsteady, when dimmed (but not at 100% brightness), similar to real candles. While this may be a desired effect for Christmas lights for some people, I find it very irritating.
Changing the PWM frequency doesn’t help against this unsteady flickering “effect”.
I’m suspecting a problem with the microcontroller not being able to accuratly maintaining the PWM frequency, causing the LEDs to flicker, but tbh. the sole reason I chose a esp32 with it’s hardware PWMs for such a simple task, was to avoid exactly such problems I’d expect from an underpowered esp8266 trying to maintian a software controlled PWM.
I’m using two H801 led controllers with esphome firmware for dimming other LED lights, that didn’t show any unsteady flickering at all, even if the PWM signals are software controlled in these devices.
Does anyone have an idea, what could cause this flickering and how I could get rid of it?
This is my config:
esphome:
name: ${node_name}
esp32:
board: esp32dev
framework:
type: arduino
substitutions:
node_name: weihnachtsbaumlicht
node_friendly_name: Weihnachtsbaumlicht
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
domain: !secret wifi_domain
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "${node_friendly_name} AP"
password: !secret wifi_ap_password
captive_portal:
logger:
ota:
password: !secret ota_password_weihnachtsbaumlicht
mqtt:
broker: !secret mqtt_broker
username: !secret mqtt_username
password: !secret mqtt_password
on_message:
- topic: ${node_name}/pwm_frequency
then:
- output.ledc.set_frequency:
id: gpio_19
frequency: !lambda 'return parse_number<float>(x).value();'
binary_sensor:
- platform: status
name: "${node_friendly_name} MQTT Status"
light:
- platform: monochromatic
output: gpio_19
name: ${node_friendly_name}
default_transition_length: 500ms
output:
- platform: ledc
pin: GPIO19
id: gpio_19
sensor:
- platform: wifi_signal
name: "${node_friendly_name} WiFi"
filters:
- filter_out: nan
switch:
- platform: restart
name: "${node_friendly_name} Restart"
text_sensor:
- platform: version
name: "${node_friendly_name} ESPHome Version"