STHS34PF80 Motion Threshold Issue

A couple of weeks ago, I asked a question about the STHS34PF80 regarding a threshold setting issue on this thread: https://community.sparkfun.com/t/sths34pf80-set-threshold-problem/47099.

Since then, I believe the issue in that thread has been resolved, but I haven’t received help for a new issue I’m facing.

To address this new problem with the module, I’m creating this post. Below is my original post:

Hi there, I’m experiencing a similar issue with setting the motion threshold. For example, when I set it to 256, it reads as 0. I tried following your instructions to fix this issue, but unfortunately, it didn’t work. Could you please advise me? Thank you! Here is my code for your reference if you need to test it:

#include “SparkFun_STHS34PF80_Arduino_Library.h”

#include <Wire.h>

STHS34PF80_I2C mySensor;

void setup()

{

Serial.begin(115200);

Serial.println(“STHS34PF80 Example: Setting and Reading Motion Threshold”);

// Begin I2C

Wire.begin();

// Establish communication with device

if (!mySensor.begin())

{

Serial.println(“Error setting up device - please check wiring.”);

while (1);

}

delay(1000);

// Set the motion threshold

uint16_t newThreshold = 256; // Set your desired threshold value

int32_t setError = mySensor.setMotionThreshold(newThreshold);

Serial.print("Motion Threshold set to: ");

Serial.println(newThreshold);

delay(1000);

// Read and print the current motion threshold

uint16_t motionThreshold;

int32_t getError = mySensor.getMotionThreshold(&motionThreshold);

if (getError == 0)

{

Serial.print("Current Motion Threshold: ");

Serial.println(motionThreshold);

}

else

{

Serial.println(“Error reading motion threshold.”);

}

}

void loop()

{

// Nothing in the loop function for this example

}