Servo PWM for ESP32

Is there a direct replacement of the pwm_8266 line for ESP32 in the following code ??

  - id: my_servo
    output: pwm_output
  - platform: esp8266_pwm
    id: pwm_output
    pin: D1
    frequency: 50 Hz
    transition_length: 10s

I have been told that ledc is a ESP32 replacement (for some applications), but how can I include the esp8266_pwm options (such as transition_length: 10s) into the code if I use LEDC ??

I think you’re on the wrong path here: transition_length is a property of servo, not of esp8266_pwm.
Otherwise, esp8266_pwm and ledc support the same configuration variables.

Thank you, you are absolutely right !! I connected my ESP32mini, used ledc and transition_length and everything works just fine, the 270 degree servos are moving smoothly at the transition_length speed I specify.(10s) …

I found a strange thing when I include a OLED display to the code .
The smooth movements of the servos starts jerking as soon as I add a SH1106 OLED to the code ??

  - file: "fonts/consolab.ttf"
    id: my_font
    size: 14

  sda: D2  # (or GPIO22 for ESP32)
  scl: D1   #  ( or GPIO21 for ESP32)
  - platform: ssd1306_i2c
    model: "SH1106 128x64"
    address: 0x3C
    lambda: |-
      it.print(0, 0, id(my_font), "Hello World 1");

The display works just fine and prints text lines,
but if I request say a 180 degree turn of the servos, (with the display lines code in the program), the servos rotate a few degrees, make a very short stop, moves a few degrees etc. until they completed the 180 degree turn…

If I remove the display lines in the code, the servos moves smoothly again…
The problem is exactly the same whether I use an ESP8266 or an ESP32…

Any ideas to why this happens ???


My guess would be that with the servo and display configured at the same time, you are reaching the ESP’s limits. After all, it’s a single thread that all the ESPHome code runs in, and the processor is trying to give each component a fair share, of course including things like overhead for WiFi or maybe other sensors you have configured.

That is possible, but I am running the exact same configuration ( Wemos D1 mini, servos & a SH1106 display) in an existing application with BLYNK, (compiled using Arduino IDE), and there the servos are running smoothly…(no servo jerking)…
Now I am trying to migrate everything into HA & ESPHome, so it would be nice to find a solution to the problem…