Port Expnd
A port expander moves pin control onto a serial bus. Its register settings determine the supported input and output functions, but not every pin is equivalent: Microchip specifies GPA7 and GPB7 as output only on MCP23017. PCF8574 instead uses quasi-bidirectional ports, so its configuration and drive behaviour differ.
A host exchanges register or port data over the expander's serial interface. MCP23017 uses I²C and MCP23S17 uses SPI; these devices provide direction and pull-up configuration registers. PCF8574 instead uses quasi-bidirectional ports without the same direction-register model. Firmware must match the exact part.
In plain terms
A power bar for GPIO: you plug your microcontroller's two-wire I²C bus into the port expander and get 8 or 16 new I/O pins out, without running any more wires back to the main board.
Why designers use it
- Drive 16 LEDs from an ESP8266 that only has 11 usable GPIO pins.
- Read a 4×4 keypad matrix from a 2-wire I²C connection.
- Control relay outputs on an expansion board without consuming main processor pins.
- Add GPIO to a Pi Zero which has no spare GPIO after radio and display are connected.
Best for
- LED control
- Keypad input
- Relay boards
Key specifications
- Operating limits: Check the exact manufacturer's datasheet (A family name does not establish voltage, current, temperature or timing limits.)
- Pin assignment: Match the complete part and package code (A similar name or function does not guarantee the same wiring.)
- Mechanical fit: Use the exact package drawing (Check pad layout, dimensions and viewing direction before building.)
When not to use it
- When serial-bus latency cannot meet the application's timing requirements.
- When the device's output-current or input-voltage capability does not suit the attached circuit.
- When a pin function requires capabilities the selected expander does not provide. For example, the cited MCP23017 revision specifies GPA7 and GPB7 as output-only.
Common mistakes
- Assuming every port bit supports input mode. On MCP23017, GPA7 and GPB7 are output only; configure the supported pins and output latches deliberately at startup.
- Omitting I²C pull-up resistors or setting them too high for the long cable to the expander board.
Where you will find it
- A controller can use an MCP23017 to monitor switches on its input-capable pins and receive interrupt-on-change notifications, reducing constant polling. GPA7 and GPB7 must not be used for those inputs.
- An escape room prop controller uses PCF8574 port expanders to drive 32 LEDs and read 32 puzzle sensor inputs over a shared I²C bus: wiring a single Cat-5 cable between rooms carries power, ground, SDA, and SCL — four wires serving 64 I/O points.
- A control panel can use an SPI port expander such as MCP23S17 when that interface fits the host. Its serial pins and software protocol differ from the I²C MCP23017.
A short history
Port expanders let a serial bus serve more digital connections without adding a separate host pin for every signal. The design still depends on the device: register-controlled GPIO and quasi-bidirectional ports behave differently. Check direction restrictions, output current, addressing and interrupt behaviour instead of treating every expander as interchangeable.