Skip to content

Conversation

@stemschmidt
Copy link
Contributor

When running the samples/sensor/accel_trig sample with a adxl345 sensor the logged output values were doubled compared to the expected values.

The sensor_channel_get() path calls adxl345_accel_convert which did not handle the configured g-range, resulting in invalid sample values except for the +/-16g range. To fix this issue the configured range is taken into account and different conversion factors are applied.

adxl345_accel_convert is also made static as it is not used by another file.

Copy link
Member

@MaureenHelm MaureenHelm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the fix. The code changes look good, but the commit message needs to be updated to fix the compliance check:

1: UC5 Commit title exceeds max length (77>75): "drivers: sensor: adi: adxl345: take selected range into account in conversion"
11: UC4 Commit message body line exceeds max length (76>75): "adxl345_accel_convert is also made static as it is not used by another file."

https://github.com/zephyrproject-rtos/zephyr/actions/runs/20066238808/job/57555432868?pr=100746#step:13:42

@stemschmidt stemschmidt force-pushed the sensor_adxl345_channel_get branch from 057ee44 to 6c43105 Compare December 9, 2025 14:29
When running the samples/sensor/accel_trig sample with a adxl345 sensor
the logged output values were doubled compared to the expected values.

The sensor_channel_get() path calls adxl345_accel_convert which did not
handle the configured g-range, resulting in invalid sample values except
for the +/-16g range. To fix this issue the configured range is taken
into account and different conversion factors are applied.

adxl345_accel_convert is also made static. It is not used by another file.

Signed-off-by: Stefan Schmidt <kontakt@stefanschmidt-embedded.de>
@stemschmidt stemschmidt force-pushed the sensor_adxl345_channel_get branch from 291bf02 to 4612b6f Compare December 9, 2025 16:10
@sonarqubecloud
Copy link

sonarqubecloud bot commented Dec 9, 2025

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: Sensors Sensors platform: ADI Analog Devices, Inc.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants