diff --git a/Adafruit_STHS34PF80.cpp b/Adafruit_STHS34PF80.cpp index 77c356f..f9d8337 100644 --- a/Adafruit_STHS34PF80.cpp +++ b/Adafruit_STHS34PF80.cpp @@ -63,6 +63,10 @@ bool Adafruit_STHS34PF80::begin(uint8_t i2c_addr, TwoWire *wire) { return false; } + if (!reset()) { + return false; + } + // Apply recommended default settings if (!setObjAveraging(STHS34PF80_AVG_TMOS_32)) { return false; @@ -98,6 +102,27 @@ bool Adafruit_STHS34PF80::isConnected() { return chip_id.read() == 0xD3; } +/*! + * @brief Reset the sensor completely + * @return True if successful, false otherwise + */ +bool Adafruit_STHS34PF80::reset() { + // Reboot OTP memory + if (!rebootOTPmemory()) { + return false; + } + + // Wait for sensor reset to complete + delay(5); + + // Reset the internal algorithm + if (!algorithmReset()) { + return false; + } + + return true; +} + /*! * @brief Set the motion detection low-pass filter configuration * @param config The LPF configuration value diff --git a/Adafruit_STHS34PF80.h b/Adafruit_STHS34PF80.h index 9f13f41..1fcce4d 100644 --- a/Adafruit_STHS34PF80.h +++ b/Adafruit_STHS34PF80.h @@ -133,6 +133,7 @@ public: bool begin(uint8_t i2c_addr = STHS34PF80_DEFAULT_ADDR, TwoWire *wire = &Wire); bool isConnected(); + bool reset(); bool setMotionLowPassFilter(sths34pf80_lpf_config_t config); sths34pf80_lpf_config_t getMotionLowPassFilter();