Skip to content
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
auto_convert: set/unset bias, + use in read_rtd
  • Loading branch information
emmanuelthome committed May 25, 2021
commit 6bf5b785cdba7515c0d2cd064e9aff255ff81b4b
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