MCP23017 I2C GPIO expander


The mcp23017 integration is the base for all related mcp23017 platforms in Home Assistant. There is no setup needed for the integration itself, for the platforms please check their corresponding sections.

For more details about the MCP23017 I2C I/O port expander you can find its datasheet here: MCP23017.

Binary Sensor

The mcp23017 binary sensor platform allows you to read sensor values from the I/O pins of your MCP23017 I2C I/O expander.

The pin numbers are from 0 to 15 where: 0-7 correspond to port A (A1-A8) and 8-15 to port B (B1-B8).

Configuration

To use the I/O pins of an mcp23017 connected to an I2C bus of your Raspberry Pi as binary sensors, add the following to your configuration.yaml file:

# Example configuration.yaml entry
binary_sensor:
  - platform: mcp23017
    i2c_address: 0x20
    pins:
      0: PIR Office
      1: PIR Bedroom

Configuration Variables

i2c_address

(integer)(Optional)

i2c address of MCP23017 chip.

Default value:

0x20

pins

(map)(Required)

List of used pins.

pin: name

(integer | string)(Required)

The pin numbers (from 0 to 15) and corresponding names.

scan_interval

(integer)(Optional)

Interval to scan for sensor state changes in seconds.

Default value:

15

invert_logic

(boolean)(Optional)

If true, inverts the output logic to ACTIVE LOW.

Default value:

false (ACTIVE HIGH)

pull_mode

(string)(Optional)

Type of internal pull resistor to use. Options are UP - pull-up resistor and DOWN - pull-down resistor.

Default value:

UP

MCP23017 only has internal pull-up resistors, if you want to use pull-down you will have to wire your own pull-down resistors.

Switch

The mcp23017 switch platform allows you to write to the I/O pins of your MCP23017 I2C I/O expander.

The pin numbers are from 0 to 15 where: 0-7 correspond to port A (A1-A8) and 8-15 to port B (B1-B8).

Configuration

To use the I/O pins of an mcp23017 connected to an I2C bus of your Raspberry Pi as switches, add the following to your configuration.yaml file:

# Example configuration.yaml entry
switch:
  - platform: mcp23017
    i2c_address: 0x20
    pins:
      11: Fan Office
      12: Light Desk

Configuration Variables

i2c_address

(integer)(Optional)

i2c address of MCP23017 chip.

Default value:

0x20

pins

(list)(Required)

Array of used pins.

pin

(integer | string)(Required)

The pin numbers (from 0 to 15) and corresponding names.

invert_logic

(boolean)(Optional)

If true, inverts the output logic to ACTIVE LOW.

Default value:

false