Cirkit Designer Logo
Cirkit Designer
Your all-in-one circuit design IDE
Home / 
Component Documentation

How to Use MCP23017: Examples, Pinouts, and Specs

Image of MCP23017
Cirkit Designer LogoDesign with MCP23017 in Cirkit Designer

Introduction

The MCP23017, manufactured by AzDelivery, is a 16-bit I/O expander that communicates with microcontrollers via the I2C interface. It provides an easy way to add up to 16 additional GPIO pins to your project, making it ideal for applications where the number of available I/O pins on a microcontroller is insufficient. The MCP23017 is highly versatile and can be used for both input and output operations, supporting features such as interrupt handling and pin direction control.

Explore Projects Built with MCP23017

Use Cirkit Designer to design, explore, and prototype these projects online. Some projects support real-time simulation. Click "Open Project" to start designing instantly!
MCP23017-Expanded I/O Interface with ADS1115 ADC and ESP32 Control
Image of door and window sensors: A project utilizing MCP23017 in a practical application
This circuit features two MCP23017 I/O expanders interfaced with multiple switches, allowing for the expansion of input capabilities. The MCP23017s are connected via I2C to an Olimex ESP32-EVB microcontroller, which likely manages the input states from the switches. Additionally, an Adafruit ADS1115 16-bit ADC is included, suggesting that some analog inputs are being monitored, with the ADC also interfaced with the ESP32 via I2C.
Cirkit Designer LogoOpen Project in Cirkit Designer
I2C-Controlled Relay Switching with ESP32 and MCP23017 for Home Automation
Image of Vloerverwarming: A project utilizing MCP23017 in a practical application
This circuit appears to be a control system utilizing two MCP23017 I/O expanders interfaced with an Olimex ESP32-EVB microcontroller via I2C communication, as indicated by the SDA and SCL connections with pull-up resistors. The MCP23017 expanders control an 8-channel relay module, allowing the microcontroller to switch various loads, potentially for home automation or industrial control. Additionally, there is an Adafruit ADS1115 16-bit ADC for analog signal measurement, and several heating actuators and a thermostat are connected, suggesting temperature control functionality.
Cirkit Designer LogoOpen Project in Cirkit Designer
ESP32-Based I2C Communication Hub with Multiplexer and Expander
Image of Lights: A project utilizing MCP23017 in a practical application
This circuit features an Olimex ESP32-EVB microcontroller unit (MCU) for processing and connectivity, interfaced with an MCP23017 I/O expander and an Adafruit TCA9548A I2C multiplexer to expand the number of I/O lines and allow multiple I2C devices to communicate with the MCU over the same bus. Pull-up resistors are connected to the I2C lines for proper bus operation, and both the MCP23017 and TCA9548A have their reset lines pulled high, likely for normal operation without external reset control.
Cirkit Designer LogoOpen Project in Cirkit Designer
ESP32-Based Vibration Motor Controller with I2C IO Expansion
Image of VIBRATYION: A project utilizing MCP23017 in a practical application
This circuit features an ESP32 Wroom Dev Kit microcontroller interfaced with an MCP23017 I/O expansion board via I2C communication, utilizing GPIO 21 and GPIO 22 for SDA and SCL lines, respectively. A vibration motor is controlled by an NPN transistor acting as a switch, with a diode for back EMF protection and a resistor to limit base current. The ESP32 can control the motor by sending signals to the MCP23017, which then interfaces with the transistor to turn the motor on or off.
Cirkit Designer LogoOpen Project in Cirkit Designer

Explore Projects Built with MCP23017

Use Cirkit Designer to design, explore, and prototype these projects online. Some projects support real-time simulation. Click "Open Project" to start designing instantly!
Image of door and window sensors: A project utilizing MCP23017 in a practical application
MCP23017-Expanded I/O Interface with ADS1115 ADC and ESP32 Control
This circuit features two MCP23017 I/O expanders interfaced with multiple switches, allowing for the expansion of input capabilities. The MCP23017s are connected via I2C to an Olimex ESP32-EVB microcontroller, which likely manages the input states from the switches. Additionally, an Adafruit ADS1115 16-bit ADC is included, suggesting that some analog inputs are being monitored, with the ADC also interfaced with the ESP32 via I2C.
Cirkit Designer LogoOpen Project in Cirkit Designer
Image of Vloerverwarming: A project utilizing MCP23017 in a practical application
I2C-Controlled Relay Switching with ESP32 and MCP23017 for Home Automation
This circuit appears to be a control system utilizing two MCP23017 I/O expanders interfaced with an Olimex ESP32-EVB microcontroller via I2C communication, as indicated by the SDA and SCL connections with pull-up resistors. The MCP23017 expanders control an 8-channel relay module, allowing the microcontroller to switch various loads, potentially for home automation or industrial control. Additionally, there is an Adafruit ADS1115 16-bit ADC for analog signal measurement, and several heating actuators and a thermostat are connected, suggesting temperature control functionality.
Cirkit Designer LogoOpen Project in Cirkit Designer
Image of Lights: A project utilizing MCP23017 in a practical application
ESP32-Based I2C Communication Hub with Multiplexer and Expander
This circuit features an Olimex ESP32-EVB microcontroller unit (MCU) for processing and connectivity, interfaced with an MCP23017 I/O expander and an Adafruit TCA9548A I2C multiplexer to expand the number of I/O lines and allow multiple I2C devices to communicate with the MCU over the same bus. Pull-up resistors are connected to the I2C lines for proper bus operation, and both the MCP23017 and TCA9548A have their reset lines pulled high, likely for normal operation without external reset control.
Cirkit Designer LogoOpen Project in Cirkit Designer
Image of VIBRATYION: A project utilizing MCP23017 in a practical application
ESP32-Based Vibration Motor Controller with I2C IO Expansion
This circuit features an ESP32 Wroom Dev Kit microcontroller interfaced with an MCP23017 I/O expansion board via I2C communication, utilizing GPIO 21 and GPIO 22 for SDA and SCL lines, respectively. A vibration motor is controlled by an NPN transistor acting as a switch, with a diode for back EMF protection and a resistor to limit base current. The ESP32 can control the motor by sending signals to the MCP23017, which then interfaces with the transistor to turn the motor on or off.
Cirkit Designer LogoOpen Project in Cirkit Designer

Common Applications and Use Cases

  • Expanding GPIO capabilities of microcontrollers like Arduino, ESP32, or Raspberry Pi.
  • Driving LEDs, relays, or other output devices.
  • Reading multiple switches, sensors, or other input devices.
  • Applications requiring interrupt-driven I/O for efficient processing.
  • Home automation, robotics, and industrial control systems.

Technical Specifications

Key Technical Details

  • Manufacturer Part ID: MCP23017
  • Interface: I2C (up to 1.7 MHz)
  • Operating Voltage: 1.8V to 5.5V
  • Maximum Current per Pin: 25 mA
  • Total GPIO Pins: 16 (divided into two 8-bit ports: PORTA and PORTB)
  • Interrupt Capability: Configurable interrupts for each pin
  • Addressing: 7-bit I2C address (configurable via 3 address pins, allowing up to 8 devices on the same bus)
  • Operating Temperature: -40°C to +85°C
  • Package: 28-pin DIP, SOIC, or SSOP

Pin Configuration and Descriptions

The MCP23017 has 28 pins, with the following configuration:

Pin Number Pin Name Description
1 GPA0 General Purpose I/O Pin 0 (PORTA)
2 GPA1 General Purpose I/O Pin 1 (PORTA)
3 GPA2 General Purpose I/O Pin 2 (PORTA)
4 GPA3 General Purpose I/O Pin 3 (PORTA)
5 GPA4 General Purpose I/O Pin 4 (PORTA)
6 GPA5 General Purpose I/O Pin 5 (PORTA)
7 GPA6 General Purpose I/O Pin 6 (PORTA)
8 GPA7 General Purpose I/O Pin 7 (PORTA)
9 VSS Ground (0V)
10 INTB Interrupt Output for PORTB
11 INTA Interrupt Output for PORTA
12 SCL I2C Clock Line
13 SDA I2C Data Line
14 A2 I2C Address Pin 2
15 A1 I2C Address Pin 1
16 A0 I2C Address Pin 0
17 RESET Active-Low Reset Input
18 VDD Power Supply (1.8V to 5.5V)
19 GPB0 General Purpose I/O Pin 0 (PORTB)
20 GPB1 General Purpose I/O Pin 1 (PORTB)
21 GPB2 General Purpose I/O Pin 2 (PORTB)
22 GPB3 General Purpose I/O Pin 3 (PORTB)
23 GPB4 General Purpose I/O Pin 4 (PORTB)
24 GPB5 General Purpose I/O Pin 5 (PORTB)
25 GPB6 General Purpose I/O Pin 6 (PORTB)
26 GPB7 General Purpose I/O Pin 7 (PORTB)
27 OSC1 Oscillator Input (optional, for external clock)
28 OSC2 Oscillator Output (optional, for external clock)

Usage Instructions

How to Use the MCP23017 in a Circuit

  1. Power Supply: Connect the VDD pin to a power source (1.8V to 5.5V) and the VSS pin to ground.
  2. I2C Connections: Connect the SCL and SDA pins to the corresponding I2C pins on your microcontroller. Use pull-up resistors (typically 4.7kΩ) on both lines.
  3. Address Configuration: Set the A0, A1, and A2 pins to either HIGH or LOW to configure the I2C address. This allows up to 8 MCP23017 devices on the same I2C bus.
  4. GPIO Configuration: Use the I2C interface to configure the direction of each GPIO pin (input or output) and set their initial states.
  5. Interrupts (Optional): If using interrupts, connect the INTA and/or INTB pins to interrupt-capable pins on your microcontroller.

Example: Using MCP23017 with Arduino UNO

Below is an example of how to use the MCP23017 with an Arduino UNO to control LEDs and read button inputs.

Circuit Setup

  • Connect the MCP23017's VDD to 5V and VSS to GND.
  • Connect SCL to Arduino's A5 and SDA to A4 (I2C pins on the UNO).
  • Use pull-up resistors (4.7kΩ) on the SCL and SDA lines.
  • Connect LEDs to PORTA pins (GPA0-GPA7) with current-limiting resistors.
  • Connect buttons to PORTB pins (GPB0-GPB7) with pull-down resistors.

Arduino Code

#include <Wire.h>
#include "Adafruit_MCP23017.h"

// Create an MCP23017 object
Adafruit_MCP23017 mcp;

void setup() {
  // Initialize I2C communication
  Wire.begin();
  
  // Initialize the MCP23017
  mcp.begin(); // Default address is 0x20
  
  // Configure PORTA as outputs for LEDs
  for (int i = 0; i < 8; i++) {
    mcp.pinMode(i, OUTPUT);
  }
  
  // Configure PORTB as inputs for buttons
  for (int i = 8; i < 16; i++) {
    mcp.pinMode(i, INPUT);
    mcp.pullUp(i, HIGH); // Enable internal pull-up resistors
  }
}

void loop() {
  // Read button states from PORTB
  for (int i = 8; i < 16; i++) {
    if (mcp.digitalRead(i) == LOW) { // Button pressed
      mcp.digitalWrite(i - 8, HIGH); // Turn on corresponding LED
    } else {
      mcp.digitalWrite(i - 8, LOW); // Turn off corresponding LED
    }
  }
}

Important Considerations and Best Practices

  • Use appropriate pull-up resistors on the I2C lines to ensure reliable communication.
  • Avoid exceeding the maximum current rating of 25 mA per pin.
  • If using multiple MCP23017 devices, ensure each has a unique I2C address.
  • Use decoupling capacitors (e.g., 0.1 µF) near the VDD pin to reduce noise.

Troubleshooting and FAQs

Common Issues and Solutions

  1. No Communication with MCP23017:

    • Ensure the I2C address matches the configuration of the A0, A1, and A2 pins.
    • Verify that pull-up resistors are connected to the SCL and SDA lines.
    • Check the wiring for loose or incorrect connections.
  2. GPIO Pins Not Responding:

    • Confirm that the pins are correctly configured as input or output.
    • Check for short circuits or excessive current draw on the pins.
  3. Interrupts Not Working:

    • Ensure the INTA/INTB pins are connected to interrupt-capable pins on the microcontroller.
    • Verify that interrupt conditions are correctly configured in the MCP23017 registers.

FAQs

  • Can I use the MCP23017 with 3.3V microcontrollers? Yes, the MCP23017 operates at voltages as low as 1.8V, making it compatible with 3.3V systems.

  • How many MCP23017 devices can I connect to a single I2C bus? Up to 8 devices can be connected by configuring the A0, A1, and A2 address pins.

  • What is the maximum I2C speed supported by the MCP23017? The MCP23017 supports I2C speeds up to 1.7 MHz.


This concludes the documentation for the MCP23017.