MCP23017 IO Expansion Board, Expands 16 I/O Pins (CE07882)

This is a placeholder topic for “MCP23017 IO Expansion Board, Expands 16 I/O Pins” comments.

The MCP23017 IO Expansion Board expands 2 signal pins as 16 I/O pins based on the I2C bus, up to 8 MCP23017 IO Expansion Board can be used at the same time, providing up to 128 I/O pins, it is compatible with both 3.3V and 5V levels.

Read more

This board has VCC, GND, SDA, SCL, INT A, INT B in its interface – which is great.
However… I don’t quite understand. Why does every row of pins (top and bottom) ALSO have VCC and GND? What are those for?

When devices are connected to the expansion pins (either as inputs or outputs) they may require a VCC or GND connection in order to operate, so these connections are made available on the board. If the devices are provided with their own external VCC supply a ground connection is still required in order to ensure a common ground for all devices, and this connection is available on the board. By providing these connections it is possible to take advantage of I2C to locate the attached devices some distance from the MCU, all connected by just the one I2C cable.

2 Likes

Hi Tony,

Jeff is right on the money here, those pins are just for convenience, in the same way that servo driver boards break out VCC and GND for each servo, rather than making you split your supply rails yourself and connect them individually.

How were you looking to use this IO expander? Keen to hear more about your project!

1 Like

Oh I ordered THREE of those. I am building something insanely cool… I will let you know guys once it’s at least half a prototype ;D

2 Likes

It took me a while… I have finally connected one of them without soldering the address jumpers. I powered it up with 3.3V (tested with a multimetre). If I run lsmod, I see i2c_bcm2708 there in the list. The board has its light on, which I assume is a good sign.
However, when I try and run i2cdetect -a -y 1 I get absolutely nothing there detected.
Am I missing something? Could the i2c part of my Pi be fried?

1 Like

Hey Tony,

That’s no good! Have you tried to have a look into the kernel logs by using dmesg | grep i2c .to see if there is any issue there? It may show something that is fixable. Alternatively, send through a couple of photos of how you have it wired up so that we can have a look at it if there are any issues there.

Cheers,
Blayden

1 Like

I am an idiot!!! I just fixed it…
The key was in the power source. I figured that the multiplexer worked when powered by the PI directly. I thought: what the hell? Then I remember a friend of mine’s words: “Tony, make sure all grounds are connected together. Always!”. So… I did that, and guess what? Bingo!!!

But… does this mean that “ground” for the two different power sources (the USB C port and the other power supply) were too different, and there was no good “baseline” for the pins to work? Or… what does it really do, connecting the two grounds together?

Hi Tony,

Glad to hear you found the solution, often it’s the little things like this that can cause the biggest headaches.

The reason why all grounds need to be tied together in a circuit comes back to the way voltage works. Since voltage is a potential difference it is by definition between two points. This is easy when you have one common reference in the form of ground. If you have two separate grounds then the voltage between two points in the circuit becomes fuzzy and you may find that circuits “float” or change in potential with respect to each other.
This article goes into a bit of a deeper dive into the different kinds of grounds if you’re interested as often in PCB design there will be an analog ground and a digital ground. (Though even these are tied together at a specific point in most cases).

Waitm WHICH article?!?!?!? :smiley: I am interested!

Hi Tony,

Whoops, forgot to attach the links. Here they are!

1 Like

Hi All
Then you have that “other” ground for analog (dare I use that word) signals such as capacitive coupled audio which swing positive and negative WRT “ground” and needs a +/- supply.
This is a technique for a single supply where everything is level shifted to elevate the virtual “signal” ground to half VCC. This “ground” is used throughout the signal processing and is usually signified in schematics by a downward pointing triangle.
Just threw this into the mix to confuse the issue. BUT this technique is not confined to analog (there used it again) audio. It is quite common where for whatever reason (usually to enable a single supply to be used) the reference point has to be level shifted. It does not have to be half VCC but usually is.
Cheers Bob

2 Likes

I’m wondering if I can still use a digital display in conjunction with MCP23017 IO Expansion Board, Expands 16 I/O Pins | Waveshare | Core Electronics Australia

The display in using is Quad 14 Segment Alphanumeric Display Module | Jaycar Electronics

Thank you

Hi Steve, welcome to the forum!

That expander would be a good pick for a display that used a parallel interface (i.e. one bit/pin per segment), but the Jaycar one you linked works over I2C, a bus interface you can read more about here:
https://learn.sparkfun.com/tutorials/i2c

Whenever you use multiple of the same device on the same I2C bus, you need to do one of two things:

  1. Change the address - Some devices like our PiicoDev gear have switches or solder jumpers to change the address of that particular unit, that way you don’t get 4 peripherals yelling over each other in response to a single address.
  2. Use a Multiplexer (sometimes shortened to Mux) - These act as a middle-man between your controller and peripheral devices, like an operator at a phone exchange. You ask the mux to “put you through” to a particular I2C port/device. This is the one to go for if you don’t have switches or jumpers on your device to change the address.

Let me know if this spurs followup questions :slight_smile:

Hi James. Thanks for your email back I’ll be honest I’m a bit out of my depth on this one. Is there any chance you can recommend an MUX board I could buy from you?

So again just to make sure we are on the same page. I need to simultaneously run a screen over I2C and use 6 analog inputs.

If you have a part that would suffice I’d gladly grab it if not I think I’ll go for the uno MAX as that looks like it has enough inputs.

Cheers

Hey Steve,

I can have a look into a compatible MUX for you, can you give me an idea of which microcontroller you are looking to use in conjunction with this at the moment anyways? I can see what might be most appropriate with a bit more insight into everything currently going into this project.

Cheers,
Blayden

Thanks a lot for your reply.

I’m using an Arduino Uno r3 right now. It is wired up to 6 LEDs and 6 LDR. It’s a basic light game that I’m building for my nephew. Like a reaction time thing. I just really want to get the screen mentioned in my first email working so he can see his score and have a timer for how long a game lasts.

It was all going to plan until I worked out that the A4 and 5 pins are also wired to the CLK and data pins so I cannot use them in conjunction with one another.

Hey Steve,

Sounds like a project expansion problem, one problem we have all known far to well at some point. If you are looking to expand anymore on the game and add in extra features in future for him, it may be worth going with the mega. The Uno is a great board for projects but does lack a lot of specialised features.

Otherwise you may want to have a look into this 16-channel MUX as it could be helpful to get a few pins cleared up and usable.

Cheers,
Blayden

Does this board come with the header pins unsoldered - so that I can easily solder in screw terminals? Thanks!

Hi Roger
You might find the pin pitch is too close and the hole diameter too small to solder screw terminals directly.
The header pin hole pitch is 2.54mm and the “normal” screw terminal is 5.08mm.
You might find very small screw or “Wago” style spring connectors with a 2.54mm pitch if you browse Element 14 or RS Components but I don’t know as I have had no need to date.
Cheers Bob
PS: I had not looked (rap on knuckles) but it looks like Core stock small screw connectors with 2.54mm pin pitch. Don’t know about hole size but. Not a good idea to open out holes in boards as you will destroy the “vias” that connect top to bottom and if there are connections on both sides of the board this connection will be lost