esphome-docs/components/output/pca9685.rst

139 lines
3.6 KiB
ReStructuredText
Raw Normal View History

PCA9685
=======
2018-05-13 11:37:02 +02:00
2018-11-14 22:12:27 +01:00
.. seo::
:description: Instructions for setting up PCA9685 LED PWM drivers.
2018-11-14 22:12:27 +01:00
:image: pca9685.jpg
:keywords: PCA9685
.. _pca9685-component:
Component/Hub
-------------
The PCA9685 component represents a PCA9685 12-bit PWM driver
(`datasheet <https://www.nxp.com/docs/en/data-sheet/PCA9685.pdf>`__,
`adafruit <https://www.adafruit.com/product/815>`__) in ESPHome. It
uses :ref:`I²C Bus <i2c>` for communication.
To use the channels of this components, you first need to setup the
global ``pca9685`` hub and give it an id, and then define the
:ref:`individual output channels <pca9685-output>`.
.. code-block:: yaml
# Example configuration entry
pca9685:
2022-08-16 06:03:13 +02:00
- id: pca9685_hub1
frequency: 500
# Individual outputs
output:
- platform: pca9685
pca9685_id: 'pca9685_hub1'
channel: 0
.. code-block:: yaml
# Example configuration entry with external clock enable and clock source from ESP32
pca9685:
- id: pca9685_hub1
external_clock_input: true
# Individual outputs
output:
# generate PWM from ESP32 ledc
- platform: ledc
pin: 25
id: extclk
min_power: 1
frequency: 40MHz
- platform: pca9685
pca9685_id: 'pca9685_hub1'
channel: 0
Configuration variables:
************************
- **frequency** (*Optional*, float): The frequency to let the
component drive all PWM outputs at. Must be in range from 24Hz to
1525.88Hz. Default ``1000Hz``.
- **external_clock_input** (*Optional*, bool): Enable external clock input. PRE_SCALE register will by set to 3. Default to ``false``.
- **address** (*Optional*, int): The I²C address of the driver.
Defaults to ``0x40``.
- **id** (*Optional*, :ref:`config-id`): The id to use for
this pca9685 component. Use this if you have multiple PCA9685s connected at the same time
.. _pca9685-output:
2022-04-03 09:30:25 +02:00
PCA9685 Output
--------------
2018-11-14 22:12:27 +01:00
2018-05-13 11:37:02 +02:00
The PCA9685 output component exposes a PCA9685 PWM channel of a global
:ref:`PCA9685 hub <pca9685-component>` as a float
2018-05-13 11:37:02 +02:00
output.
2018-06-01 18:10:00 +02:00
.. figure:: images/pca9685-full.jpg
:align: center
:width: 75.0%
2018-05-13 11:37:02 +02:00
2018-06-01 18:10:00 +02:00
PCA9685 16-Channel PWM Driver.
2018-05-13 11:37:02 +02:00
.. code-block:: yaml
2018-05-13 11:37:02 +02:00
# Example configuration entry
pca9685:
2018-06-01 18:10:00 +02:00
- frequency: 500
2018-05-13 11:37:02 +02:00
# Individual outputs
output:
- platform: pca9685
id: 'pca9685_output1'
channel: 0
Configuration variables:
************************
2018-05-13 11:37:02 +02:00
2018-06-01 18:10:00 +02:00
- **id** (**Required**, :ref:`config-id`): The id to use for this output component.
- **channel** (**Required**, int): Chose the channel of the PCA9685 of
this output component. Must be in range from 0 to 15.
- **pca9685_id** (*Optional*, :ref:`config-id`): Manually specify the ID of the
:ref:`PCA9685 hub <pca9685-component>`.
2018-06-01 18:10:00 +02:00
Use this if you have multiple PCA9685s you want to use at the same time.
- All other options from :ref:`Output <config-output>`.
2022-07-03 19:33:06 +02:00
2022-10-18 21:10:12 +02:00
Examples
2022-10-18 21:10:38 +02:00
--------
2022-07-03 19:33:06 +02:00
2022-11-28 09:29:07 +01:00
This output can be used for different PWM functions. E.g. output for light, fan etc.
2022-07-03 19:33:06 +02:00
.. code-block:: yaml
pca9685:
frequency: 500
output:
- platform: pca9685
channel: 0
id: pwm01
light:
- platform: monochromatic
name: 'main light'
output: pwm01
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/esp8266_pwm`
- :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:`pca9685/pca9685_output.h`
2018-08-24 22:44:01 +02:00
- `PCA9685 Arduino Library <https://github.com/NachtRaveVL/PCA9685-Arduino>`__ by `@NachtRaveVL <https://github.com/NachtRaveVL>`__
- :ghedit:`Edit`