Cannot interact with MCP23008

I’m using the sketch found here:

I keep getting the message “MCP23008 Disconnected!”.

I have tried already the i2c Scan and found the device on the address 0x20 (default)

What am I doing wrong?

Thanks in advance

Change this line:




Thanks Travis,
I have already tried switching that line and still get the same error.
I’m sorry I mixed up the two sketches I’ve been trying to use.
When I use the one mentioned before ( MCP23008/MCP23008.ino at master · ncd-io/MCP23008 · GitHub ) I get error:

‘class MCP23008’ has no member named ‘setRelays’

And when I use the Arduino_Library_MCP23008_8Channel_Relay_Controller/MCP23008_Example.ino at master · ncdcommunity/Arduino_Library_MCP23008_8Channel_Relay_Controller · GitHub
I end up receiving the “MCP32008 Disconnected” error.

Update, I printed gotten from this command:
address = mcp.mcp_i2cAddress; and it shows 32.

Is that somehow related?

I believe there may be some confusion here. What is the processor you are using? Is it a Particle module? If so you need to make sure you are using this library:

This is the product that I’m using:

What module do you have plugged into the board? A Particle Photon?

I am not using any module, just trying to turn on/off the relays using the Espressif.

is its ESP32 or ESP8266.
is this ESP module made by ncd?

It is the ESP32 that comes with the product

tihs lib should work

Just tried again using the example.ino and got the error “MCP23008 Disconnected!”

This is my setup, and I tried the example.ino from the previous github link


Error I get from the example.ino


What I get when running the i2c scan sketch, I guess the i2c connection is not the issue

run this test code


Code running perfectly but I see no change on the board

run this test code
#include “Wire.h”
int i = 0;
void setup()
Wire.begin(); // wake up I2C bus
// Wire.begin(12,14); // wake up I2C bus esp8266
// set I/O pins to outputs
Wire.beginTransmission(0x20);//begins talking to the slave device
Wire.write(0x00); // IODIRA register
Wire.write(0x00); // set all of port A to outputs

void loop()
Wire.write(0x09); // GPIO PINS
Wire.write(255); // data which you want to write on gpio

Make sure you have a 12VDC power supply connected to the board. If only USB is connected the relays will not click on and off.

1 Like

I have tried the code on a brand new product and it is performing the same.
Code runs perfectly but it does not seem to interact with the relays.
I’m using a 12VDC power supply and also the USB for the ESP


In the Arduino IDE make sure the Board is set to Adafruit ESP32 Feather, then try flashing the code again. Let us know what you find.