From 43e37b17ddc2edb0e43ac49577fcb907cbfc3357 Mon Sep 17 00:00:00 2001 From: TheJackiMonster Date: Wed, 19 Apr 2023 00:11:04 +0200 Subject: [PATCH] Adjust temperature values with offset and sensitivity Signed-off-by: TheJackiMonster --- interface_lib/include/device3.h | 2 +- interface_lib/src/device3.c | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/interface_lib/include/device3.h b/interface_lib/include/device3.h index 6189ad4..8a7a7d0 100644 --- a/interface_lib/include/device3.h +++ b/interface_lib/include/device3.h @@ -127,7 +127,7 @@ struct device3_t { bool claimed; uint64_t last_timestamp; - float temperature; + float temperature; // (in °C) void* offset; device3_ahrs_type* ahrs; diff --git a/interface_lib/src/device3.c b/interface_lib/src/device3.c index 8b12b6a..00fafb3 100644 --- a/interface_lib/src/device3.c +++ b/interface_lib/src/device3.c @@ -712,7 +712,8 @@ int device3_read(device3_type* device, int timeout) { int16_t temperature = pack16bit_signed(packet.temperature); - device->temperature = (float) temperature; + // According to the ICM-42688-P datasheet: (offset: 25 °C, sensitivity: 132.48 LSB/°C) + device->temperature = ((float) temperature) / 132.48f + 25.0f; FusionVector gyroscope; FusionVector accelerometer;