i2c randombly fails

Posts: 29
Joined: Tue Jan 10, 2017 5:36 pm

Re: i2c randombly fails

Postby jesseb » Thu Jul 27, 2017 12:23 am

Sorry for the misunderstanding on what you were asking. My driver still works around them but I have not tested yet whether I need to work around them or not. I'll let you know when I get a chance to test it.

User avatar
Posts: 57
Joined: Mon Jan 16, 2017 8:12 am

Re: i2c randombly fails

Postby Jakobsen » Thu Jul 27, 2017 9:17 pm

Thanks - I have been look for that fix for a very long time - and even considering using a soft i2c driver.
No more random fails on i2c. Change from _FLASH to _RAM did the job.

Code: Select all

... ESP_ERROR_CHECK( esp_wifi_init(&cfg) ); ESP_ERROR_CHECK( esp_wifi_set_storage(WIFI_STORAGE_RAM) ); ESP_ERROR_CHECK( esp_wifi_set_mode(WIFI_MODE_STA) ); ...
Regards Jakobsen
Analog Digital IC designer / DevOps @ Merus Audio, Copenhagen, Denmark.
We do novel and best in class Audio amplifiers for consumer products.
Programmed assembler for C-64 back in 1980's, learned some electronics - hacking since then

Posts: 2056
Joined: Tue Dec 01, 2015 7:35 am

Re: i2c randombly fails

Postby WiFive » Thu Jul 27, 2017 10:34 pm

Wow that is strange WIFI_STORAGE_FLASH can break i2c.

Posts: 7
Joined: Mon Feb 13, 2017 8:57 pm

Re: i2c randombly fails

Postby Maq_aux » Fri Jul 28, 2017 3:44 pm


i really hoped that this fix is going to help me with my I2C problems (mainly the SCL gets stuck or keeps clocking forever sometimes in the first seconds after a power-on, only way to recover is a module reset). Once the I2C bus works for the first couple of seconds it seems to be stable for a long time so far.

Unfortunately i recognized that

Code: Select all

ESP_ERROR_CHECK( esp_wifi_set_storage(WIFI_STORAGE_RAM) );
is already used in my code. I am happy this fix improves some parts of the I2C part but probably there still are some more issues.


Posts: 58
Joined: Thu Jan 19, 2017 5:17 pm

Re: i2c randombly fails

Postby gregstewart90 » Fri Aug 04, 2017 9:19 pm

As Markus said, the problem still exists for me even with the wifi change. The SCL line clocks forever until I reset. The values I get back from my MCP23017 i2c device are wrong and take longer to get back than normal. I believe there is a fluctuation in the power or interference from relays close by which switch 120vac main lines. I can simulate the issue by pulling the i2c lines to ground for a second.

Posts: 27
Joined: Tue Dec 27, 2016 2:10 am

Re: i2c randombly fails

Postby ammaree » Fri Jan 26, 2018 7:10 pm

Hi @jesseb ,

Read your comments on the I2C driver and your simplified replacement. I am at wits end with the ESP32 and I2C, my situation is as follows:
* Custom designed hardware using genuine Rev1 WROOM modules

* 8x LEDs and 8x relays attached to an I2C GPIO extender.
* implementing soft PWM (fadeIn, On, FadeOut, Off) functionality in a dedicated task running at 1ms (i tick) intervals
* based on the specific timing and stage each bit is toggled on and off.

* DS2482-800 I2C to 1-Wire (8 channel ) bridge reading iButtons for access and resource control
* DS2482-800 is read every 1 sec (1000 ticks)

Originally I wrote each bit change (only changes) using an individual I2C write. Very quickly this crashed the I2C bus when all 16 actuators running. I then changed to buffer all bit changes for a full cycle of all 16 actuators, and then only write the full 16 bit-mapped GPIO states to the GPIO expander in a single 16 bit write.

This reduced I2C activity hugely, but I still on a completely irregular basis have the I2C bus freeze and the GPIOs/actuators go into random states.

My questions are as follows:
1) Have you had reasonable success with your simplified I2C driver?
2) If so, can you please share the latest version with me so I can try to port my actuator engine to run on your driver instead?

All feedback much appreciated,


Posts: 2
Joined: Sun Sep 16, 2018 12:36 am

Re: i2c randombly fails

Postby barth_bh » Sun Sep 16, 2018 12:49 am

I have the same problem, accidentally the esp32 transmission from MCP23017 hangs.
It stops working after some time - randomly. I have not found a solution still

Who is online

Users browsing this forum: carlosmilon and 13 guests