Issue with MCP23017 that is not stable

I have a setup that uses an esp32, an I/O expander MCP23017 and an OLED. The MCP23017's I2C address is 0x27 and the OLED's is 0x3C. I am using the following libraries: MCP23017.h and SSD1306Wire.h. Everything worked perfect on the breadboard. However, when I ported the setup to a pcb, I have the following remarks during the testing:

  1. Sometimes (in almost 10% of the tests ) the boot of the esp32 takes almost 1 minute to complete. It gets stuck in the MCP23017 initialization in the setup().
 for (int i = 0; i < numRows; i++) {
        mcp23017.pinMode(rows[i], OUTPUT);
    }
   

when this happens, the MCP23017 works randomly (I mean mcp23017.digitalWrite does not reliably control the pins as expected.)

  1. the remaining 90% of the tests are fine: The boot of the esp32 is normal (no delay during initialization) and MCP23017 works perfect.
    I added a 0.1uf ceramic condenser between the MCP23017's VCC and GND and the issue seemed to be solved. But, after intense testing, unfortunately, I found that the issue happens rarely in almost 2% of the tests.
    Any advice is appreciated

Can you show the declaration of numRows and initialisation of the the rows[] array.

// I2C Address for MCP23017
#define MCP23017_I2C_ADDRESS 0x27  

MCP23017 mcp23017 = MCP23017(MCP23017_I2C_ADDRESS); 
/ Define MCP23017 pins for rows and columns
int rows[] = {6, 7, 8, 9, 10, 11, 12};  // Row pins: A6 -> 6, A7 -> 7, B0 -> 8, B1 -> 9, B2 -> 10, B3 -> 11, B4 -> 12
int cols[] = {2, 3, 4, 5};              // Column pins: A2 -> 2, A3 -> 3, A4 -> 4, A5 -> 5

// Number of rows and columns in the matrix
int numRows = 7;
int numCols = 4;

void setup() {
    
    // Initialize I2C and Serial Communication
    Wire.begin();
    Serial.begin(115200);
    mcp23017.init();
 // Configure MCP23017 pins as OUTPUT for rows
    for (int i = 0; i < numRows; i++) {
        mcp23017.pinMode(rows[i], OUTPUT);
    }
    // Configure MCP23017 pins as OUTPUT for columns
    for (int i = 0; i < numCols; i++) {
        mcp23017.pinMode(cols[i], OUTPUT);
    }
....

Were the leads to this short? If they are through hole capacitors long leads can cause the capacitor's resonant frequency to be lowered making it less effective.

The best way is to use surface mounting capacitors. These can be soldered between adjacent tracks in strip board.

1 Like

So obviously it's a hardware problem.
We need to see your schematics and board layout.

Thank you for this remark. In fact, I used hole capacitors. I will try with a surface mounting capacitor and revert.

The issue was solved by soldering a 0.1uf SMD capacitor between VCC and GND of mcp23107 (see picture). I will correct the PCB design . Thanks a million for your help.

1 Like

Hi,
How thin and long are your power supply tracks to the 23017?

Can you please post an EXPORTED jpg of your PCB pattern?

Thanks.. Tom.. :smiley: :+1: :coffee: :australia:

You couldn't have gotten it any closer? :expressionless:

a7

The image of your PCB shows that while it is soldered, it is not soldered very well. That is the soldered joint did not get hot enough. This might be due to the lack of power in your iron, or using lead free solder which needs to be hotter.

But the main problem might be that you are soldering pins that go straight to ground plane. This tends to suck all the heat out of your iron trying to heat up the ground plane, which by definition is quite a good heat sink.

There is a technique in laying out a PCB for getting round this, it is called "thermal relief". Search for images on this term, or / and see this link:-

It also appears the chip is not fully seated on the board.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.