esphome-docs/components/ch422g.rst
2024-09-02 11:57:36 +10:00

68 lines
2.1 KiB
ReStructuredText

CH422G I/O Expander
====================
.. seo::
:description: Instructions for setting up CH422G digital port expanders in ESPHome.
:image: ch422g.svg
The CH422G component allows you to use the **CH422G** I/O expander in ESPHome.
It uses an :ref:`I²C Bus <i2c>` for communication.
Once configured, you can use any of the 8 available GPIO pins for your projects.
Within ESPHome they can be used in place of internal GPIO pins in many of ESPHome's components such as the GPIO Binary Sensor or GPIO Switch. They are not usable for PWM or other situations requiring an internal GPIO pin.
.. note::
This I/O Expander chip is used in the *Waveshare ESP32-S3-Touch-LCD-4.3*
.. code-block:: yaml
# Example configuration entry
ch422g:
- id: ch422g_hub
address: 0x24
# Individual outputs
switch:
- platform: gpio
name: CH422G Pin 0
pin:
ch422g: ch422g_hub
number: 0
mode:
output: true
inverted: false
Configuration variables:
************************
- **id** (**Required**, :ref:`config-id`): The id to use for this ``ch422g`` component.
- **address** (*Optional*, int): The I²C address of the driver.
Defaults to ``0x24``.
- **restore_value** (*Optional*, boolean): Writes default flags on setup, overriding values from chips cache.
Defaults to ``false``.
Pin configuration variables:
****************************
- **ch422g** (**Required**, :ref:`config-id`): The id of the ``ch422g`` component of the pin.
- **number** (**Required**, int): The pin number. Valid numbers are 0-7.
- **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 the pin at. One of ``INPUT`` or ``OUTPUT``.
See Also
--------
- :ref:`i2c`
- :doc:`switch/gpio`
- :doc:`binary_sensor/gpio`
- `CH422G datasheet <https://www.wch-ic.com/downloads/file/315.html?time=2024-07-29%2002:02:32&code=Fxex1sTRHysGLS6ALgh7PTOOZnAACY6KTQx05vzD>`__
- :apiref:`ch422g/ch422g.h`
- :ghedit:`Edit`