← All parts

MCP23017 16-bit I/O Expander

MCP23017

Microchipinterface io display

The MCP23017 is a 16-bit I/O expander that communicates via an I2C interface. It provides two 8-bit bidirectional ports, allowing microcontrollers to easily add more general-purpose input/output pins.

In stock

Specifications

13
Operating Voltage
1.8 to 5.5 V
Standby Current Max
1 µA
Supply Current Max
1 mA
Interface
I2C
I2c Clock Speed Max
1.7 MHz
Operating Temperature Range
-40 to +125 °C
Package
28-pin QFN, 28-pin SOIC, 28-pin SPDIP, 28-pin SSOP
Number Of Io Pins
16
Output Current Per Pin Sink Max
25 mA
Output Current Per Pin Source Max
25 mA
I2c Bus Capacitive Loading Max
400 pF
Gpio Output Capacitive Loading Max
50 pF
I2c Address Pins
3

Pinout

28
PinNameFunctionsNotes
1GPB0
GPIO
Bidirectional I/O pin for Port B.
2GPB1
GPIO
Bidirectional I/O pin for Port B.
3GPB2
GPIO
Bidirectional I/O pin for Port B.
4GPB3
GPIO
Bidirectional I/O pin for Port B.
5GPB4
GPIO
Bidirectional I/O pin for Port B.
6GPB5
GPIO
Bidirectional I/O pin for Port B.
7GPB6
GPIO
Bidirectional I/O pin for Port B.
8GPB7
GPIO
Bidirectional I/O pin for Port B.
9VDD
POWER
Power supply voltage.
10VSS
GND
Ground reference.
11A0
Hardware address pin 0. Must be externally biased.
12A1
Hardware address pin 1. Must be externally biased.
13A2
Hardware address pin 2. Must be externally biased.
14RESET
Hardware reset input. Must be externally biased.
15INTB
GPIO
Interrupt output for Port B. Configurable polarity/open-drain.
16INTA
GPIO
Interrupt output for Port A. Configurable polarity/open-drain.
17GPA0
GPIO
Bidirectional I/O pin for Port A.
18GPA1
GPIO
Bidirectional I/O pin for Port A.
19GPA2
GPIO
Bidirectional I/O pin for Port A.
20GPA3
GPIO
Bidirectional I/O pin for Port A.
21GPA4
GPIO
Bidirectional I/O pin for Port A.
22GPA5
GPIO
Bidirectional I/O pin for Port A.
23GPA6
GPIO
Bidirectional I/O pin for Port A.
24GPA7
GPIO
Bidirectional I/O pin for Port A.
25SCL
I2C
I2C Serial Clock input.
26SDA
I2C
I2C Serial Data I/O.
27NC
No Connect.
28NC
No Connect.

Interactive pinout

Highlight:
MCP23017

Click a pin to copy its name · tap a tag above to spotlight a bus.

Starter code

Community starter examples — minimal, unofficial, and provided to get you wiring fast. Verify against the manufacturer datasheet before relying on them.

Arduino (C++)

Arduino library: Adafruit MCP23017 Arduino Library

arduino
// MCP23017 16-bit I2C I/O expander — community starter example
#include <Adafruit_MCP23X17.h>

Adafruit_MCP23X17 mcp;

void setup() {
  Serial.begin(115200);
  if (!mcp.begin_I2C(0x20)) { Serial.println("MCP23017 not found"); while (1) delay(10); }
  mcp.pinMode(0, OUTPUT);          // port A, pin 0
  mcp.pinMode(8, INPUT_PULLUP);    // port B, pin 0
}

void loop() {
  mcp.digitalWrite(0, HIGH);
  delay(300);
  mcp.digitalWrite(0, LOW);
  delay(300);
  Serial.println(mcp.digitalRead(8));
}

MicroPython

MicroPython library: mcp23017 (mcauser/micropython-mcp23017)

python
# MCP23017 I2C I/O expander (ESP32) — community starter example
# lib: mcauser/micropython-mcp23017 (mcp23017.py on the board)
from machine import Pin, I2C
from mcp23017 import MCP23017
import time

i2c = I2C(0, scl=Pin(22), sda=Pin(21))
mcp = MCP23017(i2c, 0x20)

mcp[0].output()        # GPA0 as output
while True:
    mcp[0].value(1); time.sleep(0.3)
    mcp[0].value(0); time.sleep(0.3)

Wiring

PinArduino Uno R3ESP32 DevKitC (WROOM-32)Notes
VDD+5V3V31.8-5.5 V
VSSGNDGND
SDAA4/SDAGPIO21
SCLA5/SCLGPIO22
A0/A1/A2--Tie to set address 0x20-0x27
RESET--Tie to VDD (active-low reset)

Typical uses

  • 16 extra GPIO over I2C
  • Button matrices and LED banks with interrupts

Related parts

6