-
Notifications
You must be signed in to change notification settings - Fork 7.5k
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
Latest update has broken i2c support #6333
Comments
I pulled an older version of the core from an old laptop that had not auto-updated, and the code all compiles and works fine again. Seems like this latest update broke something in the i2C library. |
I am using the following function to scan I2C and do not have any issues finding devices. It's not any different than yours: void scanI2C(){
uint8_t devices, error, address;
Serial.println("Scanning for I2C devices...");
devices = 0;
for(address = 0x01; address < 0x7f; address++){
Wire.setClock(100000);
Wire.beginTransmission(address);
error = Wire.endTransmission();
if (error == 0){
devices++;
Serial.printf("I2C device found at address 0x%02X\n", address);
} else if(error == 4){
Serial.printf("Error at address 0x%02X\n", address);
} else if(error == 5){
Serial.printf("Timeout at address 0x%02X\n", address);
} else if(error != 2){
Serial.printf("Unknown error %u at address 0x%02X\n", error, address);
}
}
Serial.printf("%u I2C devices found\n", devices);
} |
Which version is that "older" core? We have recently switched to use the ESP-IDF driver for I2C |
I'm not sure which version was on my old laptop. I believe it was from around November last year. The hardware I'm loading the code on has not changed in 6 months. It was working fine up until I tried to load the exact same firmware onto some more boards, and the code could no longer see any i2C devices (e.g. PCF8563 clock chip). As soon as I recompiled with the older core, it worked again as usual. |
In case it helps, I am running the ESP32 at 2.8V, and using 4K7 pullups on the i2C pins. The i2C peripherals are all low speed, so the pullups don't cause issues. |
I2C works for project Tasmota. Currently using a build which is a few commits newer than the released v2.0.2. Tasmota is installed in many thousands devices where a lot I2C sensors are connected. If there would be a general problem with I2C we would have many issues opened in Tasmota github. There is no issue open with I2C. |
Ok thanks, I'll remain on the older version for now and test the next release of the core to see if it's resolved. Is there any way to prevent Arduino from auto-updating? |
You mention the new I2C implementation being "more restrictive", is there any documentation on what changed? I'm having the same problem with some I2C code I wrote to interface with a servo driver (not using Wire.h). |
You can find newly written documentation about I2C here: https://docs.espressif.com/projects/arduino-esp32/en/latest/api/i2c.html |
Is there any documentation on what has changed between versions that is breaking compatibility? As Arduino auto-updates to this version, it means I'm currently having to keep copying the older core across so I can run my code without all of the i2c devices failing to work. |
The relevant PR #5683 |
Thank you for your answer. All I can find relating to this issue is "your Arduino library is written wrong use a different one". However, I'm not using an Arduino library at all for my I2C, only ESP-IDF's native I2C functions, and am having the same issue. As far as I can tell, everything I have written matches up with the ESP-IDF documentation and provided I2C examples. The code works as expected on an older version of esp32-arduino (1.0.4) but fails on the latest version. Any pointers on what I (and all these library devs apparently) are doing "against the spec" would be appreciated. |
i am using esp32 and arduino as components, with ds3231 using i2c. upgrading from 4.3.2 to 4.4 causing the i2c arduino lib not working. There is details logged, but does not indicates error during initialization. Somehow the init pass with out error but communication to i2c failed. i will try again and provide the logs. |
what devices are you guys using? |
We use the ds3231 too. Using our own (small) customized driver it works well with esp8266, esp32, esp32c3, esp32s2 |
Hi @me-no-dev, 4.4 arduino as component. ESP32 devkit v4 Wire.begin(SDA, SCL, 100000); [ 31][E][esp32-hal-i2c-slave.c:224] i2cSlaveInit(): invalid pins sda=22, scl=-96 this is the init issue, after init during the wire transfer it sometime responding sometime is not. i have to open back the project later to be exact. but i did not see error at the console. something related to i2c slave. need to revisit debug and set to verbose if i had time. thanks. |
try |
@Smashcat Did you solve your problem? |
@VojtechBartoska Not really. I think the developers have just decided it's not their fault that things broke after they made changes, and everyone else has just been using it wrong so they won't fix it. I'm just keeping a copy of the last working release for now, so I can replace any future updates that break other things. This isn't the first time they've broken the Arduino libs with an update, which is why I guessed what had happened when previously working code suddenly stopped working. I think the previous time they broke it, the build process failed completely, and so people had to link to the development branch while they fixed it... |
@Smashcat It's actually not exactly as this. I2C was refactored too use high level ESP-IDF API. this brings a lot of benefits and it's more solid solution for Arduino core also to keep it up to date. Unfortunately some third-party libraries which are not maintained by us will need some changes to work with this refactored API and we are not able to cover this issue. We wrote an extensive documentation which was also mentioned above and we will try to help you with your problem as much as possible. So if you can provide more info what exactly is not working, what you have tried and so on, it will help to move this issue forward. |
I think the issue is that the Arduino IDE automatically updates the ESP core when it checks at startup. There is no indication this has happened to the user, and so people will just notice that things are suddenly broken. It's not obvious why they're broken, or that they should search through the documentation here to find the cause. The issue is that it breaks the standard Ardunio i2C library - at least in version 1.8.16 that I have here (from sept 2021 I think). Maybe it would have been better to keep the old version as an option - "i2c-compat" or something so people could migrate, and also should some compile time errors, or something to indicate there's a problem with how the new library is being used if possible? Anyway, I am just staying with the old version - it seems to work fine with i2c, so not sure why I'd need to change over to a new version. Thanks. |
this work! |
Can I consider this solved? |
I'm closing this issue as solved. If you still face some issues, please reopen it. Thanks! |
Board
ESP32 custom board.
Device Description
Custom board with ESP32 VROOM castellated module, although the problem likely affects all ESP32 variants.
Hardware Configuration
Various devices, including i2C
Version
latest master
IDE Name
Arduino
Operating System
Windows
Flash frequency
80mhz
PSRAM enabled
no
Upload speed
921600
Description
Since the latest update (that Arduino pulls in automatically) i2C no longer works on the module.
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: