MCP23017 Board
Make how-to guides like this one in a snap.
ms

matt shepherd

Created Jun 06, 2023

MCP23017 Board

The MCP23017 board offers a convenient solution for extending the number of GPIO pins available on a Raspberry Pi, making it particularly useful in robotics and other hardware projects that require multiple motors or modules. By utilizing this board, you can significantly simplify wiring complexities. For instance, instead of directly connecting a multitude of wires – such as 20 for a button matrix and LEDs – to the Raspberry Pi, you only need to connect 4 wires. This board also features a distinct I2C address, allowing the Raspberry Pi to identify and communicate with it, especially useful when multiple MCP23017 boards are in use. The standard address for these boards is typically 0x20 (or 20 in decimal). It's crucial to verify that the board is properly connected and that the Raspberry Pi can communicate with it. Instructions on how to check this connection and communication will be detailed below.

688
1

1. The MCP23017 Board

Great, let's include that detail:

This compact board is a real lifesaver, allowing us to directly solder the ribbon cables from the FM4's buttons and LEDs. Here’s the layout you’ll use: Connect the LED ribbon cable to Row A0-A7 and the button ribbon cable to Row B0-B7. It’s important to note that the two inner rows on the board are for ground. So, the very first wire of the button ribbon cable should connect to one of these ground rows. Following that, the second wire from the button ribbon should be connected to B0, as you can see in the image below.

Additionally, there are four more holes at the bottom left of the board for power, ground, SCL, and SDA. These provide power to the board and facilitate data transmission to the Raspberry Pi. This means you can manage up to 16 cables on the board with only 4 needing to connect to the Pi, keeping your setup neat and tidy. And the best part? All you need to do is desolder the ribbon cables from the old FM4 PCB and resolder them here. Simple and effective!

The MCP23017 Board
2

2. Wiring up the MCP23017 board

In this photo, you can see how the setup is organized on the MCP23017 board, making the wiring straightforward and clean. The two ribbon cables are meticulously soldered into rows A and B. Notice how the top first wire from the button ribbon is cleverly routed underneath and connected to a ground pin located just behind B0. This ensures a solid ground connection, which is essential for reliable button functionality.

Also visible are the individual wires in red, black, yellow, and green. These colors are typically used to denote specific connections:

- Red is generally for power (+V).

- Black usually signifies ground (-).

- Yellow often carries data signals, in this case, possibly the SCL (clock line for I2C communication).

- Green might be used for the SDA (data line for I2C communication).

This color-coding helps in quickly identifying the purpose of each wire, making troubleshooting and maintenance easier. The arrangement here maximizes the board’s capabilities while keeping the connections organized and accessible for any adjustments or diagnostics needed later.

Wiring up the MCP23017 board
3

3. Checking the I2C Address of the MCP23017

Once you have the 4 wires connected open up Putty or Terminus and ssh into the pi. Once you are connected to the pi run this short line of code to find your mcp23017 address to see if it's connected.

sudo i2cdetect -y 1

If all goes well and you have your wires connected properly then it should look like the image below, if not then you have got your sda and scl cables the wrong way around

If you have your LEDs and buttons connected properly and your mcp23017 is connected to the pi and giving the address 20, you should be good to give the pi a reboot and test your buttons. As long as the LED lights when a button is pressed then you have successfully connected everything.

You might need to swap a few cables around if the LED lights are on the wrong button etc etc.

4

4. Address 20

The beauty of these compact boards lies in their ability to connect multiple units together, each with a unique address. This feature is particularly useful in applications like drone building or robotics, where managing multiple components efficiently is key to performance and functionality.

Address 20
Well done!
Create how-to guides like this in a snap. Get Tango now.