zephyrproject-rtos / zephyr

Primary Git Repository for the Zephyr Project. Zephyr is a new generation, scalable, optimized, secure RTOS for multiple hardware architectures.
https://docs.zephyrproject.org
Apache License 2.0
10.17k stars 6.23k forks source link

ST LIS2DUX12 driver: temperature is not converted to Celsius and raw values are returned #75686

Open ragrus-nbl opened 2 weeks ago

ragrus-nbl commented 2 weeks ago

Describe the bug ST LIS2DUX12 accelerometer driver doesn't convert the raw value of temperature to Celsius. When I read the SENSOR_CHAN_DIE_TEMP channel, I get values like these (of type struct sensor_value): .val1 = 1360, .val2 = 0.

According to the docs, they must be in Celsius.

To Reproduce Steps to reproduce the behavior:

  1. Get a board with a LIS2DUX12 accelerometer
  2. Enable the LIS2DUX12 driver (by adding the accelerometer into the device tree)
  3. Add CONFIG_LIS2DUX12_ENABLE_TEMP=y to prj.conf
  4. Run some code which reads the SENSOR_CHAN_DIE_TEMP channel. Like the following:
const struct device *dev = DEVICE_DT_GET(LIS2DUX12);
struct sensor_value val = { .val1 = 0, .val2 = 0 };
sensor_channel_get(dev, SENSOR_CHAN_DIE_TEMP, &val);
LOG_DBG("Temperature: %d.%06d", val.val1, val.val2);

Logs and console output

[00:22:32.297,729] <dbg> test_accelerometer: Temperature: 1520.000000

Environment

github-actions[bot] commented 2 weeks ago

Hi @ragrus-nbl! We appreciate you submitting your first issue for our open-source project. 🌟

Even though I'm a bot, I can assure you that the whole community is genuinely grateful for your time and effort. 🤖💙