Merge pull request #5843 from gemu2015/sgp30

global update fix
This commit is contained in:
Theo Arends 2019-05-22 12:26:51 +02:00 committed by GitHub
commit b18eee50e2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 5 additions and 5 deletions

View File

@ -125,7 +125,7 @@ int blinks = 201; // Number of LED blinks
uint32_t uptime = 0; // Counting every second until 4294967295 = 130 year uint32_t uptime = 0; // Counting every second until 4294967295 = 130 year
uint32_t loop_load_avg = 0; // Indicative loop load average uint32_t loop_load_avg = 0; // Indicative loop load average
uint32_t global_update = 0; // Timestamp of last global temperature and humidity update 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_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 float global_pressure = 0; // Provide a global pressure to be used by some sensors
char *ota_url; // OTA url string pointer char *ota_url; // OTA url string pointer

View File

@ -644,7 +644,7 @@ void ResetGlobalValues(void)
{ {
if ((uptime - global_update) > GLOBAL_VALUES_VALID) { // Reset after 5 minutes if ((uptime - global_update) > GLOBAL_VALUES_VALID) { // Reset after 5 minutes
global_update = 0; global_update = 0;
global_temperature = 0; global_temperature = 9999;
global_humidity = 0; global_humidity = 0;
global_pressure = 0; global_pressure = 0;
} }

View File

@ -89,7 +89,7 @@ void Sgp30Update(void) // Perform every second to ensure proper operation of th
} }
return; // Measurement failed return; // Measurement failed
} }
if (global_update) { if (global_update && global_humidity>0 && global_temperature!=9999) {
// abs hum in mg/m3 // abs hum in mg/m3
sgp30_abshum=sgp30_AbsoluteHumidity(global_temperature,global_humidity,TempUnit()); sgp30_abshum=sgp30_AbsoluteHumidity(global_temperature,global_humidity,TempUnit());
sgp.setHumidity(sgp30_abshum*1000); sgp.setHumidity(sgp30_abshum*1000);
@ -124,7 +124,7 @@ void Sgp30Show(bool json)
if (sgp30_ready) { if (sgp30_ready) {
char abs_hum[33]; char abs_hum[33];
if (global_update) { if (global_update && global_humidity>0 && global_temperature!=9999) {
// has humidity + temperature // has humidity + temperature
dtostrfd(sgp30_abshum,4,abs_hum); dtostrfd(sgp30_abshum,4,abs_hum);
} }

View File

@ -62,7 +62,7 @@ void CCS811Update(void) // Perform every n second
TVOC = ccs.getTVOC(); TVOC = ccs.getTVOC();
eCO2 = ccs.geteCO2(); eCO2 = ccs.geteCO2();
CCS811_ready = 1; 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; ecnt = 0;
} }
} else { } else {