Closed

Description
[issue mistakenly posted to adafruit / Adafruit_DPS310 - reposting here]
First, thanks for this library!
I have a DPS310 on a grove module, it's not from Adafruit so maybe my issue doesn't apply to ICs shipped by Adafruit. Anyway - as mentioned in Infineon's official lib some ICs have a problem with temperature (mine does) in which case their "correctTemp()" function has to be called just after i2c initilaization (or as tests showed, after a reset).
The following fix worked for me. I'm a noob with python so I didn't want to modify the lib and send a pull request - instead I've just overriden the _reset() function. Maybe add that fix to the library ?
class fixDPS310(DPS310):
# magic values from the official library's DpsClass.cpp
_reg0e = RWBits(8, 0x0E, 0)
_reg0f = RWBits(8, 0x0F, 0)
_reg62 = RWBits(8, 0x62, 0)
def _correct_temp(self):
self._reg0e = 0xA5
self._reg0f = 0x96
self._reg62 = 0x02
self._reg0e = 0
self._reg0f = 0
unused_var = self._raw_temperature
def _reset(self):
# print('override reset')
self._reset_register = 0x89
# wait for hardware reset to finish
sleep(0.010)
while not self._sensor_ready:
sleep(0.001)
self._correct_temp()
dps310 = fixDPS310(i2c)
# [...]
Metadata
Metadata
Assignees
Labels
No labels