Skip to content
Buy 10+ on select items — save 10% auto-applied
Free US shipping on orders $35+
Order by 3pm ET — ships same-day from the US
Skip to main content

Arduino Uno MCP23017: Add 16 I2C GPIO Pins | ShillehTek

August 21, 2026 10 views

Arduino Uno MCP23017: Add 16 I2C GPIO Pins | ShillehTek
Project

Build an Arduino Uno MCP23017 I2C GPIO expander that adds 16 extra pins, then scale it into a DIN-rail industrial module using ShillehTek parts.

Intermediate (Advanced for t5 parts

Project Overview

Arduino Uno + MCP23017 I2C port expander: build and test a 16-channel GPIO expansion module over I2C, then scale the design into a DIN-rail-mounted, optocoupler-protected industrial board with status LEDs.

  • Time: Basics in 30 minutes; full industrial build over a weekend
  • Skill level: Intermediate (Advanced for the SMD build)
  • What you will build: A 16-channel I/O expander you control with two wires, plus the blueprint for a cabinet-ready automation board (5V or 24V powered).
DIN-rail style MCP23017 I2C GPIO expander module with 16 channels and status LEDs
The finished module: 16 protected I/O channels behind a single I2C connection.

Parts List

From ShillehTek

External

  • ULN2803A high-current driver, TLP291-4 optocouplers
  • MB2S bridge rectifier, XL1509-5.0 DC-DC converter, AMS1117-3.3 regulator
  • 2-layer PCB (103x60 mm), SMD passives, terminal blocks
  • 3D-printed DIN-rail enclosure (STL files in the original project)

Note: The MCP23017 has three address pins, allowing up to 8 expanders on one I2C bus. That is 128 extra I/O pins from two microcontroller pins.

Step-by-Step Guide

Step 1 - Why an I/O Expander

Goal: Understand the problem this solves.

What to do: Many automation projects run out of pins quickly: relays, sensors, indicators, and buttons add up. The MCP23017 adds 16 GPIO (two 8-bit ports, GPA and GPB) on the I2C bus, with per-pin direction, pull-ups, and interrupt support.

Your microcontroller can keep its own pins for timing-critical work and delegate the rest to the expander.

Expected result: A clear picture of where the expander fits in your designs.

Step 2 - Design the Industrial Version (Schematic)

Goal: See what separates a breakout from a cabinet-grade module.

What to do: The industrial design surrounds the MCP23017 with protection and drive circuitry: a bridge rectifier on the power entry (survives reversed wiring), a DC-DC converter accepting 5V or 24V cabinet power, TLP291-4 optocouplers isolating every input, and a ULN2803A Darlington array sinking real current on every output. DIP switches set the I2C address.

Industrial MCP23017 GPIO expander schematic showing bridge rectifier, DC-DC supply, optocouplers, and ULN2803A drivers
The full schematic: protected power entry, opto-isolated inputs, driven outputs.

Expected result: You know what each supporting IC contributes.

Step 3 - Lay Out the PCB Like a PLC

Goal: Route a board an electrician would recognize.

What to do: The 103x60 mm 2-layer layout follows industrial conventions: power entry top-left, outputs along the top edge, inputs along the bottom, I2C connectors bottom-right, and a status LED for all 16 channels. Export Gerbers and send them to any board house.

Top layer PCB layout for MCP23017 industrial expander with I/O terminals on edges and logic centered
Top layer: I/O along the edges, logic in the middle.
Bottom layer routing view of the MCP23017 industrial expander PCB
Bottom layer routing.

Expected result: Fab-ready Gerbers (or use the author's shared design files).

Step 4 - Assemble: Paste, Place, Reflow, Inspect

Goal: Populate the SMD board cleanly.

What to do: Apply solder paste through the stencil, place the SMD parts with tweezers, reflow on a hot plate (about 245 C peak), then hand-solder the through-hole terminal blocks. Finish with an isopropyl clean and a microscope pass for bridges.

Applying solder paste to an MCP23017 expander PCB using a stencil before reflow
Paste through the stencil…
Hand placing SMD parts on the MCP23017 industrial expander PCB before reflow
…components placed by hand…
Reflowing an MCP23017 expander PCB on a hot plate during SMD assembly
…reflowed on the hot plate…
Inspecting MCP23017 expander PCB solder joints under a microscope after reflow
…and inspected under magnification.

Expected result: A clean, bridge-free assembled board.

Step 5 - Test It from an Arduino

Goal: Drive all 16 channels over I2C.

What to do: Wire the board's I2C port to an Uno (SDA to A4, SCL to A5, plus GND). The same code also drives the ShillehTek pre-soldered breakout, so you can follow along without building the industrial board.

Install the Adafruit MCP23017 library and cycle the outputs:

Code:

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

Adafruit_MCP23017 expander;

void setup() {
  expander.begin(0);               // address offset 0 -> I2C 0x20
  for (int i = 8; i < 16; i++) {   // GPB0–GPB7 as outputs
    expander.pinMode(i, OUTPUT);
  }
}

void loop() {
  for (int i = 8; i < 16; i++) {   // chase the output LEDs
    expander.digitalWrite(i, HIGH);
    delay(150);
    expander.digitalWrite(i, LOW);
  }
}

A second test sketch mirrors the 8 inputs onto the 8 outputs. Flip any input and its output LED follows, proving every channel end to end.

Arduino Uno running an MCP23017 output-cycling test with LEDs indicating channel states
Output-cycling test driven by the Uno.
MCP23017 I2C address DIP switches used to configure multiple expanders on one bus
Address DIP switches: eight boards can share one bus.

Expected result: All 16 channels verified over two wires.

Step 6 - Mount It on the DIN Rail

Goal: Finish like a real automation product.

What to do: Place the board into the 3D-printed DIN-rail enclosure and clip it into the cabinet next to your PSU and PLC gear. Terminal blocks land the field wiring, and the I2C cable runs back to your controller.

MCP23017 industrial expander PCB installed inside a 3D-printed DIN-rail enclosure
Boxed in the printed enclosure.
Completed MCP23017 I2C GPIO expander clipped onto a DIN rail in an industrial style
Clipped onto the rail, like off-the-shelf automation kit.

Expected result: A cabinet-ready 16-channel I/O module.

Conclusion

The MCP23017 turns two I2C wires into 16 protected and indicated industrial-grade I/O channels. This build walks from Arduino Uno breakout-board testing to a reflowed, DIN-rail-mounted module suitable for a control cabinet.

Want the exact parts used in this build? Grab them from ShillehTek.com. If you want help customizing this project or building something for your product, check out our IoT consulting services.

Photo credit: images referenced from the original project by DIY GUY Chris on Hackster.io.