From d2f53073ec5332dfa59cc70b41eaa5df44a5cf88 Mon Sep 17 00:00:00 2001 From: dooku Date: Sun, 18 Jul 2021 13:58:35 +0200 Subject: [PATCH] Changed temperature calculation --- fw/Core/Src/scd4x.c | 2 +- fw/Core/Src/sht4x.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/fw/Core/Src/scd4x.c b/fw/Core/Src/scd4x.c index c241ae6..56f1d9a 100644 --- a/fw/Core/Src/scd4x.c +++ b/fw/Core/Src/scd4x.c @@ -88,7 +88,7 @@ int8_t scd4x_read_measurement(int * co2, int *temperature, int *relative_humidit uint32_t co2_ticks = (buffer[0] << 8) + buffer[1]; uint32_t t_ticks = (buffer[3] << 8) + buffer[4]; uint32_t rh_ticks = (buffer[6] << 8) + buffer[7]; - int t_degC = 10*(-45 + 175 * t_ticks / 65535); + int t_degC = -450 + 10 * 175 * t_ticks / 65535; int rh_pRH = 100 * rh_ticks / 65535; if (rh_pRH > 100) { rh_pRH = 100; diff --git a/fw/Core/Src/sht4x.c b/fw/Core/Src/sht4x.c index 263219b..63221fa 100644 --- a/fw/Core/Src/sht4x.c +++ b/fw/Core/Src/sht4x.c @@ -40,7 +40,7 @@ int8_t sht4x_measure(int *temperature, int *relative_humidity) // Convert to T and RH; taken directly from pseudocode in SHT4x datasheet, page 3 uint32_t t_ticks = (buffer[0] << 8) + buffer[1]; uint32_t rh_ticks = (buffer[3] << 8) + buffer[4]; - int t_degC = 10*(-45 + 175 * t_ticks / 65535); + int t_degC = -450 + 10 * 175 * t_ticks / 65535; /* temperature * 10 */ int rh_pRH = -6 + 125 * rh_ticks / 65535; if (rh_pRH > 100) { rh_pRH = 100;