-
Notifications
You must be signed in to change notification settings - Fork 7.6k
I2C Fail 3.2.0 #11228
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I also see strange behavior on the I2c bus. Serial debug is disabled, but I get the message - i2c.master: i2c transaction timeout detected. Full log: E (1124) i2c.master: I2C transaction timeout detected |
Pleas provide full information and minimal compilable code example |
I am also experiencing this issue. It occurred after Updating Arduino IDE to 2.3.5 from 2.3.4. The ESP IDF also updated at this time. I had never seen this error previously. |
@lucasssvaz I noticed some changes attributed to you in the most recent update, any chances that is what’s causing the issue? test(wokwi): Add I2C Master test and enable GPIO and PSRAM tests by @lucasssvaz in #10848 test(i2c): Add test to scan bus by @lucasssvaz in #11022 test(i2c): Do not use delta as Wokwi timing can be inconsistent by @lucasssvaz in #11080 |
@MarksWizard These PRs are related only to our I2C test in the CI. It does not affect how I2C works in any way. |
After a bunch of testing, and even more hair pulling... I think it ended up being a wiring issue for me. I finally got code to run without the error, but it would still be nice if that message didn’t spam the serial like it does. |
I see the same issue, but I can confirm that it does not seem to be a wiring issue. |
Please list devices and libraries that you use with them, so that we can try to replicate any of the confirmed non-wiring issues. |
If everything is wired correctly, the sketch runs fine. If you disconnect a single wire from the OLED and reboot it will trigger the issue. It’s not specifically related to the OLED though, the issue seems to occur when you initialize an I2C device that isn’t connected. Unfortunately the solution isn’t simply “check your wiring”, because this completely eliminates the ability to test code “headless” without a sensor or screen attached. Often times I test code on just an unwired board just to make sure everything is working correctly before I upload to the actual device. Previous to the ESP update, typical initialization code would just tell you the sensor wasn’t present and would maybe report something like -127 or whatever, which is perfectly fine when I’m testing something that doesn’t actually need the sensor to be present. Now it spams the serial with the error messages and the official ESP IDE I2C_oled example I tested caused the device into a boot/crash loop. I can get it to trigger using the code below, it should trigger before printing “Wire Started” if you don’t have an I2C device connected and should run fine if you do.
|
@MarksWizard so this is rather a logging issue. Your terminal gets flooded when there is no device. This I would say is oK. You should check if the device is there and not issue any more I2C transactions. That would stop the logs. I understand this is change in behavior, but that change comes from ESP-IDF's driver and not from Arduino, so we can not control it (other than blank stop it and not allow any logs, which is also not a good idea). I am looking for a case where everything was working before and is no longer working at all with the new driver and proper wiring. |
@me-no-dev |
@HanksSaloon sure! Please also give some basic info of the setup. What devices you have connected, how do you manage communication with them and pointers to what should we look at in the traces |
@me-no-dev first thanks for all of your help with this, and everything you do on the other projects.. I would not be able to play with these things without all of the hard work you have contributed. I understand that it’s not an issue with Arduino, since the ESP IDF example code causes the issue. With the new update they changed some I2C stuff and added these error messages I guess. However it’s bad code behavior as there is no rate limit, flag or anything to limit the error messages. In the ESP IDF example it causes the device to boot/crash loop, which I can’t imagine is the preferred behavior if a simple I2C device becomes disconnected. Your suggestion to not send any I2C if not connected seems absurd? So before every screen refresh or sensor read, I need to check that the actual device is present? That would add 100’s of lines of code to my project. This issue breaks 1000’s of example code found online that doesn’t involve those checks. EDIT: actually this is not possible, since initializing the sensor is what causes the issue.. and we don’t know if it’s present before we try to initialize. I have not been able to progress my own code because I have been trying to deal with this issue. Unfortunately I feel like in trying initially determine and explain the issue I made things confusing. Now that I know exactly where the issue lies, can you please help me properly explain this to the ESP devs? |
Ok, here goes: Hardware I/O DEVICE ; Type ; address; I2C-ch; Library All libraries have been slightly modified, but only to the extent of adding or removing some interface routines. Physically, all circuits are on the same 100x100mm PCB, except for the ACS37800 which is located about 8 meters away. Standard #includes are To explain the analyzer outputs: The RTC-module sends a 1Hz interrupt signal to pin D25. The interrupt handling routine couldn't be simpler, it just increases the value of a semaphore. Takes minimum of time. The semaphore is then processed elsewhere in the S process. Both processes poll their I2C channel regularly, process S once every second, process R according to it's own internal logic. Finally, the samples: At first, the two outputs seem very similar and there is no clear explanation to what the problem is in 3.2.0. In 3.2.0 SCL is released much later. Compare these examples: I haven't had time to check the standard if there's a time limit when the SCL must be released after the data is sent, but as a delayed SCL release also delays the ACK/NACK response from the slave it seems that the ESP (ver 3.2.0) doesn't understand where the response comes from and therefore logs an error condition. |
@HanksSaloon awesome work, thanks for helping to get this resolved. Can you post all of the above info in the issue opened on the ESP GitHub? Mythbuster5 has been asking for the logic analyzer stuff which I can’t provide. |
@HanksSaloon How to open the DMS file in your zip. Or it's not dma, because I download from mac. So the question is how to open that file? Or what's the correct extention name? |
Got it. |
0001-fix-i2c-optimization-performance-on-esp32.txt @HanksSaloon I have generated patch for shorten the time between last byte and stop. If your every transaction data is smaller than 63 byte (include address byte), you can try this. However, data in one transaction is larger than 63 bytes still have some problem, I still need time for debugging. Thank you. @me-no-dev PTAL, and please help to share a method how to patch idf code in ardiuno environment if needed. Thanks. |
@mythbuster5 @me-no-dev |
@mythbuster5 here is how the issue is manifesting for me in Arduino IDE IMG_6624.mov |
@MarksWizard @mythbuster5 That's good to know. |
library - https://github.com/enjoyneering/SCD30_I2C The sensor is very slow at startup - it takes about 2 seconds to warm up. It also requires 150 ms of clock stretching at 100 kHz due to self-calibration from time to time. |
@enjoyneering Okay(?) |
I also see strange behavior on the I2c bus. Serial debug is disabled, but I get the message - i2c.master: i2c transaction timeout detected. Full log: E (1124) i2c.master: I2C transaction timeout detected |
I rolled back to Arduino 2.3.4 and installed the esp board manager [v3.1.3 based on ESP-IDF v5.3] As you can see the issue doesn’t exist here. THIS IS HOW I WOULD PREFER THE CODE TO WORK! IMG_6627.mov |
Board
ESP32 - WROOM
Device Description
Custom ESE32 Wroom .
Hardware Configuration
GPIO 33,32, Wire library.
Version
v3.2.0
IDE Name
ARD
Operating System
Windows 11
Flash frequency
40
PSRAM enabled
yes
Upload speed
921600
Description
Compare to 3.1.3
3.2.0 Reported with 2 issues :
1-Executing i2c call time increase.
2-Deadlock [I2C hardware NACK detected] .
Sketch
Debug Message
Other Steps to Reproduce
No response
I have checked existing issues, online documentation and the Troubleshooting Guide
The text was updated successfully, but these errors were encountered: