GPIO Extension Not Reliable

Hi All,

I'm working on industrial automation. Replacing to MC instead of PLC for minor automations. Completed few projects and are in production without any issues till now.

For all those previous automaions, I used ESP32-S3 with onboard GPIO's.
But as my new project requires more GPIO's like around 45, I tried to extend the pins refering to many videos and forums and used below modules through I2C but nothing are reliable.

MCP23017, PCF8574, PCF8575
Also trying, AW9523B & CH423

Let me clarify a thing.
I'm already using 3-ADS1115 ADC's and a DS3231 RTC in I2C bus.
As all GPIO extendors tend to use the same I2C protocol, I used the same port and also different I2C port by twowire.

Problem here is, when I connect them, the functionality is working great for 2 hrs continuously and stops detecting all the I2C devices.
As per the forum, I2C bus is weaker so I pulled up both SDA, SCL with diff resistors from 2.4kohm to 10kohm - no use.

After long trouble shooting,
I couldn't fix it. So desoldred the GPIO extendors from the 12C bus and the system backs to stable. Ofcourse replaced the extendor modules with new ones too. I believe using GPIO extendor in ESP32 is making the system unreliable.

So I request you all to suggest some reliable way to extend GPIO's and if someone faced this kind of issue and found the rootcause, please share here.

Perhaps the modules contain their own pullup resistors.
Check and remove excess.

Lacking more important information I'd suggest to use SPI extenders instead of I2C.

Ofcource I tried without resistors aswel.
Can you please suggest SPI GPIO Extendors?

To mention, I already using a Memory Shield Module via SPI.

This is an SPI port expander and similar to one of the I2C versions you have already tried: https://www.microchip.com/en-us/product/mcp23s17

However, I think you should look at why you get problems when using the I2C versions. You should post a schematic and show which modules you are currently using with I2C.

Long cables and too much load on the bus (multiple pullup resistors) can cause problems. A failure after 2 hours though sounds more like a memory leak or overflow somewhere.

1 Like

Agreed.
@murugesh_rcpilot For diagnosis, I'd like to see

  • Full code, properly formatted and in code tags, please.
  • Description of project
  • Schematic, including wire lengths, power schema, etc.
  • Power supply layout, wiring, and interconnection(I list this separately, as we so often receive a schematic that doesn't really show the critical stuff)
  • Description of application environs - industrial/commercial/residential, in a chassis/open air, beside a 230V 3 phase motor, etc. etc.

To be clear, you may not wish to provide all of this, but you risk inadequate/no solution if you don't share as much as you can. I run I2C with MCP23017(up to 8, total bus length < 1m and 2x Rpullups 4.7k) with LCD/OLED displays on that same bus, and I don't have any such stalls, so something's not right.

1 Like

Hi, I have ordered your suggested MCP23S17.
Once I receive it, will give it a try and update here.

And it is not exactly failing after 2hrs but also at random times.
If its a memory leak issue, after I restart, It should work fine untill memory full dump but its not.
Once it fails, the only way to get it work back is to reconnect the GPIO extendor's I2C wires.

Its not a memory leak issue as I already faced once and knew to fix by following
https://iotespresso.com/how-to-check-free-memory-in-esp32/

Thanks you for the interest.
I have a doubt, I2C works with communication lessthan 1m means? I have connected these extendors with 10cm wire x 2 pairs while other ADC and RTC are onboard. So wire distance doesn't matter here as its below 1m isn't it?

Actually, Its a 30K lines code (mostly intended to access HMI through UART) putup in multiple tabs. Please excuse me to validate SPI chip on priority.
I believe SPI is more reliable than I2C
Let me give it a try and back here.

Hi Guys,
After several try over GPIO extensions with
MCP23017, PCF8574, PCF8575, MCP23S17, 74HC165, 74HC595

The only reliable way for extension is using UART and control other MC's GPIO's.
Finally my project was relased into production.

Thanks you all for your time.