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.
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.
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!
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?
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.
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?
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).
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.
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:
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.
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.
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.
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.
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.
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.
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