ADXL362 Noise on Thingy 91

Hi,

I would like to use the Thingy 91 to count rotations making use of the accelerometer. So I wrote this function that seems to work to get the acceleration values from the ADXL362:

int ext_sensors_accel_lp_get(double *accel)
{
	int err;
	struct sensor_value data[ACCELEROMETER_CHANNELS];

	err = sensor_sample_fetch_chan(accel_sensor_lp.dev, SENSOR_CHAN_ALL);
	if (err) {
		LOG_ERR("sensor_sample_fetch_chan, error: %d", err);
		return -1; 
	}

	err = sensor_channel_get(accel_sensor_lp.dev, SENSOR_CHAN_ACCEL_XYZ, data);
	if (err) {
		LOG_ERR("sensor_channel_get, error: %d", err);
		return -1; 
	}

	accel[0] = sensor_value_to_double(&data[0]);
	accel[1] = sensor_value_to_double(&data[1]);
	accel[2] = sensor_value_to_double(&data[2]);

	//k_spinlock_key_t key = k_spin_lock(&(accel_sensor_lp.lock));
	//*accel = sensor_value_to_double(&data);
	//k_spin_unlock(&(accel_sensor_lp.lock), key);

	return 0;
}

However, the values this function returns vary a lot, more than I expect from reading the datasheet:

 0.068646    -0.558979  -8.620045
 0.039226    -0.019613  -8.953471
-0.284392    0.323619   -8.786758
 0.304006     0.225552  -9.855683
 0.235359    -0.941438  -6.982334
 0.774725    -1.029698  -10.012589
-0.470719   -0.274586   -8.933858
 0.608012    -0.980665  -10.208722



(The one higher valued axis does change like you would expect when rotating the Thingy 91)

I also tried changing the measurement rate to 12.5Hz:
# ADXL362 - Low-Power accelerometer used for activity and inactivity detection.
CONFIG_ADXL362=y
CONFIG_ADXL362_TRIGGER_GLOBAL_THREAD=y
CONFIG_ADXL362_INTERRUPT_MODE=1
CONFIG_ADXL362_ABS_REF_MODE=1
CONFIG_ADXL362_ACCEL_RANGE_2G=y
#CONFIG_ADXL362_ACCEL_ODR_400=y
CONFIG_ADXL362_ACCEL_ODR_12_5=y

But this did not improve the results. I'm I missing something or just reading the values in the wrong manner perhaps?

Related