Selaa lähdekoodia

Corrected timing for temp and lux

Thomas Chef 6 kuukautta sitten
vanhempi
commit
61d840cda9
3 muutettua tiedostoa jossa 6 lisäystä ja 4 poistoa
  1. 2 2
      main/config.h
  2. 1 1
      main/lux.c
  3. 3 1
      main/readTemps.c

+ 2 - 2
main/config.h

@@ -12,11 +12,11 @@
 
 //#define WIFI_ENABLED
 //#define MQTT_ENABLED
-//#define ENABLE_DS18B20
+#define ENABLE_DS18B20
 
 #define MQTT_DEBUG              // Add an extra debug string to the beginning of the topic-string
 
-#define ONE_WIRE_BUS_IO           GPIO_NUM_33   // Temp sensors
+#define ONE_WIRE_BUS_IO           GPIO_NUM_26   // Temp sensors
 
 
 #define ENABLE_LUX_SENSOR

+ 1 - 1
main/lux.c

@@ -372,7 +372,7 @@ static void tsl2561_task(void * pvParameter)
     uint8_t id = read8(TSL2561_COMMAND_BIT | TSL2561_REGISTER_ID);
     ESP_LOGI(TAG, "WHO_AM_I = %02X", id);
 
-    setIntegrationTime(TSL2561_INTEGRATIONTIME_101MS);
+    setIntegrationTime(TSL2561_INTEGRATIONTIME_402MS);
     setGain(TSL2561_GAIN_1X);
 
     // Do an initial delay to make the different tasks to work out of sync to each other (not send all data at same time)

+ 3 - 1
main/readTemps.c

@@ -69,6 +69,8 @@ void readAndSendTemps(void *pvParameters) {
 
     ESP_LOGI("TEMPS", "Read temperature task. Core:%d",xPortGetCoreID());
 
+    TickType_t vLastWakeTime = xTaskGetTickCount();
+
     while(true)
     {
    
@@ -123,7 +125,7 @@ void readAndSendTemps(void *pvParameters) {
             ESP_LOGE("TEMPS", "No DS18B20 devices detected!");
         }
 
-        vTaskDelay(10000 / portTICK_PERIOD_MS);
+        vTaskDelayUntil( &vLastWakeTime, 20000 / portTICK_PERIOD_MS );
     
     }
     vTaskDelete(NULL);