Add PCA6416A (#2834)

Co-authored-by: Jesse Hills <3060199+jesserockz@users.noreply.github.com>
This commit is contained in:
Mat931 2023-05-01 04:00:24 +00:00 committed by GitHub
parent 56a7d349ff
commit 4b5f24a1d6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 105 additions and 0 deletions

103
components/pca6416a.rst Normal file
View File

@ -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 <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`

1
images/pca6416a.svg Normal file
View File

@ -0,0 +1 @@
<svg width="518.776" height="25mm" viewBox="0 0 137.259 25" xmlns="http://www.w3.org/2000/svg"><path style="fill:#000;fill-opacity:1;stroke-width:.133497;stroke-miterlimit:4;stroke-dasharray:none" d="M5 0h127.26c2.77 0 5 2.23 5 5v15c0 2.77-2.23 5-5 5H5c-2.77 0-5-2.23-5-5V5c0-2.77 2.23-5 5-5Z"/><g aria-label="PCA6416A" style="font-size:10.5833px;line-height:1.25;letter-spacing:1.08479px;fill:#fffffc;stroke-width:.264583"><path d="M13.322 4.861q2.1 0 3.635.7 1.557.7 2.393 1.987.835 1.287.835 3.048 0 1.738-.835 3.048-.836 1.287-2.393 1.987-1.536.677-3.635.677h-3.184v4.358H6.48V4.86Zm-.204 8.467q1.648 0 2.506-.7.858-.722.858-2.032 0-1.332-.858-2.032-.858-.722-2.506-.722h-2.98v5.486zM31.656 20.937q-2.416 0-4.38-1.039-1.942-1.061-3.07-2.912-1.107-1.874-1.107-4.223 0-2.348 1.106-4.199 1.129-1.874 3.07-2.913 1.965-1.06 4.403-1.06 2.055 0 3.703.722 1.67.722 2.8 2.077l-2.348 2.167q-1.603-1.851-3.974-1.851-1.468 0-2.62.655-1.15.632-1.805 1.783-.632 1.152-.632 2.62 0 1.467.632 2.618.654 1.152 1.806 1.807 1.151.632 2.619.632 2.37 0 3.974-1.874l2.348 2.167q-1.13 1.378-2.8 2.1-1.67.723-3.725.723zM57.057 20.666h-3.838l-1.4-3.387H44.48l-1.4 3.387h-3.748L46.378 4.86h3.612zM48.16 8.45l-2.506 6.051h5.012zM66.157 10.754q1.512 0 2.754.61t1.965 1.738q.722 1.106.722 2.574 0 1.58-.79 2.777t-2.168 1.851q-1.354.633-3.025.633-3.319 0-5.193-2.032-1.874-2.032-1.874-5.803 0-2.687 1.016-4.606t2.822-2.912q1.83-.994 4.222-.994 1.265 0 2.416.294 1.174.27 1.987.79l-1.355 2.687q-1.174-.79-2.957-.79-2.01 0-3.184 1.174-1.174 1.174-1.264 3.409 1.4-1.4 3.906-1.4zm-.745 7.45q1.174 0 1.896-.631.745-.633.745-1.716 0-1.084-.745-1.716-.722-.655-1.941-.655-1.197 0-1.965.677-.767.655-.767 1.694 0 1.038.745 1.693t2.032.655zM85.913 14.366h2.574v2.98h-2.574v3.32h-3.567v-3.32h-8.512v-2.46l7.45-10.025h3.84l-6.91 9.505h4.245V11.41h3.454zM89.369 7.796V4.861h6.818v15.805H92.53V7.796ZM107.635 10.754q1.513 0 2.755.61t1.964 1.738q.723 1.106.723 2.574 0 1.58-.79 2.777t-2.168 1.851q-1.355.633-3.026.633-3.318 0-5.192-2.032t-1.874-5.803q0-2.687 1.016-4.606t2.822-2.912q1.829-.994 4.222-.994 1.264 0 2.416.294 1.174.27 1.987.79l-1.355 2.687q-1.174-.79-2.958-.79-2.01 0-3.183 1.174-1.174 1.174-1.265 3.409 1.4-1.4 3.906-1.4zm-.745 7.45q1.174 0 1.897-.631.745-.633.745-1.716 0-1.084-.745-1.716-.723-.655-1.942-.655-1.197 0-1.964.677-.768.655-.768 1.694 0 1.038.745 1.693t2.032.655zM132.224 20.666h-3.839l-1.4-3.387h-7.337l-1.4 3.387H114.5l7.044-15.805h3.613zM123.328 8.45l-2.506 6.051h5.012z" style="font-weight:700;font-size:22.5778px;font-family:Montserrat;-inkscape-font-specification:'Montserrat, Bold'"/></g></svg>

After

Width:  |  Height:  |  Size: 2.5 KiB

View File

@ -770,6 +770,7 @@ Miscellaneous Components
Servo, components/servo, servo.svg Servo, components/servo, servo.svg
Sprinkler, components/sprinkler, sprinkler-variant.svg Sprinkler, components/sprinkler, sprinkler-variant.svg
PCA6416A I/O Expander, components/pca6416a, pca6416a.svg
PCA9554 I/O Expander, components/pca9554, pca9554a.jpg PCA9554 I/O Expander, components/pca9554, pca9554a.jpg
PCF8574 I/O Expander, components/pcf8574, pcf8574.jpg PCF8574 I/O Expander, components/pcf8574, pcf8574.jpg
MCP230XX I/O Expander - I²C Bus, components/mcp230xx, mcp230xx.svg MCP230XX I/O Expander - I²C Bus, components/mcp230xx, mcp230xx.svg