I2C bus possible problem.

Moderators: grovkillen, Stuntteam, TD-er

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

I2C bus possible problem.

#1 Post by mackowiakp » 30 Sep 2021, 16:09

Build: ESP_Easy_mega 20210820_custom_ESP8266_4M1M
I have two sensors connected to the I2C bus, BMP180 and BME680. BMP180 is installed in a winter garden (together with whole esp based unit) and BME680 outside the building. The wall in the garden is thin, hence the length of the wires 15 cm max.
Sometimes the sensors (either one or the other) give nonsensical measurements like a temperature of 250 C and/or a pressure of 2500 hPa.
I applied a rule which, if 5 consecutive measurements are senseless, performs a hard reset by shorting the RESET pin via transistor to ground using free GPIO.
Most cases it helps, but sometimes only the power cycle helps.
I try simply soft reset instead hard reset but the result is similar.
I set the max speed of the I2C bus equal to the min speed and now both speeds are 100kHz.
As far as I know there is a problem with I2C in this FW realese.
Is it possible to know if there is any planned bug fixing of the software sources in this regard?
Of course, I realize all we have some other activities besides ESP, so I'm just asking.

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

Re: I2C bus possible problem.

#2 Post by TD-er » 30 Sep 2021, 19:53

When this happens, do you see errors on all I2C addresses when performing an I2C scan?

About the planned fix for this issue (if it is what I think it is): https://github.com/letscontrolit/ESPEasy/pull/3678
I added some more code to it only a few days ago.
But it is really hard to test.

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

Re: I2C bus possible problem.

#3 Post by mackowiakp » 01 Oct 2021, 16:40

When this happens, do you see errors on all I2C addresses when performing an I2C scan?
in 95% cases, wrong measurements gives BMP180, in 5% - BME680. I did not notice the case of both wrong measurement results.
But it is really hard to test.
Yes. Such situation occur several times per day and then during next two weeks no issue.

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

Re: I2C bus possible problem.

#4 Post by mackowiakp » 12 Oct 2021, 16:26

Seams to work better since ESP_Easy_mega_20211005_custom_ESP8266_4M1M. No I2C malfunctions so far.

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

Re: I2C bus possible problem.

#5 Post by mackowiakp » 24 Oct 2021, 05:34

Still no I2C issues/errors. Look nice !!!

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

Re: I2C bus possible problem.

#6 Post by TD-er » 24 Oct 2021, 10:29

Great, so the reproduction of the issue has been made even harder :)

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

Re: I2C bus possible problem.

#7 Post by mackowiakp » 17 Dec 2021, 16:33

First I2C hangs after install FW ESP_Easy_mega_20211005_custom_ESP8266_4M1M.
Soft reboot does not help. Hardware reset via RST pin - too.
What helps, power cycle with 30 sec of power off.

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

Re: I2C bus possible problem.

#8 Post by mackowiakp » 31 Dec 2021, 12:09

Today after 5 days of using ESPEasy_ESP82xx_mega-20211224 (custom compilation), the I2C bus "lost" one of the two connected sensors.
Interestingly, one was working properly all the time.

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

Re: I2C bus possible problem.

#9 Post by Ath » 31 Dec 2021, 12:30

Interesting to know: Which sensors, which one 'survived' and which one failed, and what is the read-interval for both? And what did you do to 'revive' it, assuming it didn't revive itself with help from the 'Try clear I2C bus when stuck' setting?
/Ton (PayPal.me)

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

Re: I2C bus possible problem.

#10 Post by mackowiakp » 31 Dec 2021, 13:01

BMP085/180 'survived' (I2C addr - 0x77). read-interval - 120 sec
BME680 (I2C addr - 0x76) - no. read-interval - 120 sec
"Try clear I2C bus when stuck:: - checked
Soft reboot from console did not help.
Hard reset via GPIO5 connected to RST - also not.
Turning off the power for 4-5 minutes helped. It's a long time, but from the same power supply I power 3 other, completely different devices and, just in case, I waited for all electrolytic capacitors to discharge.

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

Re: I2C bus possible problem.

#11 Post by TD-er » 01 Jan 2022, 03:09

Another test you could have done is to swap in software the SDA and SCL pin and then swap them back.

If that fixes it, then it could be another clue on what is happening.

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

Re: I2C bus possible problem.

#12 Post by mackowiakp » 01 Jan 2022, 03:39

OK, will try if it happens next time.
But if so, is it possible to done this procedure from rule?

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

Re: I2C bus possible problem.

#13 Post by TD-er » 01 Jan 2022, 13:46

More like the procedure to get out of a stuck I2C bus now does this as last resort.
But maybe it should be the first to try.

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

Re: I2C bus possible problem.

#14 Post by mackowiakp » 02 Jan 2022, 01:42

OK, there's a problem with I2C again. I swapped SCL and SDA, saved it and changed it again (as You suggested). Unfortunately it didn't help.
As usual, it was helpful to turn off the power for a while, wait about 30 seconds for the electrolytic capacitors to discharge (there are lots of them "on the way"). And the unit start working properly.

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

Re: I2C bus possible problem.

#15 Post by TD-er » 02 Jan 2022, 02:10

Was there any I2C communication with the pins swapped?
That's needed to make this fix work, as it does start sending data which will be considered as clock pulses by the I2C slave devices.

One of the options to trigger some I2C communication is to perform an I2C scan.

But there has to be some communication. or else this will not "fix" anything.

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

Re: I2C bus possible problem.

#16 Post by mackowiakp » 02 Jan 2022, 02:34

Yes, there was communication. After swapping the SDA / SCL, I did a scan of the I2C devices and of course it showed no existence of any.
After restoring the previous settings, I did the I2C scan again and only the BMP180 was detected.
It is strange that one of the connected sensors is usually "lost". That is, either the BMP180 or (most often) the BME680.

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

Re: I2C bus possible problem.

#17 Post by TD-er » 02 Jan 2022, 12:54

OK, so one was found?
That means the high state of one of the sensors was resolved, or else the entire I2C bus would have still been hanging.

This means the fix does work, but still strange that the other sensor remains in some limbo state.

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

Re: I2C bus possible problem.

#18 Post by mackowiakp » 02 Jan 2022, 14:15

Yes, one found.
The fact is that in previous versions of the FW the entire bus was hanging and there was no WiFi access to the device.
I don't know if it has anything to do with it, but it did.
The device, however, "lived" because the LED that I connected specially was blinking and turned on/off (via rule) when the value from the sensor connected via UART was read.

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

Re: I2C bus possible problem.

#19 Post by TD-er » 02 Jan 2022, 14:27

Hmm strange that it also affected WiFi
Maybe the plugin for the failing device doesn't have proper timeout checks implemented.
Or maybe the I2C related read code has improved since the last SDK update?

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

Re: I2C bus possible problem.

#20 Post by mackowiakp » 02 Jan 2022, 14:40

In my case that it also affected WiFi in very old versions of FW.
Or strange readouts form sensors like 2500 hPa or so.
Now - i sensor is visible by ESP - readouts are correct.

Post Reply

Who is online

Users browsing this forum: No registered users and 37 guests