2024-05-30 07:29 AM
I am using the STM driver to control the LIS2DH12TR accelerometer.
void MEMS_task(void)
{
lis2dh12_self_test(&dev_ctx);
result = lis2dh12_operating_mode_set(&dev_ctx, LIS2DH12_HR_12bit);
result = lis2dh12_data_rate_set(&dev_ctx, LIS2DH12_ODR_100Hz);
result = lis2dh12_fifo_mode_set(&dev_ctx, LIS2DH12_BYPASS_MODE);
result = lis2dh12_block_data_update_set(&dev_ctx, PROPERTY_ENABLE);
result = lis2dh12_temperature_meas_set(&dev_ctx, LIS2DH12_TEMP_ENABLE);
for (;;)
{
result = lis2dh12_xl_data_ready_get(&dev_ctx, &acceleration_data_available);
if (acceleration_data_available != 0)
{
/* Read accelerometer data */
memset(data_raw_acceleration, 0x00, sizeof(data_raw_acceleration));
lis2dh12_acceleration_raw_get(&dev_ctx, data_raw_acceleration);
acceleration_mg[0] = lis2dh12_from_fs2_hr_to_mg(data_raw_acceleration[0]);
acceleration_mg[1] = lis2dh12_from_fs2_hr_to_mg(data_raw_acceleration[1]);
acceleration_mg[2] = lis2dh12_from_fs2_hr_to_mg(data_raw_acceleration[2]);
}
}
}
X: 0
Y: -22
Z: 1016
X: -2
Y: -20
Z: 1024
X: -1
Y: -21
Z: 1017
X: 4
Y: -24
Z: 1019
Solved! Go to Solution.
2024-06-03 03:13 AM
Hi @Manuel Ferrero ,
Yes, it is normal. You have to consider the impact of noise.
In addition, test them in controlled environment to minimize ambient noise as well.
2024-06-03 03:13 AM
Hi @Manuel Ferrero ,
Yes, it is normal. You have to consider the impact of noise.
In addition, test them in controlled environment to minimize ambient noise as well.