PWM pulse generation with esp32 and esphome

I want to generate with an esp32 a square signal of 1khz frequency pulses and with square pulses of 10% on and 90% off. I understand that if the frequency is 1Khz the “update_interval” parameter will be 1ms and “transition_lenght” 0.1ms:

effects:
   - pulse:
      name: "Pulse"
      update_interval: 1ms
       transition_length: 0.1ms

But I get the message “Maximum precision is milliseconds.”!!

I think that a frequency of 1Khz is quite normal, and I am surprised that a signal of this type cannot be generated.

Am I wrong about something, or is it really that this type of signal cannot be generated?

Thank you so much

Ledc component is not ok for you?

I’ve tested ledc, with this configuration:

> output:
>   - platform: ledc
>     pin: GPIO32
>     frequency: 1000  # Frecuencia en Hz
>     id: cargador_pwm_output
>     max_power: 1.0
> 
>  light:
>   - platform: monochromatic
>      output: cargador_pwm_output
>     name: "Cargador"
>      restore_mode: ALWAYS_ON
>      id: cargador
>      on_turn_on: 
>        then:
>           - light.turn_on:
>               id: cargador
>               brightness: 10%

If I mesure the voltage is 0.33V (10% of 3.3V) so I think the output is not square it seems proporcional to the brightness.t doesn’t look like a square sign

On your oscilloscope or logic analyser?

1 Like

Using ledc component to generate PWM signal for gas valve modulation.
It working perfect. Highly recommend to use oscillosope to control waveform.