Sensirion / embedded-scd

Embedded SCD Drivers for Sensirion CO2 Sensors - Download the Zip Package from the Release Page
https://github.com/Sensirion/embedded-scd/releases
BSD 3-Clause "New" or "Revised" License
47 stars 9 forks source link

Fix readout error with drifting clocks #44

Closed rnestler closed 3 years ago

rnestler commented 4 years ago

If the sensirion_sleep_usec sleeps longer or shorter, the readout will fail at some point, since we will miss the readout window of 100ms at one point or another. By waiting less then the measurement interval and then starting to poll the data ready flag we should fix the issue, except if the sleep time is off by more than 100ms.

Fixes #43

Check the following:

rnestler commented 3 years ago

As a separate commit or PR, could you also double-check whether the sensor indeed returns correctly checksummed 0xff readings outside the data-ready window?

This is indeed the case. Depending on the clock deviation between the SCD30 and the Raspberry Pi it happens more or less frequently.

rnestler commented 3 years ago

After testing it extensively on a RaspberryPi I came to the following conclusion:

I'll change this PR accordingly.