From 4b5f24a1d655d0f8fe99252891138b83a37fe6e6 Mon Sep 17 00:00:00 2001 From: Mat931 <49403702+Mat931@users.noreply.github.com> Date: Mon, 1 May 2023 04:00:24 +0000 Subject: [PATCH] Add PCA6416A (#2834) Co-authored-by: Jesse Hills <3060199+jesserockz@users.noreply.github.com> --- components/pca6416a.rst | 103 ++++++++++++++++++++++++++++++++++++++++ images/pca6416a.svg | 1 + index.rst | 1 + 3 files changed, 105 insertions(+) create mode 100644 components/pca6416a.rst create mode 100644 images/pca6416a.svg diff --git a/components/pca6416a.rst b/components/pca6416a.rst new file mode 100644 index 000000000..8b6038b28 --- /dev/null +++ b/components/pca6416a.rst @@ -0,0 +1,103 @@ +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 ` 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 ` 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 `__ +- `PCAL6416A datasheet `__ +- :apiref:`pca6416a/pca6416a.h` +- :ghedit:`Edit` diff --git a/images/pca6416a.svg b/images/pca6416a.svg new file mode 100644 index 000000000..67c5a3723 --- /dev/null +++ b/images/pca6416a.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/index.rst b/index.rst index 08416c28d..d4feb29cc 100644 --- a/index.rst +++ b/index.rst @@ -770,6 +770,7 @@ Miscellaneous Components Servo, components/servo, servo.svg Sprinkler, components/sprinkler, sprinkler-variant.svg + PCA6416A I/O Expander, components/pca6416a, pca6416a.svg PCA9554 I/O Expander, components/pca9554, pca9554a.jpg PCF8574 I/O Expander, components/pcf8574, pcf8574.jpg MCP230XX I/O Expander - I²C Bus, components/mcp230xx, mcp230xx.svg