Skip to content

auto_convert: set/unset bias, + use in read_rtd #32

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

Merged
merged 1 commit into from
Jan 17, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions adafruit_max31865.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,8 +204,10 @@ def auto_convert(self, val):
config = self._read_u8(_MAX31865_CONFIG_REG)
if val:
config |= _MAX31865_CONFIG_MODEAUTO # Enable auto convert.
config |= _MAX31865_CONFIG_BIAS # Enable bias.
else:
config &= ~_MAX31865_CONFIG_MODEAUTO # Disable auto convert.
config &= ~_MAX31865_CONFIG_BIAS # Disable bias.
self._write_u8(_MAX31865_CONFIG_REG, config)

@property
Expand Down Expand Up @@ -243,6 +245,11 @@ def read_rtd(self):
nominal value of the resistance-to-digital conversion and some math. If you just want
temperature use the temperature property instead.
"""
if self.auto_convert:
rtd = self._read_u16(_MAX31865_RTDMSB_REG)
if not rtd & 1:
rtd >>= 1
return rtd
self.clear_faults()
self.bias = True
time.sleep(0.01)
Expand Down