adafruit / adafruit/Adafruit_CircuitPython_SI7021

Sensor continuously throws "other measurement in progress" error after CRC error

Open
#33 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
10
Forks
7
PR merge metrics
No merged PRs in 30d

Description

I'm still debugging this since it comes up so infrequently, but I noticed that after a CRC error the program doesn't seem to reset the `_measurement` variable. Since the `_data` function throws the error, it seems that it is left to the user to handle the reset. I just want to make sure this is the intended behavior since `_measurement` is not documented.

Within `_data()`
```
if checksum != _crc(data[:2]):
raise ValueError("CRC mismatch")
```
`relative_humidity()` does not catch the CRC mismatch to reset `self._measurement=0`
```
def relative_humidity(self) -> float:
"""The measured relative humidity in percent."""
self.start_measurement(HUMIDITY)
value = self._data()
self._measurement = 0
return min(100.0, value * 125.0 / 65536.0 - 6.0)
```
This might fixed the issue, but I have NOT fully tested it (needed for both `relative_humidity()` and `temperature()`)
```
def relative_humidity(self) -> float:
"""The measured relative humidity in percent."""
self.start_measurement(HUMIDITY)
try:
value = self._data()
finally:
self._measurement = 0
return min(100.0, value * 125.0 / 65536.0 - 6.0)
```

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by reading `_data()`, `relative_humidity()`, and `temperature()` to trace how a CRC mismatch affects `_measurement`. Confirm the intended cleanup behavior and verify that a later measurement can start normally after the error, including both humidity and temperature paths.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
embedded-iot
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.