Skip to content
Get started

PCA9554 I/O Expander

The PCA9554 component allows you to use a variety of I/O expanders in ESPHome that use the I²C Bus for communication. Once configured, you can use any of the IO pins (up to 16) with 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. Any option accepting a Pin Schema can theoretically be used, but some more complicated components that do communication through this I/O expander will not work.

PCA9554A I/O Expander chip

Set device: to the part in use. The PCAL parts add pull resistors, input latching and a selectable output drive strength on top of the plain I/O. At startup every PCAL pin is set as an input with its pull resistors disconnected, whatever the chip’s power-on state, before the configured pin modes are applied.

DeviceNumber of PinsI²C AddressFeatures
PCA953640x41I/O
PCA953480x20-0x27I/O
PCA9534A80x38-0x3FI/O
PCA953880x70-0x73I/O
PCA955480x20-0x27I/O
PCA9554A80x38-0x3FI/O
TCA955480x20-0x27I/O
PCA9535160x20-0x27I/O
PCA9555160x20-0x27I/O
TCA9535160x20-0x27I/O
TCA9555160x20-0x27I/O
PCAL953880x70-0x73I/O, pull up/down, latching, drive strength
PCAL9555160x20-0x27I/O, pull up/down, latching, drive strength

Devices that show a range of I²C addresses have an address that can be set using strapping pins on the device. Other expanders with the same register layout work when configured as the device with the same number of pins and features; set address: to match the part.

# Example configuration entry
pca9554:
- id: pca9554_hub
device: PCA9554
# Individual outputs
switch:
- platform: gpio
name: "PCA9554 Pin 2"
pin:
pca9554: pca9554_hub
number: 2
mode:
output: true
# Individual inputs
binary_sensor:
- platform: gpio
name: "PCA9554 Pin 3"
pin:
pca9554: pca9554_hub
number: 3
mode:
input: true
  • id (Required, ID): The id to use for this pca9554 component.
  • address (Optional, int): The I²C address of the device; see the table above. Defaults to the lowest address of the selected device, with all address pins low: 0x20 for most parts, 0x38 for the PCA9534A and PCA9554A, 0x41 for the PCA9536 and 0x70 for the PCA9538 and PCAL9538.
  • device (Optional, string): The part in use, one of the names in the table above. Defaults to PCA9554, or to the plain part with the pins given by pin_count.
  • pin_count (Optional, int): The number of pins of the expander, 4, 8 or 16, for configurations that predate device. With device set it may be left out; if both are given they must agree.
  • interrupt_pin (Optional, Pin Schema): The pin connected to the INT output of the expander. When configured, the component becomes interrupt-driven instead of polling: it only reads the chip when a pin actually changes state, significantly reducing I²C bus traffic and CPU usage. The INT pin is active-low and open-drain, so an external or internal pull-up resistor is required. Must be an internal GPIO pin (not another expander pin). On the PCAL parts every input pin asserts INT and every output pin is masked, so no per-pin setup is needed.
  • pca9554 (Required, ID): The id of the pca9554 component of the pin. Instead of an id, an address: can be given to select the hub by its I²C address; see Selecting an I2C Expander by Address.
  • number (Required, int): The pin number.
  • inverted (Optional, boolean): If all read and written values should be treated as inverted. Defaults to false.
  • mode (Optional, boolean(s)): Pin mode settings for the selected pin. Multiple pin modes may be selected by indenting them after the mode: entry in the YAML as shown in the example above. All devices support input and output. The PCAL parts additionally support pullup and pulldown; the plain parts reject them.
  • latch (Optional, boolean): PCAL parts only. Latch an input pin, see below. Defaults to false.
  • drive_strength (Optional, percentage): PCAL parts only. The drive strength of an output pin, one of 25%, 50%, 75% or 100%. Refer to the datasheet of your device for the recommended value. Defaults to 100%; the plain parts reject this option.

NOTE

Pin numbers start at 0. Datasheets for 16-pin parts may split the pins into two ports (P0_0..P0_7 and P1_0..P1_7). Port 0 is pins 0-7 and port 1 is pins 8-15, so P0_4 is pin 4 and P1_4 is pin 12.

input: Configure the pin as a high impedance input.

output: Configure the pin as a push/pull output.

pullup: If the pin is configured as an input enable a 100K pull up.

pulldown: If the pin is configured as an input enable a 100K pull down.

With latch: true a PCAL part holds a changed input level until the component reads the input register, which happens on every poll or, with interrupt_pin, when INT fires. INT stays asserted until that read. A pulse shorter than the poll interval is therefore still reported once instead of being missed; the level read back is the latched one, even if the pin has already returned to its original state.

pca9554:
- id: pcal9538_hub
device: PCAL9538
switch:
- platform: gpio
name: "PCAL9538 Pin 2"
pin:
pca9554: pcal9538_hub
number: 2
drive_strength: 50%
mode:
output: true
binary_sensor:
- platform: gpio
name: "PCAL9538 Pin 3"
pin:
pca9554: pcal9538_hub
number: 3
latch: true
mode:
input: true
pullup: true