UncleRus / esp-idf-lib

Component library for ESP32-xx and ESP8266
https://esp-idf-lib.readthedocs.io/en/latest/
1.33k stars 414 forks source link

SHT4x often gives "i2cdev: Could not read from device [0x44 at 0]" error on measurement #598

Closed MRusinov closed 5 months ago

MRusinov commented 5 months ago

The issue

SHT4x often gives "i2cdev: Could not read from device [0x44 at 0]" error on measurement. ESP32C3

Corrected this way:

--- sht4x.c.old 2024-02-02 10:34:14.680822283 +0400
+++ sht4x.c 2024-02-02 11:23:58.529277599 +0400
@@ -174,8 +174,8 @@
 {
     I2C_DEV_TAKE_MUTEX(&dev->i2c_dev);
     I2C_DEV_CHECK(&dev->i2c_dev, send_cmd_nolock(dev, cmd));
-    if (delay_ticks)
-        vTaskDelay(delay_ticks);
+    // if (delay_ticks)
+    vTaskDelay(delay_ticks + 1);
     I2C_DEV_CHECK(&dev->i2c_dev, read_res_nolock(dev, res));
     I2C_DEV_GIVE_MUTEX(&dev->i2c_dev);

After that all errors gone...

Which SDK are you using?

esp-idf

Which version of SDK are you using?

5.1.2

Which build target have you used?

Component causing the issue

sht4x

Anything in the logs that might be useful for us?

No response

Additional information or context

No response

Confirmation

UncleRus commented 5 months ago

Thank you. But could you do a pull request instead of an issue?

MRusinov commented 5 months ago

Never did it, but I'll try today...