Add more I/O ports to one Particle Photon

Hi guys

I need more I/O ports to the Photon board. Is it posible?
Can two Photon boards be connected via SPI communication for example, or can an extended board with more ports be connected?

Do you know some tricks or a product, that can handle this issue?

Try looking for I/O expanders. Something like this should work:


Try looking for the mcp23017 or mcp23008 ( 8 or 16 port ) which have SPI and I2c versions

Another vote for mcp23017 from me, its a wonderful I2C chip with 2 banks of 8 pins, supports in/out put and even has 2 interupt pins for medium speed inputs, generally though extended pins are not well suited for highspeed inputs.

Not sure what your requirements are (output?/inputs?)?

But I recommend you to stay away from the MCP23017 i2c… I have had nothing but trouble using it on the Photon.

The only firmware that where the MCP23017 is stable is 0.4.6. Anything lower will causes issues. And also the latest 0.4.7 (as of this post) has issues again. It will cause the Photon to lock up. I am hoping 0.4.8 resolves the issues…

If you can use a Shift Register:

Can someone who has used GPIO extenders or shift registers with the Photon make a comment here. I have a student who needs about 30 Digital Inputs to control a musical instrument.

@Moors7 link above has now been retired.

I have also found: which is I2C 16 bits and looks interesting. The MCP23017 seems to have mixed reviews from @Carsten4207 and @MORA

Another one but with only 8 bits

I am looking for 16 - 32 bit extenders that are easy to use like but I think this one might be hard to get working on the Photon.

Any suggestions?

I have a project that uses 2 MCP23017 chips over I2C (for a total of 32 extra GPIOs). They are used for both input and output and I make use of the interrupt pins for input alerts (rather than constant polling). That same project also has 32 8-bit shift registers controlled through some of the MCP23017 pins.

They have worked flawlessly for me with a Photon. In fact, the thing has been running a simulation for about 5 months now that involves sending around 40,000 bits per second down the shift register chain and have had no issues.

On a side note, you can get the chips cheaper from an electronics distributor, for example:

One thing I’d be wary of is using over I2C is make sure you don’t have any other I2C devices that require a slower I2C bus (at first I had an I2C LED that was supposed to work at 100k, but had to slow the I2C bus down to 70k for it to be reliable). I ended up throwing that thing away and writing my own LED driver with the MCP23017 pins which eliminated the I2C bus speed bottleneck (your I2C bus speed is global, not a per device basis, so you have to set it to the speed of the slowest device on the bus). So now I have I2C running at 400k.


Do you have the include files for the MCP23017 that work on the Photon. I have searched the libraries and the nearest I have found is for the MCP23008-I2C.H

@rocksetta, I published the Adafruit_MCP23017 library on the web IDE.

1 Like

Yes I see it now. Thanks @peekay123

1 Like

My issues with the MCP23017 seems to be the pullup resistors on the I2C line. @peekay123 Does this diagram look ok for a basic MCP23017

Anyone got any suggestions for adding a second MCP23017. I assume we set one of pin 15,16,17 to 3.3 V and then
mcp.begin(1); But which PIN 15, 16, 17 sets byte 1?

With a bare chip MCP23017 or MCP23008 you’ll need pull-up resistors on SDA and SCL.

A0, A1, and A2 form an 3-bit offset from the base address. The base address is 0x20 (I think), and if all three A lines are tied to GND, then the address is still 0x20 (offset 0). If you set A0=HIGH, then the address is 0x21. If A1=HIGH and A0=LOW, the address is 0x22. And so on to 0x27.


The pullups are the 4.7K at D1 and D0 in the above diagram.

That reminds me on another I2C device (an OLED) I did not have to use pullups when I used 3V3. Do you think that would apply here? The MCP23017 voltage range is 1.8V to 5.5V. If so then this diagram might work nicely

Not sure if the reset could be done with 3V3. Anyone know how the reset works?

Thanks @rickkas7 above arrangement would still need pullup resistors for both D1 and D0.

Most breakout boards including OLED displays and most of the boards from SparkFun and Adafruit have the pull-ups on the board. Any bare chip like this will likely need external pull-ups, either to 3V3 or VIN, depending on what you are powering it from.

The /RESET line can be tied to VIN in your case, or 3V3 if you’re powering from 3V3. The chip resets when powered up and it’s there in case you need to hardware reset it, but I’ve never had to.

The first section of my I2C tutorial explains some of the why you need pull-ups with I2C:


Really nice I2C tutorial @rickkas7

The “bar” across the top of the word RESET (or /Reset) indicates and active-low signal, so to reset a device you wouldn’t use 3.3V or 5V or whatever, but pull the pin to GND (which is always the same for any supply voltage :wink: )


Thanks @ScruffR and @rickkas7. I got my MCP23017 chip working and managed to test it using different bit addresses for PINS 15, 16, 17:grinning:

Almost forgot. Thanks @peekay123 for getting the Adafruit libraries working on the Photon.

1 Like