MCP23017 vs PCF8574: I2C GPIO Expanders Compared

Microcontrollers often run out of input and output pins. This is especially common when a project uses buttons, relays, LEDs, keypads, displays or several modules at the same time. I2C GPIO expanders solve this problem by adding extra digital pins through the I2C bus.

Two common I2C GPIO expanders are the MCP23017 and the PCF8574. Both can add extra digital I/O pins, but they work differently. The MCP23017 is a more full-featured 16-bit GPIO expander. The PCF8574 is a simpler 8-bit quasi-bidirectional I/O expander. This article compares them from a practical Arduino-compatible project point of view.

Why Use an I2C GPIO Expander?

An I2C GPIO expander lets a microcontroller control or read more digital signals using only the I2C bus.

  • Add more digital inputs
  • Add more digital outputs
  • Use buttons, LEDs and relays without using many MCU pins
  • Place I/O closer to a front panel or module
  • Share the I2C bus with displays, RTCs, sensors and ADCs

This is especially useful on compact boards such as XIAO modules, ESP32-C3 boards, RP2040 boards or other controllers with limited exposed pins.

PCF8574: Simple 8-Bit I/O Expander

The PCF8574 is a very common 8-bit I2C I/O expander. It is often used on I2C LCD backpacks, keypad modules and simple input/output boards.

  • 8 I/O pins
  • I2C interface
  • Simple and low-cost
  • Common on LCD backpacks
  • Often used for keypads and simple buttons
  • Quasi-bidirectional I/O behavior

The PCF8574 is useful when the project needs a few extra simple digital pins and the software can handle its I/O behavior.

MCP23017: Full-Featured 16-Bit GPIO Expander

The MCP23017 is a more advanced I2C GPIO expander with 16 I/O pins. It has more configuration options than the PCF8574 and is often better for larger or more structured digital I/O expansion.

  • 16 I/O pins
  • I2C interface
  • Configurable input and output direction
  • Internal pull-up options
  • Interrupt outputs
  • Good for larger button, LED and control projects

The MCP23017 is usually the better choice when the project needs many extra pins or more control over input/output behavior.

Main Comparison Table

Feature PCF8574 MCP23017
Number of I/O pins 8 16
Interface I2C I2C
I/O style Quasi-bidirectional Separate configurable input/output direction registers
Internal pull-ups Weak internal source behavior, not the same as normal configurable pull-ups Configurable internal pull-ups
Interrupt support Interrupt output available on many versions More advanced interrupt features
Best for Simple buttons, keypads, LCD backpacks and small I/O needs Larger I/O expansion, many buttons, LEDs, relays and structured control panels
Beginner simplicity Simple hardware, but I/O behavior can confuse beginners More registers, but behavior is more like normal GPIO
Main limitation Only 8 pins and quasi-bidirectional behavior More complex setup and larger chip/module

The Big Difference: Quasi-Bidirectional vs Direction Registers

The most important difference is how the pins behave.

The PCF8574 uses quasi-bidirectional pins. A pin is not configured with a normal input/output direction register like many microcontrollers. Instead, writing a HIGH allows the pin to act like an input with a weak internal current source, while writing LOW actively pulls the pin low.

The MCP23017 behaves more like normal microcontroller GPIO. Each pin can be configured as input or output with direction registers.

  • PCF8574 is simple, but its pin behavior is unusual
  • MCP23017 is more configurable and more familiar
  • PCF8574 works well for simple low-current tasks
  • MCP23017 is better when clear input/output direction matters

Pin Count: 8 vs 16

The PCF8574 provides 8 I/O pins. The MCP23017 provides 16 I/O pins. This alone can decide the choice.

I/O Need Better Choice Reason
4x4 keypad PCF8574 or MCP23017 Both can provide enough pins; PCF8574 is common for keypad modules
8 extra simple outputs PCF8574 Simple and low-cost if 8 pins are enough
16 extra GPIO pins MCP23017 Provides 16 pins from one chip
Many buttons and LEDs MCP23017 More pins and better input/output configuration

Inputs and Buttons

Both expanders can read buttons, switches and digital input signals. The difference is how pull-ups and input behavior are handled.

The MCP23017 has configurable pull-up resistors, which makes button wiring straightforward. A button can connect the pin to ground, and the internal pull-up keeps the input HIGH when the button is open.

The PCF8574 can also be used with buttons, but its quasi-bidirectional behavior must be understood. It is very common in keypad modules, but the software and wiring should match the chip behavior.

  • Use MCP23017 when many clean button inputs are needed
  • Use PCF8574 for simple button/keypad modules when the library supports it
  • Use external pull-ups or pull-downs when required by the circuit
  • Do not assume PCF8574 pins behave exactly like microcontroller GPIO pins

Outputs and LEDs

Both chips can drive simple digital outputs, but current limits matter. I/O expanders are not power drivers.

  • Use LEDs with proper current-limiting resistors
  • Check total chip current limits, not only per-pin current
  • Use transistor or MOSFET drivers for relays, solenoids and high-current loads
  • Do not power large LED arrays directly from expander pins

The MCP23017 is usually easier to understand for output control because pins are explicitly set as outputs. The PCF8574 can still work well for simple LED or LCD control, especially where modules are already designed around it.

Relays and Higher-Current Loads

Neither PCF8574 nor MCP23017 should directly drive relay coils, motors, solenoids or other higher-current loads. Use a suitable driver stage.

  • Use transistor or MOSFET drivers
  • Use flyback diodes for relay coils and solenoids
  • Use relay driver ICs when many relays are needed
  • Keep load power separate from logic power where appropriate
  • Use proper grounding and protection

The I/O expander provides logic control. The driver circuit handles the load current.

I2C Addressing

Both PCF8574 and MCP23017 chips are available with address pins, allowing multiple devices on the same I2C bus. The exact available addresses depend on the chip version and module wiring.

  • Check the module address jumpers or solder pads
  • Use an I2C scanner to find connected devices
  • Watch for address conflicts with displays, sensors and RTC modules
  • Use an I2C multiplexer if many devices have fixed conflicting addresses

Address flexibility matters in modular systems where several I2C devices share the same bus.

I2C Bus Speed and Length

GPIO expanders can share the I2C bus with other modules, but bus wiring still matters.

  • Keep I2C wires reasonably short
  • Use suitable pull-up resistors
  • Reduce I2C speed if wiring is long or noisy
  • Avoid running I2C wires next to motor or relay wiring
  • Use good connectors and a solid ground connection

If a front panel is far away from the controller, I2C may not always be the best interface without careful design.

Interrupts

Interrupt outputs allow an I/O expander to notify the microcontroller when an input changes. This can be useful when the controller should not constantly poll the expander.

The MCP23017 has more advanced interrupt configuration than the PCF8574. This can matter for button panels, keypads and low-power projects.

  • Interrupts can reduce polling
  • Useful for waking a microcontroller from sleep
  • Useful for button panels
  • MCP23017 offers more interrupt configuration options

For simple projects, polling over I2C may be enough. For larger or lower-power systems, interrupts can be useful.

LCD Backpacks and PCF8574

The PCF8574 is very common on I2C backpacks for HD44780-compatible character LCDs. In that role, it is not being used as a general-purpose expander by the user. It simply converts I2C commands into the parallel control signals needed by the LCD.

  • Common on 1602 and 2004 LCD I2C backpacks
  • Reduces LCD wiring to SDA, SCL, VCC and GND
  • Usually handled by LCD library code
  • Address may vary between backpacks

For LCD backpacks, the PCF8574 is a practical and proven solution.

Keypads and PCF8574

The PCF8574 is also commonly used with matrix keypads. A 4x4 keypad needs 8 signals, which matches the 8 pins of the PCF8574 well.

  • Good fit for 4x4 keypad modules
  • Uses only I2C plus power
  • Works well with suitable keypad libraries
  • Simple and low-cost

For a keypad-only module, the PCF8574 can be a very good choice.

MCP23017 for Larger Control Panels

The MCP23017 is attractive when a project has many buttons, LEDs, switches or control lines. Its 16 pins and normal direction registers make larger panels easier to organize.

  • Many buttons and switches
  • Several LEDs or logic outputs
  • Mixed input/output projects
  • Interrupt-based button panels
  • Modular I/O expansion

For anything larger than a simple keypad or LCD backpack, the MCP23017 often feels more flexible.

Voltage Compatibility

GPIO expander modules must match the voltage levels used in the system. Some modules are designed for 5V, some for 3.3V, and some can work across a range depending on the chip and pull-ups.

  • Check the chip supply voltage range
  • Check the I2C pull-up voltage
  • Do not pull a 3.3V microcontroller I2C bus up to 5V unless the pins are 5V tolerant
  • Use level shifting when mixing 3.3V and 5V systems

I2C pull-up voltage is especially important because all devices on the bus share SDA and SCL.

Software Support

Both chips are well supported, but in different ways.

  • PCF8574 support is common in LCD backpack and keypad libraries
  • MCP23017 has good GPIO expander libraries
  • MCP23017 code may look more like normal pinMode/digitalWrite logic depending on library
  • PCF8574 libraries must account for quasi-bidirectional behavior

For beginners, using a library designed specifically for the module is important. Raw register handling is possible, but it is not necessary for most projects.

When to Use PCF8574

  • You need 8 simple I/O pins
  • You are using an I2C LCD backpack
  • You are using a 4x4 keypad module
  • Cost and simplicity matter
  • The module and library already support the PCF8574

The PCF8574 is a good choice for small, simple I/O expansion and common LCD/keypad modules.

When to Use MCP23017

  • You need up to 16 extra GPIO pins
  • You want normal input/output direction configuration
  • You need internal pull-ups for many inputs
  • You need better interrupt options
  • You are building a larger button, LED or control panel
  • You want a more full-featured GPIO expander

The MCP23017 is usually the better choice for larger or more serious I/O expansion.

Choosing by Project Type

Project Type Good Choice Reason
I2C character LCD backpack PCF8574 Very common and well supported for this use
4x4 keypad PCF8574 or MCP23017 PCF8574 is common and enough; MCP23017 gives more flexibility
Many buttons and LEDs MCP23017 More pins and better GPIO-style configuration
Relay control logic MCP23017 plus driver stage Good pin count, but relay coils still need external drivers
Small low-cost I/O expansion PCF8574 Simple and inexpensive when 8 pins are enough
Structured 16-bit digital I/O module MCP23017 Designed for full-featured 16-bit expansion

Common Mistakes

  • Assuming PCF8574 pins behave exactly like normal microcontroller GPIO pins
  • Trying to drive relays or large loads directly from expander pins
  • Ignoring total chip current limits
  • Forgetting I2C address conflicts
  • Pulling a 3.3V I2C bus up to 5V by accident
  • Using long noisy I2C wiring without reducing speed or improving layout
  • Choosing PCF8574 for a project that really needs 16 well-controlled GPIO pins

Which GPIO Expander Should You Choose?

Need Best Choice Why
Lowest-cost simple 8-bit expansion PCF8574 Simple and common
16 extra GPIO pins MCP23017 Provides 16 configurable pins
LCD I2C backpack PCF8574 Very common and proven for HD44780 LCD backpacks
Button panel with interrupts MCP23017 Better interrupt and pull-up options
4x4 keypad only PCF8574 8 pins are enough and many keypad modules use it
Mixed inputs and outputs with clean configuration MCP23017 Direction registers make behavior clearer

When to Use Something Else

Sometimes a GPIO expander is not the best solution.

  • Use a shift register when only many outputs are needed and I2C is not required
  • Use a dedicated LED driver for many LEDs
  • Use a relay driver board for relay outputs
  • Use an I2C multiplexer if the real problem is address conflicts
  • Use a larger microcontroller if the project needs many fast GPIO signals

Conclusion

The PCF8574 and MCP23017 are both useful I2C GPIO expanders, but they are best suited for different levels of I/O expansion.

  • Choose the PCF8574 for simple 8-bit expansion, LCD backpacks, keypads and low-cost modules.
  • Choose the MCP23017 for 16-bit expansion, larger control panels, mixed inputs and outputs, pull-ups and better interrupt handling.

The PCF8574 is simple and common, but its quasi-bidirectional pins can surprise beginners. The MCP23017 is more configurable and usually better when the project needs GPIO expansion that behaves more like normal microcontroller pins.

Shopping Cart
Scroll to Top