Skip to content

Commit 98653ee

Browse files
authored
Merge pull request #55 from jerryneedell/jerryn_temperature
fix temperature calculation
2 parents d8f3c0a + e31548e commit 98653ee

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

adafruit_lsm6ds/__init__.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,8 @@ class AccelHPF(CV):
158158
_LSM6DS_TAP_CFG = const(0x58)
159159
_LSM6DS_MLC0_SRC = const(0x70)
160160
_MILLI_G_TO_ACCEL = 0.00980665
161-
161+
_TEMPERATURE_SENSITIVITY = 256
162+
_TEMPERATURE_OFFSET = 25.0
162163

163164
_LSM6DS_EMB_FUNC_EN_A = const(0x04)
164165
_LSM6DS_EMB_FUNC_EN_B = const(0x05)
@@ -399,10 +400,7 @@ def temperature(self) -> float:
399400

400401
temp = self._raw_temp_data[0]
401402

402-
if temp > 0x550:
403-
return (temp - 2 ** 13) * 0.0625
404-
405-
return temp * 0.0625
403+
return temp / _TEMPERATURE_SENSITIVITY + _TEMPERATURE_OFFSET
406404

407405
def _set_embedded_functions(self, enable, emb_ab=None):
408406
"""Enable/disable embedded functions - returns prior settings when disabled"""

0 commit comments

Comments
 (0)