From 1aff0d62efd47f045bc9f747d9954769719b709b Mon Sep 17 00:00:00 2001 From: Uspizig <56263335+Uspizig@users.noreply.github.com> Date: Thu, 26 Sep 2024 15:45:33 +0200 Subject: [PATCH] correct Temperature Readings MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit As stated in Application Note AN5130 Chapter 9: The temperature sensor has a sensitivity of 256LSB/°C Therefore the Value must be devided by 256 to get the correct readings. In the old code it was divided by 16 and therefore the readout Temperature values are wrong. https://www.st.com/resource/en/application_note/an5130-lsm6ds3trc-alwayson-3d-accelerometer-and-3d-gyroscope-stmicroelectronics.pdf --- src/SparkFunLSM6DS3.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/SparkFunLSM6DS3.cpp b/src/SparkFunLSM6DS3.cpp index a099fc5..f27b922 100644 --- a/src/SparkFunLSM6DS3.cpp +++ b/src/SparkFunLSM6DS3.cpp @@ -753,7 +753,8 @@ int16_t LSM6DS3::readRawTemp( void ) float LSM6DS3::readTempC( void ) { - float output = (float)readRawTemp() / 16; //divide by 16 to scale + //float output = (float)readRawTemp() / 16; //divide by 16 to scale + float output = (float)readRawTemp() / 256; //divide by 256 to scale: Application Note AN5130 Chapter 9 256LSB/°C output += 25; //Add 25 degrees to remove offset return output; @@ -762,7 +763,8 @@ float LSM6DS3::readTempC( void ) float LSM6DS3::readTempF( void ) { - float output = (float)readRawTemp() / 16; //divide by 16 to scale + //float output = (float)readRawTemp() / 16; //divide by 16 to scale = Wrong + float output = (float)readRawTemp() / 256; //divide by 256 to scale: Application Note AN5130 Chapter 9 256LSB/°C output += 25; //Add 25 degrees to remove offset output = (output * 9) / 5 + 32;