MCP23Sxx I/O Expander

The Microchip MCP23Sxx series of general purpose, parallel I/O expansion for SPI bus applications. This series features exactly the same API as the MCP230xx I/O Expander (I²C).

Supported Variants :

MCP23S08 Component

The MCP23S08 component (datasheet, Digi-Key) has 8 GPIOs that can be configured independently.

# Example configuration entry
mcp23s08:
  - id: 'mcp23s08_hub'
    cs_pin: GPIOXX
    deviceaddress: 0

# Individual outputs
switch:
  - platform: gpio
    name: "MCP23S08 Pin #0"
    pin:
      mcp23xxx: mcp23s08_hub
      # Use pin number 0
      number: 0
      # One of INPUT, INPUT_PULLUP or OUTPUT
      mode:
        output: true
      inverted: false

# Individual inputs
binary_sensor:
  - platform: gpio
    name: "MCP23S08 Pin #1"
    pin:
      mcp23xxx: mcp23s08_hub
      # Use pin number 1
      number: 1
      # One of INPUT or INPUT_PULLUP
      mode:
        input: true
      inverted: false

Configuration variables:

  • id (Required, ID): The id to use for this MCP23S08 component.

  • cs_pin (Required, int): The SPI chip select pin to use

  • deviceaddress (Optional, int): The address of the chip. Defaults to 0.

  • open_drain_interrupt (Optional, boolean): Configure interrupt pins to open-drain mode. 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:

  • mcp23xxx (Required, 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 Pin Schema

MCP23S17 Component

The MCP23S17 component allows you to use MCP23S17 I/O expanders (datasheet, Digi-Key) in ESPHome. It uses the SPI Bus 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.

# Example configuration entry
mcp23s17:
  - id: 'mcp23s17_hub'
    cs_pin: GPIOXX
    deviceaddress: 0

# Individual outputs
switch:
  - platform: gpio
    name: "MCP23S17 Pin #0"
    pin:
      mcp23xxx: mcp23s17_hub
      # Use pin number 0
      number: 0
      mode:
        output: true
      inverted: false

# Individual inputs
binary_sensor:
  - platform: gpio
    name: "MCP23S17 Pin #1"
    pin:
      mcp23xxx: mcp23s17_hub
      # Use pin number 1
      number: 1
      # One of INPUT or INPUT_PULLUP
      mode:
        input: true
        pullup: true
      inverted: false

Configuration variables:

  • id (Required, ID): The id to use for this MCP23S17 component.

  • cs_pin (Required, int): The SPI chip select pin to use.

  • deviceaddress (Optional, int): The address of the chip. Defaults to 0.

  • open_drain_interrupt (Optional, boolean): Configure interrupt pins to open-drain mode. 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:

  • mcp23xxx (Required, 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 Pin Schema

See Also