MCP23017 I/O Expander

The MCP23017 component allows you to use MCP23017 I/O expanders (datasheet, Adafruit) in ESPHome. It uses the I²C 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
mcp23017:
  - id: 'mcp23017_hub'
    address: 0x20

# Individual outputs
switch:
  - platform: gpio
    name: "MCP23017 Pin #0"
    pin:
      mcp23017: mcp23017_hub
      # Use pin number 0
      number: 0
      # One of INPUT, INPUT_PULLUP or OUTPUT
      mode: OUTPUT
      inverted: False

Configuration variables:

  • id (Required, ID): The id to use for this MCP23017 component.
  • address (Optional, int): The I²C address of the driver. Defaults to 0x21.