I2C problem still exists?

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
mackowiakp
Normal user
Posts: 527
Joined: 07 Jun 2018, 06:47
Location: Gdynia/Poland

I2C problem still exists?

#1 Post by mackowiakp » 29 Jan 2023, 23:42

The last time I made a new device based on ESP was over a year ago.
Now I would like to make a new one consisting of 5 devices controlled by I2C.
I have a question for colleagues about their experience with the stability of I2C operation over a longer period of time with FW versions newer than ESPEasy_ESP32_mega-20211224.
Do you still have the problem of bus hanging with more than one I2C device?
Once a TD-er wrote that the problem is difficult to diagnose because it occurs very rarely and it is difficult to determine the cause.
I agree with this statement because sometimes the device could work for half a year without a problem and then it could hang 3 times a day.
So what is the empirical status for today?

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: I2C problem still exists?

#2 Post by TD-er » 30 Jan 2023, 00:43

I think the automatic clearing of a stuck I2C bus does a good job.
Also I have been working hard on getting the timings better managed, so it is less likely the ESP is occupied in some piece of code where interrupts are temporary disabled.

But still, there is a number of possible causes for the I2C bus to get stuck:
- Some I2C devices really are more prone to get stuck compared to others, so it might be a "firmware issue" on the sensor itself. Meaning there can be differences among generations of the same sensor.
- Longer wires, or different lengths of wires for SCL and SDA make a signal more prone to timing issues.
- Twisting GND & SDA and GND & SCL does help reducing noise, but also may increase capacitance of the wires.
- To compensate for higher capacitance, you can either lower the I2C clock, or lower pull-up resistor values (or both)
- Add a small capactor (100 nF) close to the Vdd/GND at the sensor side to make sure voltage supplied to the sensor is as stable as possible.

The main issue seems to be that either the I2C master or the slave may still be waiting for a last bit to be sent or received.
So it is best to eliminate false pulses as much as possible, but as said, there are some I2C devices which are just more prone to these issues.

mackowiakp
Normal user
Posts: 527
Joined: 07 Jun 2018, 06:47
Location: Gdynia/Poland

Re: I2C problem still exists?

#3 Post by mackowiakp » 30 Jan 2023, 01:09

Thanks for the answer.
The problem of cable length in my case does not occur because everything is in one small housing. But I reduced the clock to 100kHz anyway.
As for the FW of the sensors themselves, it is of course difficult to say anything.
It's been working fine for 2 days now. What will happen next - we'll see.

User avatar
Ath
Normal user
Posts: 3416
Joined: 10 Jun 2018, 12:06
Location: NL

Re: I2C problem still exists?

#4 Post by Ath » 30 Jan 2023, 08:41

What exact I2C device(s) are you using for this setup?
/Ton (PayPal.me)

mackowiakp
Normal user
Posts: 527
Joined: 07 Jun 2018, 06:47
Location: Gdynia/Poland

Re: I2C problem still exists?

#5 Post by mackowiakp » 30 Jan 2023, 09:13

- 2 x PCF8574 (+8 relay board +8 optoisolated inputs board)
- SI7021 (Temp/Hum)
- BH1750 (Light)
- LCD display 2x16

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: I2C problem still exists?

#6 Post by TD-er » 30 Jan 2023, 10:54

I've seen reports from other users using PCF8574 who reported I2C issues.
So maybe it is worth looking into whether this one may be allowed to use clock stretching.

User avatar
Ath
Normal user
Posts: 3416
Joined: 10 Jun 2018, 12:06
Location: NL

Re: I2C problem still exists?

#7 Post by Ath » 30 Jan 2023, 11:40

And maybe check if there aren't too many pull-up resistors active on the bus, if they all have 4.7k or 10k PU, then net it will be less than 2k, that may be a bit low
/Ton (PayPal.me)

mackowiakp
Normal user
Posts: 527
Joined: 07 Jun 2018, 06:47
Location: Gdynia/Poland

Re: I2C problem still exists?

#8 Post by mackowiakp » 30 Jan 2023, 11:55

Ath wrote: 30 Jan 2023, 11:40 And maybe check if there aren't too many pull-up resistors active on the bus, if they all have 4.7k or 10k PU, then net it will be less than 2k, that may be a bit low
Will check

Post Reply

Who is online

Users browsing this forum: No registered users and 27 guests