Skip to content

Commit

Permalink
Merge pull request #32 from emmanuelthome/enable_auto_convert
Browse files Browse the repository at this point in the history
auto_convert: set/unset bias, + use in read_rtd
  • Loading branch information
FoamyGuy committed Jan 17, 2022
2 parents d0cfb9b + 6bf5b78 commit eb8e72c
Showing 1 changed file with 7 additions and 0 deletions.
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

0 comments on commit eb8e72c

Please sign in to comment.