Changed temperature calculation

This commit is contained in:
dooku 2021-07-18 13:58:35 +02:00
parent 2b04e6f53c
commit d2f53073ec
2 changed files with 2 additions and 2 deletions

View File

@ -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;

View File

@ -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;