2018-05-13 11:37:02 +02:00
|
|
|
PCF8574 I/O Expander
|
|
|
|
====================
|
|
|
|
|
2018-11-14 22:12:27 +01:00
|
|
|
.. seo::
|
2019-02-27 10:10:09 +01:00
|
|
|
:description: Instructions for setting up PCF8574 digital port expanders in ESPHome.
|
2018-11-14 22:12:27 +01:00
|
|
|
:image: pcf8574.jpg
|
|
|
|
|
2018-05-13 11:37:02 +02:00
|
|
|
The PCF8574 component allows you to use PCF8574 or PCF8575 I/O expanders
|
|
|
|
(`datasheet <http://www.ti.com/lit/ds/symlink/pcf8574.pdf>`__,
|
2020-05-10 21:27:59 +02:00
|
|
|
`SparkFun`_) in ESPHome. It uses :ref:`I²C Bus <i2c>` for communication.
|
2018-05-13 11:37:02 +02:00
|
|
|
|
|
|
|
Once configured, you can use any of the 8 pins (PCF8574) or 16 pins (PCF8575) as
|
2019-02-16 23:25:23 +01:00
|
|
|
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
|
2018-05-13 11:37:02 +02:00
|
|
|
binary sensor or GPIO switch.
|
|
|
|
|
2018-06-01 18:10:00 +02:00
|
|
|
Any option accepting a :ref:`Pin Schema <config-pin_schema>` can theoretically be used, but some more
|
2018-05-13 11:37:02 +02:00
|
|
|
complicated components that do communication through this I/O expander will
|
|
|
|
not work.
|
|
|
|
|
2018-06-01 18:10:00 +02:00
|
|
|
.. figure:: images/pcf8574-full.jpg
|
|
|
|
:align: center
|
2018-06-08 11:46:57 +02:00
|
|
|
:width: 80.0%
|
2018-05-13 11:37:02 +02:00
|
|
|
|
2018-06-08 11:46:57 +02:00
|
|
|
PCF8574 I/O Expander.
|
2018-05-13 11:37:02 +02:00
|
|
|
|
2020-05-10 21:27:59 +02:00
|
|
|
.. _SparkFun: https://www.sparkfun.com/products/retired/8130
|
2018-05-13 11:37:02 +02:00
|
|
|
|
2018-11-19 18:32:16 +01:00
|
|
|
.. code-block:: yaml
|
2018-05-13 11:37:02 +02:00
|
|
|
|
|
|
|
# Example configuration entry
|
|
|
|
pcf8574:
|
|
|
|
- id: 'pcf8574_hub'
|
|
|
|
address: 0x21
|
2021-07-28 23:56:11 +02:00
|
|
|
pcf8575: false
|
2018-05-13 11:37:02 +02:00
|
|
|
|
|
|
|
# Individual outputs
|
|
|
|
switch:
|
|
|
|
- platform: gpio
|
|
|
|
name: "PCF8574 Pin #0"
|
|
|
|
pin:
|
2018-05-14 21:15:49 +02:00
|
|
|
pcf8574: pcf8574_hub
|
|
|
|
# Use pin number 0
|
|
|
|
number: 0
|
2020-05-24 02:14:26 +02:00
|
|
|
# One of INPUT or OUTPUT
|
2021-11-03 19:55:26 +01:00
|
|
|
mode:
|
|
|
|
output: true
|
2021-07-28 23:56:11 +02:00
|
|
|
inverted: false
|
2018-05-13 11:37:02 +02:00
|
|
|
|
|
|
|
Configuration variables:
|
2021-03-09 02:53:04 +01:00
|
|
|
************************
|
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 PCF8574 component.
|
|
|
|
- **address** (*Optional*, int): The I²C address of the driver.
|
|
|
|
Defaults to ``0x21``.
|
2021-07-28 23:56:11 +02:00
|
|
|
- **pcf8575** (*Optional*, boolean): Whether this is a 16-pin PCF8575. Defaults to ``false``.
|
2018-05-13 11:37:02 +02:00
|
|
|
|
2021-03-09 02:53:04 +01:00
|
|
|
|
|
|
|
Pin configuration variables:
|
|
|
|
****************************
|
|
|
|
|
|
|
|
- **pcf8574** (**Required**, :ref:`config-id`): The id of the PCF8574 component of the pin.
|
2021-11-28 19:57:01 +01:00
|
|
|
- **number** (**Required**, int): The pin number.
|
2021-03-09 02:53:04 +01:00
|
|
|
- **inverted** (*Optional*, boolean): If all read and written values
|
2021-07-28 23:56:11 +02:00
|
|
|
should be treated as inverted. Defaults to ``false``.
|
2021-03-09 02:53:04 +01:00
|
|
|
- **mode** (*Optional*, string): A pin mode to set for the pin at. One of ``INPUT`` or ``OUTPUT``.
|
|
|
|
|
|
|
|
|
2018-06-01 18:10:00 +02:00
|
|
|
See Also
|
|
|
|
--------
|
|
|
|
|
|
|
|
- :ref:`i2c`
|
|
|
|
- :doc:`switch/gpio`
|
|
|
|
- :doc:`binary_sensor/gpio`
|
2018-08-24 22:44:01 +02:00
|
|
|
- `PCF8574 Arduino Library <https://github.com/skywodd/pcf8574_arduino_library>`__ by `Fabien Batteix <https://github.com/skywodd>`__
|
2019-05-12 22:44:59 +02:00
|
|
|
- :apiref:`pcf8574/pcf8574.h`
|
2019-02-07 13:54:45 +01:00
|
|
|
- :ghedit:`Edit`
|