Skip to content
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

sht4x - Fix sporadic measurement errors by applying TIME_TO_TICKS() m… #632

Merged
merged 1 commit into from
May 16, 2024

Conversation

cmorganBE
Copy link
Contributor

…acro from SHT3x driver to ensure the delay time is at least 1 more tick than desired

Replace pdMS_TO_TICKS() with TIME_TO_TICKS().

FreeRTOS vTaskDelay() (https://www.freertos.org/a00127.html) does NOT guarantee that the delay time is at least the ticks specified, relative to time.

The SHT4x has timing constraints that are required to be followed for the part to be ready to respond. In the case where the delay was 10ms and the FreeRTOS tick time is 10ms vTaskDelay(1) was being called. Measurement via oscilloscope confirmed that most of the time the delay was 10ms + 2-5ms, but sometimes it was 6ms or 7ms.

In the cases where the delay was <10ms, the SHT4x would not respond to the 'read measurement' phase of taking a measurement, resulting in i2cdev logging an error, and the measurement call failing.

…acro from SHT3x driver to ensure the delay time is at least 1 more tick than desired

Replace pdMS_TO_TICKS() with TIME_TO_TICKS().

FreeRTOS vTaskDelay() (https://www.freertos.org/a00127.html) does NOT guarantee that
the delay time is at least the ticks specified, relative to time.

The SHT4x has timing constraints that are required to be followed for the part to be ready to respond.
In the case where the delay was 10ms and the FreeRTOS tick time is 10ms
vTaskDelay(1) was being called. Measurement via oscilloscope confirmed that most of the time the
delay was 10ms + 2-5ms, but sometimes it was 6ms or 7ms.

In the cases where the delay was <10ms, the SHT4x would not respond to the 'read measurement' phase of
taking a measurement, resulting in i2cdev logging an error, and the measurement call failing.
@UncleRus
Copy link
Owner

Thank you!

@UncleRus UncleRus merged commit 315294a into UncleRus:master May 16, 2024
40 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants