UncleRus / esp-idf-lib

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

ACK issue in wake up command in SCD4x component #582

Open vbieleny opened 9 months ago

vbieleny commented 9 months ago

The issue

I have tried to connect my SCD41 and I uploaded the example code to my ESP32-C3-DevKitM-1 and I got this error:

E (282) i2cdev: Could not write to device [0x62 at 0]: -1 (ESP_FAIL)

After some troubleshooting, I found out that the issue is in scd4x_wake_up function. So I checked the datasheet and section 3.10.4 has a description where it is mentioned that this command is not acknowledged by SCD4x:

Wake up the sensor from sleep mode into idle mode. Note that the SCD4x does not acknowledge the wake_up command. The sensor idle state after wake up can be verified by reading out the serial number (Section 3.9.2).

I've checked the code for the wake up function and it's using i2c_dev_write function, which always enables ACK, which I think is why this function fails.

Which SDK are you using?

esp-idf

Which version of SDK are you using?

v5.1.1

Which build target have you used?

Component causing the issue

scd4x

Anything in the logs that might be useful for us?

No response

Additional information or context

No response

Confirmation

AxelLin commented 8 months ago

The issue

I have tried to connect my SCD41 and I uploaded the example code to my ESP32-C3-DevKitM-1 and I got this error:

E (282) i2cdev: Could not write to device [0x62 at 0]: -1 (ESP_FAIL)

I can confirm the same error, I have to remove ESP_ERROR_CHECK around scd4x_wake_up() to make it work.