adafruit / Adafruit_CircuitPython_SCD4X

CircuitPython/Python driver for Sensirion SCD40 & SCD41
MIT License
19 stars 10 forks source link

get_data_ready_status should watch 11 bits (not 10) #11

Closed topherCantrell closed 2 years ago

topherCantrell commented 2 years ago

Section 3.8.2 of the SCD4x datasheet says to check the least significant 11 bits of the returned status. But the code on line 211 in "data_ready" only checks 8+2 = 10 bits. I've never ever seen that unchecked bit get set when data was not ready, but just in case it ever does -- we should AND the MSB with 7 (3 bits + 8) instead of 3 (2 bits + 8) to follow the datasheet.

KeithTheEE commented 2 years ago

That's a good catch. Thank you for the really direct references, it was really easy to look up and see. I tried going through the Sensirion provided c code to see what they use, but c is not my specialty. I've got a sensor so I should be able to give it a shot regardless

ladyada commented 2 years ago

! can y'all submit a PR?

KeithTheEE commented 2 years ago

Yup! I should have one in tonight

caternuson commented 2 years ago

Just adding to document: image

caternuson commented 2 years ago

Closing. Fixed with #12.