mirror of
https://github.com/esphome/esphome-docs.git
synced 2024-11-15 10:45:41 +01:00
104 lines
3.1 KiB
ReStructuredText
104 lines
3.1 KiB
ReStructuredText
|
PCA6416A I/O Expander
|
||
|
=====================
|
||
|
|
||
|
.. seo::
|
||
|
:description: Instructions for setting up PCA6416A and PCAL6416A, digital port expanders in ESPHome.
|
||
|
:image: pca6416a.svg
|
||
|
|
||
|
The PCA6416A component allows you to use **PCA6416A** or **PCAL6416A** I/O expanders in ESPHome.
|
||
|
It uses :ref:`I²C Bus <i2c>` for communication.
|
||
|
|
||
|
Once configured, you can use any of the **16** pins for your projects. Within ESPHome they emulate a real internal
|
||
|
GPIO pin and can therefore be used with many of ESPHome's components such as the GPIO binary sensor or GPIO switch.
|
||
|
|
||
|
.. note::
|
||
|
|
||
|
The 7 bit I²C device address ranges are:
|
||
|
|
||
|
- PCA6416A: ``0x20`` to ``0x21``
|
||
|
- PCAL6416A: ``0x20`` to ``0x21``
|
||
|
|
||
|
For the PCA6416A and PCAL6416A, the actual choice of the I²C device address depends on state of the address pin.
|
||
|
Please refer to the individual datasheets linked at the bottom of the page for further details to set the address.
|
||
|
|
||
|
Up to two PCA6416A or PCAL6416A devices can reside on the same I²C bus.
|
||
|
|
||
|
The PCA6416A and PCAL6416A provide 16 bits of GPIO's (pin numbers 0-15).
|
||
|
|
||
|
Only the PCAL6416A supports pull-up resistors.
|
||
|
|
||
|
Any option accepting a :ref:`Pin Schema <config-pin_schema>` can theoretically be used, but some more
|
||
|
complicated components that do communication through this I/O expander will not work.
|
||
|
|
||
|
.. code-block:: yaml
|
||
|
|
||
|
# Example configuration entry
|
||
|
pca6416a:
|
||
|
- id: 'pca6416a_device'
|
||
|
address: 0x20
|
||
|
|
||
|
# Individual outputs
|
||
|
switch:
|
||
|
- platform: gpio
|
||
|
name: "PCA6416A Pin #0"
|
||
|
pin:
|
||
|
pca6416a: pca6416a_device
|
||
|
# Use pin number 0
|
||
|
number: 0
|
||
|
# One of INPUT or OUTPUT
|
||
|
mode:
|
||
|
output: true
|
||
|
inverted: false
|
||
|
|
||
|
|
||
|
.. code-block:: yaml
|
||
|
|
||
|
# Example configuration entry
|
||
|
pca6416a:
|
||
|
- id: 'pcal6416a_device'
|
||
|
address: 0x20
|
||
|
|
||
|
# Individual outputs
|
||
|
switch:
|
||
|
- platform: gpio
|
||
|
name: "PCAL6416A Pin #0"
|
||
|
pin:
|
||
|
pca6416a: pcal6416a_device
|
||
|
# Use pin number 0
|
||
|
number: 0
|
||
|
# One of INPUT, INPUT_PULLUP or OUTPUT
|
||
|
mode:
|
||
|
input: true
|
||
|
pullup: true
|
||
|
inverted: false
|
||
|
|
||
|
Configuration variables:
|
||
|
************************
|
||
|
|
||
|
- **id** (**Required**, :ref:`config-id`): The id to use for this ``pca6416a`` component.
|
||
|
- **address** (*Optional*, int): The I²C address of the driver.
|
||
|
Defaults to ``0x20``.
|
||
|
|
||
|
|
||
|
|
||
|
Pin configuration variables:
|
||
|
****************************
|
||
|
|
||
|
- **pca6416a** (**Required**, :ref:`config-id`): The id of the ``pca6416a`` component of the pin.
|
||
|
- **number** (**Required**, int): The pin number.
|
||
|
- **inverted** (*Optional*, boolean): If all read and written values
|
||
|
should be treated as inverted. Defaults to ``false``.
|
||
|
- **mode** (*Optional*, string): A pin mode to set for the pin at. One of ``INPUT`` or ``OUTPUT``.
|
||
|
|
||
|
|
||
|
See Also
|
||
|
--------
|
||
|
|
||
|
- :ref:`i2c`
|
||
|
- :doc:`switch/gpio`
|
||
|
- :doc:`binary_sensor/gpio`
|
||
|
- `PCA6416A datasheet <https://www.nxp.com/docs/en/data-sheet/PCA6416A.pdf>`__
|
||
|
- `PCAL6416A datasheet <https://www.nxp.com/docs/en/data-sheet/PCAL6416A.pdf>`__
|
||
|
- :apiref:`pca6416a/pca6416a.h`
|
||
|
- :ghedit:`Edit`
|