diff --git a/sonoff/sonoff.ino b/sonoff/sonoff.ino index ef9845c81..48145fb2f 100755 --- a/sonoff/sonoff.ino +++ b/sonoff/sonoff.ino @@ -125,7 +125,7 @@ int blinks = 201; // Number of LED blinks uint32_t uptime = 0; // Counting every second until 4294967295 = 130 year uint32_t loop_load_avg = 0; // Indicative loop load average uint32_t global_update = 0; // Timestamp of last global temperature and humidity update -float global_temperature = 0; // Provide a global temperature to be used by some sensors +float global_temperature = 9999; // Provide a global temperature to be used by some sensors float global_humidity = 0; // Provide a global humidity to be used by some sensors float global_pressure = 0; // Provide a global pressure to be used by some sensors char *ota_url; // OTA url string pointer diff --git a/sonoff/support.ino b/sonoff/support.ino index da79be0e0..f3faa1798 100644 --- a/sonoff/support.ino +++ b/sonoff/support.ino @@ -644,7 +644,7 @@ void ResetGlobalValues(void) { if ((uptime - global_update) > GLOBAL_VALUES_VALID) { // Reset after 5 minutes global_update = 0; - global_temperature = 0; + global_temperature = 9999; global_humidity = 0; global_pressure = 0; } diff --git a/sonoff/xsns_21_sgp30.ino b/sonoff/xsns_21_sgp30.ino index 27d1a43f9..e9c097dc4 100644 --- a/sonoff/xsns_21_sgp30.ino +++ b/sonoff/xsns_21_sgp30.ino @@ -89,7 +89,7 @@ void Sgp30Update(void) // Perform every second to ensure proper operation of th } return; // Measurement failed } - if (global_update) { + if (global_update && global_humidity>0 && global_temperature!=9999) { // abs hum in mg/m3 sgp30_abshum=sgp30_AbsoluteHumidity(global_temperature,global_humidity,TempUnit()); sgp.setHumidity(sgp30_abshum*1000); @@ -124,7 +124,7 @@ void Sgp30Show(bool json) if (sgp30_ready) { char abs_hum[33]; - if (global_update) { + if (global_update && global_humidity>0 && global_temperature!=9999) { // has humidity + temperature dtostrfd(sgp30_abshum,4,abs_hum); } diff --git a/sonoff/xsns_31_ccs811.ino b/sonoff/xsns_31_ccs811.ino index 2624d0b8c..550313b51 100644 --- a/sonoff/xsns_31_ccs811.ino +++ b/sonoff/xsns_31_ccs811.ino @@ -62,7 +62,7 @@ void CCS811Update(void) // Perform every n second TVOC = ccs.getTVOC(); eCO2 = ccs.geteCO2(); CCS811_ready = 1; - if (global_update) { ccs.setEnvironmentalData((uint8_t)global_humidity, global_temperature); } + if (global_update && global_humidity>0 && global_temperature!=9999) { ccs.setEnvironmentalData((uint8_t)global_humidity, global_temperature); } ecnt = 0; } } else {