I've recently bought two more MCP23017-E's for a project, but after hooking them up to my Teensy 2.0 I couldn't get them to react to anything. Suspecting faulty hardware, I hooked them up to an old LCP1114, and got them running just fine. I've tried porting the code I used, which still gave no result.

I'm using the following code:

#include "Wire.h"
const byte device=0b01000000; //default addrress of IO chip

const byte IODIRA=0x00;
const byte IODIRB=0x01;

const byte GPIOA=0x12; //IO pins, port A
const byte GPIOB=0x13; //IO pins, port B
const byte OLATA=0x14;//O pins A
const byte OLATB=0x15;//O pins B

const byte GPPUA=0x0C; //pull up resistors ,port A
const byte GPPUB=0x0D; //pull up resistors ,port B

char iCounter = 0;

void setup() { 
  seti2cbyte(device,GPPUB,0xFF);  //enable pull-up resistors on port B

byte geti2cbyte(byte address, byte ptr) {
  Wire.requestFrom(address, 1); // request one byte of data from MCP20317
  byte inputs=Wire.read(); 
  return inputs; 

void seti2cbyte(byte address, byte ptr, byte value) {
  Wire.write(ptr); // set MCP23017 memory pointer to GPPUA address
  Wire.write(value); // enable pull up resistors

void loop() { 
  byte port_b = geti2cbyte(device,GPIOB); //get status of pins 21-28

I don't see a blinking LED, and port_b stays at 255 (or -1 I figured after reading the Wire.cpp)

I've tried different methods, even running SPI myself (setting pins high and low manually). The only difference I see is that the Teensy 2.0 is 5V, and the LCP1114 runs at 3.3V. The data sheet for the MCP23017-E states that it is also rated for 5V though.

Why does it seem like my MCP23017-E's won't work at 5V, while the data sheet states they should?

MCP23017-E datasheet

• Operating Voltage: - 1.8V to 5.5V @ -40°C to +85°C - 2.7V to 5.5V @ -40°C to +85°C - 4.5V to 5.5V @ -40°C to +125°C

Overview Close-up of Teensy. Yes, I did plug in the USB cable while testing.

  • Those solder connections look really bad in the last picture. On D1 you can see that half of the hole isn't even filled with solder. You should first try to resolder all pins and check continuity between GND,VCC,D0 and D1 to your chips. – Maximilian Gerhardt Apr 23 '18 at 18:43
  • @Maximilian Gerhardt I've checked the connections, they're fully functional. They're indeed not filled, since it's temporary, but there is no measurable resistance over the connections. – Daniël van den Berg Apr 23 '18 at 18:47
  • No I2C pullup resistors? Also did you run an I2C scanner sketch? – Mikael Patel Apr 23 '18 at 18:52
  • The I2C scanner will help determine if the device is connected correctly and verify the address. The address in the code seems to be a "bit" off. – Mikael Patel Apr 23 '18 at 18:59

You have the wrong device address. You've included the R/W bit in the address, which you shouldn't. An I2C address is only 7 bits, not 8. Drop one bit:

const byte device=0b0100000; //default addrress of IO chip
| improve this answer | |
  • HA!!! Thank you! I'm used to it just getting OR'd by libraries. – Daniël van den Berg Apr 24 '18 at 5:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.