-
Notifications
You must be signed in to change notification settings - Fork 7.6k
Poor performance of 2.0.2 probably due to I2C #6553
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
Without a code sample, no help is possible. In general core 2.0.3-rc1 works well with i2c wifi and mqtt. We use all of this in our Project Tasmota and have instant mqtt message from connected i2c sensors. |
Hi, as already written it is not possible to share the code: it is a closed source project for the company I work with. Your comment makes me think that maybe the issue could be about the I2C libraries we use, something like they are not well compatible with the newer Arduino ESP32 versions.
Have you noticed any difference in performance switching between 2.0.0 and 2.0.2 (or 2.0.3-RC1)? Regards |
Hello @FStefanni, did you face same issue on 2.0.3-rc1? |
We have seen no noticable performance differences between all core versiins. |
@FStefanni we have switched to using ESP-IDF for I2C and because of that and also preventing threading issues, Wire now has a more strict requirements of how the API is being used. Many libraries do not use proper Wire calls and can end up in problems. |
Hi,
yes, same issues. @me-no-dev thank you for your reply. To me sounds warring that other people had I2C issues and just switched away from the Arduino layer... And if we switch to ESP-IDF, we have to write by hand the code of the sensors/peripherals libraries... not funny... Regards |
@FStefanni currently Arduino Wire is a thin layer on top of that same ESP-IDF API that you would use. The problem is that people have for a long time written libraries where they use Wire wrong. The most common thing is wrapping |
Hi, if I understand correctly, I can check for Wire.beginTransmission(...);
Wire.requestFrom(...);
Wire.endTransmission(); Is this what you correct? Or is the opposite, i.e. it must not be enclosed? Thank you, |
Wire.beginTransmission(...);
Wire.requestFrom(...);
Wire.endTransmission(); This is bad code. Here is correct code: // Writing to I2C
Wire.beginTransmission(...);
Wire.write(...);
Wire.write(...);
Wire.endTransmission();
//Reading from I2C
Wire.requestFrom(...);
Wire.read(...);
Wire.read(...); |
@FStefanni Did you already solve your issue? |
Hi, no, not solved. I wonder if other people have checked the performances and have found my same issue... Regards |
@FStefanni are you able to retest this on v2.0.3? So far we cannot replicate your issue. |
Hi, yes, but I need some time due to other projects deadlines (I am working on this at work). Regards. |
Hi, I have finally done some further investigation. Actually, it seems an issue of ADC ADS1115_WE: at the moment we have no ADS1115_WE component, and the other parts of the circuit are going fine, with both 2.0.2 and 2.0.3. The software library I use seems fine, so maybe it is an hw problem. Maybe does it require a dedicated bus? For example, we have discovered that PN532 requires a dedicated bus on esp32 (https://github.com/adafruit/Adafruit-PN532). I will test with ADS1115_WE as soon as the component arrives (we have ordered a copy). Regards. |
thanks @FStefanni for testing, we will wait for your follow up. |
I can confirm that I2C starting from 2.0.1 Arduino Release is "slow" compared to older versions. I use this function in order to read data from SHT21 sensors and i had to increase the
|
I'm now also running into issues with the latest ESP32 code where I2C is so much slower that it's actually causing issues. |
Hi,
I am very sorry, but I am using Arduino for work, and just now I am super busy on other stuff. Meanwhile, I see also other people had these issues... I hope they can give faster feedback. Regards |
@TD-er Did the PN532 ever work reliable with i2c? In out trys it always got stuck (after a few days) with ESP8266 and ESP32. After we changed to use serial connection it is working. |
Yep it was working, but there's a lot of checks in the code to reset the unit. I'm now looking into the traces using a logic analyzer and I'm not really surprised it is working so poorly.
|
OK, found something here.... So what I now do is I added a delay between sending the command and asking for data which seems to work just fine. Just looking at the code: (esp32-hal-i2c.c) esp_err_t i2cRead(uint8_t i2c_num, uint16_t address, uint8_t* buff, size_t size, uint32_t timeOutMillis, size_t *readCount){
esp_err_t ret = ESP_FAIL;
if(i2c_num >= SOC_I2C_NUM){
return ESP_ERR_INVALID_ARG;
}
#if !CONFIG_DISABLE_HAL_LOCKS
//acquire lock
if(bus[i2c_num].lock == NULL || xSemaphoreTake(bus[i2c_num].lock, portMAX_DELAY) != pdTRUE){
log_e("could not acquire lock");
return ret;
}
#endif
if(!bus[i2c_num].initialized){
log_e("bus is not initialized");
} else {
ret = i2c_master_read_from_device((i2c_port_t)i2c_num, address, buff, size, timeOutMillis / portTICK_RATE_MS);
if(ret == ESP_OK){
*readCount = size;
} else {
*readCount = 0;
}
}
#if !CONFIG_DISABLE_HAL_LOCKS
//release lock
xSemaphoreGive(bus[i2c_num].lock);
#endif
return ret;
} Timeout is in millis, in an uint32_t Thus: Not sure how this could lead to something like |
Can you please take a look on this issue @me-no-dev in the meantime? Thanks |
Status update: After discussing this internally there is not much we can do. I2C now uses ESP-IDF API and we're not aware of any performance issues. Some external libraries are now not working properly due to implementation on previous version of I2C in ESP32 Arduino core. |
Board
ESP32 Dev Module
Device Description
Hardware Configuration
Version
v2.0.2
IDE Name
VS Code + arduino-cli
Operating System
Linux Debian Testing
Flash frequency
default
PSRAM enabled
no
Upload speed
default
Description
Hi,
I have performed some performance tests:
loop()
The results delay in receiving the MQTT message to the PC (which is attached to the same broker):
So:
No workaround found.
No idea if this is an Arduino ESP32 issue or a ESP-IDF issue.
Regards
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: