esphome-docs/components/output/esp8266_pwm.rst

76 lines
2.4 KiB
ReStructuredText
Raw Normal View History

2018-05-13 11:37:02 +02:00
ESP8266 Software PWM Output
===========================
2018-11-14 22:12:27 +01:00
.. seo::
:description: Instructions for setting up ESP8266 software-based PWMs.
:image: pwm.png
2018-05-13 11:37:02 +02:00
The ESP8266 Software PWM platform allows you to use a software PWM on
2019-02-16 23:25:23 +01:00
the pins GPIO0-GPIO16 on your ESP8266. Note that this is a software PWM,
2020-05-10 21:27:59 +02:00
so there can be some flickering during periods of high WiFi activity. Hardware PWMs
2019-02-16 23:25:23 +01:00
like the one on the ESP32 (see :doc:`ledc`) are preferred.
2018-05-13 11:37:02 +02:00
.. code-block:: yaml
2018-05-13 11:37:02 +02:00
# Example configuration entry
output:
- platform: esp8266_pwm
pin: GPIOXX
frequency: 1000 Hz
id: pwm_output
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: pwm_output
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:`Pin Schema <config-pin_schema>`): The pin to use PWM on.
- **id** (**Required**, :ref:`config-id`): The id to use for this output component.
- **frequency** (*Optional*, frequency): The frequency to run the PWM with. Lower frequencies
have more visual artifacts, but can represent much more colors. Defaults to ``1000 Hz``.
2018-06-01 18:10:00 +02:00
- All other options from :ref:`Output <config-output>`.
.. note::
If you previously had Tasmota installed on your device and have just flashed ESPHome onto it,
you may encounter an issue where the PWM output is only fully on or off.
A hard reset fixes the problem - if you have this issue please power cycle the device, that
should fix it.
2019-05-12 22:44:59 +02:00
.. _output-esp8266_pwm-set_frequency_action:
``output.esp8266_pwm.set_frequency`` Action
-------------------------------------------
This :ref:`Action <config-action>` allows you to manually change the frequency of an ESP8266 PWM
channel at runtime. Use cases include controlling a passive buzzer (for pitch control).
.. code-block:: yaml
on_...:
- output.esp8266_pwm.set_frequency:
id: pwm_output
frequency: 100Hz
Configuration variables:
- **id** (**Required**, :ref:`config-id`): The ID of the PWM output to change.
- **frequency** (**Required**, :ref:`templatable <config-templatable>`, float): The frequency
to set in hertz.
2018-06-01 18:10:00 +02:00
See Also
2018-10-12 16:33:22 +02:00
--------
2018-06-01 18:10:00 +02:00
- :doc:`/components/output/index`
- :doc:`/components/output/ledc`
- :doc:`/components/light/monochromatic`
- :doc:`/components/fan/speed`
- :doc:`/components/power_supply`
2019-05-12 22:44:59 +02:00
- :apiref:`esp8266_pwm/esp8266_pwm.h`
- :ghedit:`Edit`