How change loop_interval value for improve h-bridge light?

Hi.

I using h-bridge light. It works fine, but, the light is a little dimmed. I check the code and each loop change the direction. The problem is ESPHome execute the loop each every 16ms (60hz), so the each light is on half time (30hz), I can notice a little flicks.

I think if can change the loop interval to 4-8ms I would get improved results.

I see the set exists in cpp, but I don’t know how pass a value from yaml:

Add the following to your yaml config:

esphome:
  on_boot:
    then:
      - lambda: App.set_loop_interval(0);

You can see the actual loop time your ESP chip achieved by adding:

debug:
  update_interval: 5s

sensor:
  - platform: debug
    loop_time:
      name: "Loop Time"

With api component I get ~11ms on ESP8266 and ~5ms on ESP32. Without the api component I get ~1ms on ESP32.

1 Like