diff --git a/pycardium/modules/py/bhi160.py b/pycardium/modules/py/bhi160.py index 430508d10f2406c39a96f6062b7a7dafb1879be5..6036e9a2aac5a248be024031e58e83cd40497d01 100644 --- a/pycardium/modules/py/bhi160.py +++ b/pycardium/modules/py/bhi160.py @@ -18,6 +18,11 @@ class BHI160: def enable_sensor(self): interrupt.disable_callback(self.interrupt_id) interrupt.set_callback(self.interrupt_id, self._interrupt) + + # If the sensor is already enabled, disable it first. + # The call is allowed to silently fail. + sys_bhi160.disable_sensor(self.sensor_id) + self.stream_id = sys_bhi160.enable_sensor( self.sensor_id, self.sample_buffer_len, self.sample_rate, self.dynamic_range )