Просмотр исходного кода

Fixed incorrect calculation of air humidity

Victor 3 лет назад
Родитель
Сommit
7d24031b16
3 измененных файлов с 16 добавлено и 11 удалено
  1. 8 2
      sensors/BME680.c
  2. 8 7
      sensors/BME680.h
  3. 0 2
      sensors/MAX6675.c

+ 8 - 2
sensors/BME680.c

@@ -1,6 +1,7 @@
 /*
     Unitemp - Universal temperature reader
-    Copyright (C) 2022  Victor Nikitchuk (https://github.com/quen0n)
+    Copyright (C) 2022-2023  Victor Nikitchuk (https://github.com/quen0n)
+    Contributed by g0gg0 (https://github.com/g3gg0)
 
     This program is free software: you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
@@ -60,7 +61,7 @@ const SensorType BME680 = {
 #define BME680_HUM_OVERSAMPLING_2 0b00000010
 #define BME680_HUM_OVERSAMPLING_4 0b00000011
 #define BME680_HUM_OVERSAMPLING_8 0b00000100
-#define BME680_HUM_OVERSAMPLING_16 0b00000101u
+#define BME680_HUM_OVERSAMPLING_16 0b00000101
 //Режимы работы датчика
 #define BME680_MODE_SLEEP 0b00000000 //Наелся и спит
 #define BME680_MODE_FORCED 0b00000001 //Обновляет значения 1 раз, после чего уходит в сон
@@ -394,6 +395,11 @@ UnitempStatus unitemp_BME680_update(Sensor* sensor) {
         return UT_SENSORSTATUS_ERROR;
     }
 
+    unitemp_i2c_writeReg(
+        i2c_sensor,
+        BME680_REG_CTRL_MEAS,
+        unitemp_i2c_readReg(i2c_sensor, BME680_REG_CTRL_MEAS) | 1);
+
     while(BME680_isMeasuring(sensor)) {
         if(furi_get_tick() - t > 100) {
             return UT_SENSORSTATUS_TIMEOUT;

+ 8 - 7
sensors/BME680.h

@@ -1,6 +1,7 @@
 /*
     Unitemp - Universal temperature reader
-    Copyright (C) 2022  Victor Nikitchuk (https://github.com/quen0n)
+    Copyright (C) 2022-2023  Victor Nikitchuk (https://github.com/quen0n)
+    Contributed by g0gg0 (https://github.com/g3gg0)
 
     This program is free software: you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
@@ -48,12 +49,12 @@ typedef struct {
 } BME680_press_cal;
 
 typedef struct {
-    uint8_t dig_H1;
-    int16_t dig_H2;
-    uint8_t dig_H3;
-    int16_t dig_H4;
-    int16_t dig_H5;
-    int8_t dig_H6;
+    uint16_t dig_H1;
+    uint16_t dig_H2;
+    int8_t dig_H3;
+    int8_t dig_H4;
+    int8_t dig_H5;
+    uint8_t dig_H6;
     int8_t dig_H7;
 } BME680_hum_cal;
 

+ 0 - 2
sensors/MAX6675.c

@@ -77,7 +77,5 @@ UnitempStatus unitemp_MAX6675_update(Sensor* sensor) {
 
     sensor->temp = (int16_t)(raw) / 32.0f;
 
-    UNITEMP_DEBUG("RAW: %04lX", raw);
-
     return UT_SENSORSTATUS_OK;
 }