2020-12-06 18:44:06 +01:00
MCP23Sxx I/O Expander
=====================
.. seo ::
2023-10-25 16:54:24 +02:00
:description: Instructions for setting up MCP23S08, MCP23S16 or MCP23S17 digital port expander in ESPHome. This series features exactly the same API as the MCP230xx I/O Expander (I²C)
2021-11-16 03:19:33 +01:00
:image: mcp230xx.svg
2020-12-06 18:44:06 +01:00
The Microchip MCP23Sxx series of general purpose, parallel I/O expansion for SPI bus applications.
2023-10-25 16:54:24 +02:00
This series features exactly the same API as the MCP230xx I/O Expander (I²C).
2020-12-06 18:44:06 +01:00
**Supported Variants :**
- :ref: `mcp23S08-label`
- :ref: `mcp23S17-label`
.. _mcp23S08-label:
2021-02-20 22:02:46 +01:00
MCP23S08 Component
------------------
2020-12-06 18:44:06 +01:00
The MCP23S08 component (`datasheet <http://ww1.microchip.com/downloads/en/DeviceDoc/MCP23008-MCP23S08-Data-Sheet-20001919F.pdf> `__ ,
`Digi-Key <https://www.digikey.com/product-detail/en/microchip-technology/MCP23S08-E-P/MCP23S08-E-P-ND/735954> `__ ) has 8 GPIOs that can be configured independently.
.. code-block :: yaml
# Example configuration entry
mcp23s08:
- id: 'mcp23s08_hub'
2024-05-07 07:40:12 +02:00
cs_pin: GPIOXX
2020-12-06 18:44:06 +01:00
deviceaddress: 0
# Individual outputs
switch:
- platform: gpio
name: "MCP23S08 Pin #0"
pin:
2021-03-07 20:24:08 +01:00
mcp23xxx: mcp23s08_hub
2020-12-06 18:44:06 +01:00
# Use pin number 0
number: 0
# One of INPUT, INPUT_PULLUP or OUTPUT
2021-11-03 19:55:26 +01:00
mode:
output: true
2021-07-28 23:56:11 +02:00
inverted: false
2020-12-06 18:44:06 +01:00
# Individual inputs
binary_sensor:
- platform: gpio
name: "MCP23S08 Pin #1"
pin:
2021-03-07 20:24:08 +01:00
mcp23xxx: mcp23s08_hub
2020-12-06 18:44:06 +01:00
# Use pin number 1
number: 1
# One of INPUT or INPUT_PULLUP
2021-11-03 19:55:26 +01:00
mode:
input: true
2021-07-28 23:56:11 +02:00
inverted: false
2020-12-06 18:44:06 +01:00
Configuration variables:
2021-03-11 19:31:31 +01:00
***** ***** ***** ***** *** *
2020-12-06 18:44:06 +01:00
- **id** (**Required** , :ref: `config-id` ): The id to use for this MCP23S08 component.
2021-02-07 17:35:39 +01:00
- **cs_pin** (**Required** , int): The SPI chip select pin to use
2020-12-06 18:44:06 +01:00
- **deviceaddress** (*Optional* , int): The address of the chip.
Defaults to `` 0 `` .
2021-11-28 19:57:01 +01:00
- **open_drain_interrupt** (*Optional* , boolean): Configure interrupt pins to open-drain mode.
2021-03-07 20:24:08 +01:00
Useful when the MCP23S08's power supply is greater than 3.3 volts. Note that these pins
will require pull-up resistors (to 3.3 volts) when this mode is enabled.
Pin Configuration Variables:
2021-03-11 19:31:31 +01:00
***** ***** ***** ***** ***** ***
2021-03-07 20:24:08 +01:00
- **mcp23xxx** (**Required** , :ref: `config-id` ): The id of the MCP23S08 component.
- **interrupt** (*Optional* ): Set this pin to trigger the INT pin on the component. Can be one of `` CHANGE `` , `` RISING `` , `` FALLING `` .
- All other options from :ref: `Pin Schema <config-pin_schema>`
2020-12-06 18:44:06 +01:00
.. _mcp23S17-label:
2021-02-20 22:02:46 +01:00
MCP23S17 Component
------------------
2020-12-06 18:44:06 +01:00
The MCP23S17 component allows you to use MCP23S17 I/O expanders
(`datasheet <http://ww1.microchip.com/downloads/en/DeviceDoc/20001952C.pdf> `__ ,
`Digi-Key <https://www.digikey.com/product-detail/en/microchip-technology/MCP23S17-E-SP/MCP23S17-E-SP-ND/894276> `__ ) in ESPHome.
It uses the :ref: `SPI Bus <spi>` for communication.
Once configured, you can use any of the 16 pins as
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.
.. code-block :: yaml
# Example configuration entry
mcp23s17:
- id: 'mcp23s17_hub'
2024-05-07 07:40:12 +02:00
cs_pin: GPIOXX
2020-12-06 18:44:06 +01:00
deviceaddress: 0
# Individual outputs
switch:
- platform: gpio
name: "MCP23S17 Pin #0"
pin:
2021-03-07 20:24:08 +01:00
mcp23xxx: mcp23s17_hub
2020-12-06 18:44:06 +01:00
# Use pin number 0
number: 0
2021-11-03 19:55:26 +01:00
mode:
output: true
2021-07-28 23:56:11 +02:00
inverted: false
2020-12-06 18:44:06 +01:00
# Individual inputs
binary_sensor:
- platform: gpio
name: "MCP23S17 Pin #1"
pin:
2021-03-07 20:24:08 +01:00
mcp23xxx: mcp23s17_hub
2020-12-06 18:44:06 +01:00
# Use pin number 1
number: 1
# One of INPUT or INPUT_PULLUP
2021-11-03 19:55:26 +01:00
mode:
input: true
pullup: true
2021-07-28 23:56:11 +02:00
inverted: false
2020-12-06 18:44:06 +01:00
Configuration variables:
2021-03-11 19:31:31 +01:00
***** ***** ***** ***** *** *
2020-12-06 18:44:06 +01:00
- **id** (**Required** , :ref: `config-id` ): The id to use for this MCP23S17 component.
2021-02-07 17:35:39 +01:00
- **cs_pin** (**Required** , int): The SPI chip select pin to use.
2020-12-06 18:44:06 +01:00
- **deviceaddress** (*Optional* , int): The address of the chip.
Defaults to `` 0 `` .
2021-11-28 19:57:01 +01:00
- **open_drain_interrupt** (*Optional* , boolean): Configure interrupt pins to open-drain mode.
2021-03-07 20:24:08 +01:00
Useful when the MCP23S17's power supply is greater than 3.3 volts. Note that these pins
will require pull-up resistors (to 3.3 volts) when this mode is enabled.
Pin Configuration Variables:
2021-03-11 19:31:31 +01:00
***** ***** ***** ***** ***** ***
2021-03-07 20:24:08 +01:00
- **mcp23xxx** (**Required** , :ref: `config-id` ): The id of the MCP23S17 component.
- **interrupt** (*Optional* ): Set this pin to trigger the port INT pin on the component. Can be one of `` CHANGE `` , `` RISING `` , `` FALLING `` .
- All other options from :ref: `Pin Schema <config-pin_schema>`
2020-12-06 18:44:06 +01:00
See Also
--------
- :ref: `spi`
- :doc: `switch/gpio`
- :doc: `binary_sensor/gpio`
- :apiref: `API Reference (MCP23S08) <mcp23S08/mcp23S08.h>`
- :apiref: `API Reference (MCP23S17) <mcp23S17/mcp23S17.h>`
- :ghedit: `Edit`