2018-05-13 11:37:02 +02:00
|
|
|
|
ESP32 LEDC Output
|
|
|
|
|
=================
|
|
|
|
|
|
2018-11-14 22:12:27 +01:00
|
|
|
|
.. seo::
|
|
|
|
|
:description: Instructions for setting up LEDC hardware PWM outputs on the ESP32.
|
|
|
|
|
:image: pwm.png
|
|
|
|
|
|
2018-05-13 11:37:02 +02:00
|
|
|
|
The LEDC output component exposes a `LEDC PWM
|
2018-11-19 18:32:16 +01:00
|
|
|
|
channel <https://docs.espressif.com/projects/esp-idf/en/latest/api-reference/peripherals/ledc.html>`__
|
2018-05-13 11:37:02 +02:00
|
|
|
|
of the ESP32 as an output component.
|
|
|
|
|
|
2019-05-12 22:44:59 +02:00
|
|
|
|
The frequency range of LEDC is from 10Hz to 40MHz - however, higher frequencies require a smaller
|
|
|
|
|
bit_depth which means the output is not that accurate for frequencies above ~300kHz.
|
|
|
|
|
|
2018-11-19 18:32:16 +01:00
|
|
|
|
.. code-block:: yaml
|
2018-05-13 11:37:02 +02:00
|
|
|
|
|
|
|
|
|
# Example configuration entry
|
|
|
|
|
output:
|
|
|
|
|
- platform: ledc
|
2019-02-16 23:25:23 +01:00
|
|
|
|
pin: GPIO19
|
2018-06-01 18:10:00 +02:00
|
|
|
|
id: gpio_19
|
2018-05-13 11:37:02 +02:00
|
|
|
|
|
2019-02-16 23:25:23 +01:00
|
|
|
|
# Example usage in a light
|
|
|
|
|
light:
|
|
|
|
|
- platform: monochromatic
|
|
|
|
|
output: gpio_19
|
|
|
|
|
name: "Kitchen Light"
|
|
|
|
|
|
2018-05-13 11:37:02 +02:00
|
|
|
|
Configuration variables:
|
2018-10-12 16:33:22 +02:00
|
|
|
|
------------------------
|
2018-05-13 11:37:02 +02:00
|
|
|
|
|
2018-06-01 18:10:00 +02:00
|
|
|
|
- **pin** (**Required**, :ref:`config-pin`): The pin to use LEDC on. Can only be GPIO0-GPIO33.
|
|
|
|
|
- **id** (**Required**, :ref:`config-id`): The id to use for this output component.
|
|
|
|
|
- **frequency** (*Optional*, float): At which frequency to run the LEDC
|
2019-05-12 22:44:59 +02:00
|
|
|
|
channel’s timer. Defaults to 1000Hz.
|
|
|
|
|
- **bit_depth** (*Optional*, int): The bit depth to use for the LEDC channel. Defaults to the
|
|
|
|
|
highest possible for the configured frequency.
|
2019-02-16 23:25:23 +01:00
|
|
|
|
- All other options from :ref:`Output <config-output>`.
|
|
|
|
|
|
|
|
|
|
Advanced options:
|
|
|
|
|
|
2018-06-01 18:10:00 +02:00
|
|
|
|
- **channel** (*Optional*, int): Manually set the `LEDC
|
2018-11-19 18:32:16 +01:00
|
|
|
|
channel <https://docs.espressif.com/projects/esp-idf/en/latest/api-reference/peripherals/ledc.html#configure-channel>`__
|
2018-06-01 18:10:00 +02:00
|
|
|
|
to use. Two adjacent channels share the same timer. Defaults to an automatic selection.
|
|
|
|
|
|
|
|
|
|
See Also
|
2018-10-12 16:33:22 +02:00
|
|
|
|
--------
|
2018-06-01 18:10:00 +02:00
|
|
|
|
|
2019-02-07 13:54:45 +01:00
|
|
|
|
- :doc:`/components/output/index`
|
|
|
|
|
- :doc:`/components/output/esp8266_pwm`
|
|
|
|
|
- :doc:`/components/light/monochromatic`
|
|
|
|
|
- :doc:`/components/fan/speed`
|
|
|
|
|
- :doc:`/components/power_supply`
|
2019-05-12 22:44:59 +02:00
|
|
|
|
- :apiref:`ledc/ledc_output.h`
|
2018-11-19 18:32:16 +01:00
|
|
|
|
- `esp-idf LEDC API docs <https://docs.espressif.com/projects/esp-idf/en/latest/api-reference/peripherals/ledc.html>`__
|
2019-02-07 13:54:45 +01:00
|
|
|
|
- :ghedit:`Edit`
|