diff --git a/examples/ONE_I-9PSL/ONE_I-9PSL.ino b/examples/ONE_I-9PSL/ONE_I-9PSL.ino index 3c53838..941dbbd 100644 --- a/examples/ONE_I-9PSL/ONE_I-9PSL.ino +++ b/examples/ONE_I-9PSL/ONE_I-9PSL.ino @@ -60,7 +60,7 @@ enum { APP_SM_WIFI_MANAGER_STA_CONNECTED, /** Connecting to WiFi worked */ APP_SM_WIFI_OK_SERVER_CONNECTING, /** Once connected to WiFi an attempt to reach the server is performed */ - APP_SM_WIFI_OK_SERVER_CONNECTED, /** Server is reachable, all fine */ + APP_SM_WIFI_OK_SERVER_CONNECTED, /** Server is reachable, all fine */ /** Exceptions during WIFi Setup */ APP_SM_WIFI_MANAGER_CONNECT_FAILED, /** Cannot connect to WiFi (e.g. wrong password, WPA Enterprise etc.) */ @@ -446,6 +446,7 @@ static int ledSmState = APP_SM_NORMAL; /** Save display SM */ static int dispSmState = APP_SM_NORMAL; /** Save LED SM */ static int tvocIndex = -1; +static int tvocRawIndex = -1; static int noxIndex = -1; static int co2Ppm = -1; static int pm25 = -1; @@ -1440,10 +1441,12 @@ static void updateDispLedBar(void) { */ static void tvocPoll(void) { tvocIndex = ag.sgp41.getTvocIndex(); + tvocRawIndex = ag.sgp41.getTvocRaw(); noxIndex = ag.sgp41.getNoxIndex(); - Serial.printf("tvocIndexindex: %d\r\n", tvocIndex); - Serial.printf(" NOx index: %d\r\n", noxIndex); + Serial.printf(" TVOC index: %d\r\n", tvocIndex); + Serial.printf("TVOC raw index: %d\r\n", tvocRawIndex); + Serial.printf(" NOx index: %d\r\n", noxIndex); } /** @@ -1494,6 +1497,9 @@ static void sendDataToServer(void) { if (tvocIndex >= 0) { root["tvoc_index"] = tvocIndex; } + if (tvocRawIndex >= 0) { + root["tvoc_raw"] = tvocRawIndex; + } if (noxIndex >= 0) { root["noxIndex"] = noxIndex; } diff --git a/examples/Open_Air/Open_Air.ino b/examples/Open_Air/Open_Air.ino index 87e2979..99d5002 100644 --- a/examples/Open_Air/Open_Air.ino +++ b/examples/Open_Air/Open_Air.ino @@ -57,7 +57,7 @@ enum { APP_SM_WIFI_MANAGER_STA_CONNECTED, /** Connecting to WiFi worked */ APP_SM_WIFI_OK_SERVER_CONNECTING, /** Once connected to WiFi an attempt to reach the server is performed */ - APP_SM_WIFI_OK_SERVER_CONNECTED, /** Server is reachable, all fine */ + APP_SM_WIFI_OK_SERVER_CONNECTED, /** Server is reachable, all fine */ /** Exceptions during WIFi Setup */ APP_SM_WIFI_MANAGER_CONNECT_FAILED, /** Cannot connect to WiFi (e.g. wrong password, WPA Enterprise etc.) */ @@ -408,6 +408,7 @@ static bool wifiHasConfig = false; static String wifiSSID = ""; int tvocIndex = -1; +int tvocRawIndex = -1; int noxIndex = -1; int co2Ppm = 0; @@ -554,6 +555,9 @@ static void sendDataToServer(void) { if (tvocIndex > 0) { root["tvoc_index"] = loopCount; } + if (tvocRawIndex >= 0) { + root["tvoc_raw"] = tvocRawIndex; + } if (noxIndex > 0) { root["nox_index"] = loopCount; } @@ -769,10 +773,12 @@ static void updateWiFiConnect(void) { */ static void tvocPoll(void) { tvocIndex = ag.sgp41.getTvocIndex(); + tvocRawIndex = ag.sgp41.getTvocRaw(); noxIndex = ag.sgp41.getNoxIndex(); - Serial.printf("tvocIndexindex: %d\r\n", tvocIndex); - Serial.printf(" NOx index: %d\r\n", noxIndex); + Serial.printf(" TVOC index: %d\r\n", tvocIndex); + Serial.printf("TVOC raw index: %d\r\n", tvocRawIndex); + Serial.printf(" NOx index: %d\r\n", noxIndex); } /** diff --git a/src/sgp41/sgp41.cpp b/src/sgp41/sgp41.cpp index c86ba58..ea3d4ae 100644 --- a/src/sgp41/sgp41.cpp +++ b/src/sgp41/sgp41.cpp @@ -120,6 +120,7 @@ void Sgp41::_handle(void) { for (;;) { vTaskDelay(pdMS_TO_TICKS(1000)); if (getRawSignal(srawVoc, srawNox)) { + tvocRaw = srawVoc; nox = noxAlgorithm()->process(srawNox); tvoc = vocAlgorithm()->process(srawVoc); AgLog("Polling SGP41 success: tvoc: %d, nox: %d", tvoc, nox); @@ -241,3 +242,10 @@ bool Sgp41::_noxConditioning(void) { err = sgpSensor()->executeConditioning(defaultRh, defaultT, srawVoc); return (err == 0); } + +/** + * @brief Get TVOC raw value + * + * @return int + */ +int Sgp41::getTvocRaw(void) { return tvocRaw; } diff --git a/src/sgp41/sgp41.h b/src/sgp41/sgp41.h index f26b343..5c58de1 100644 --- a/src/sgp41/sgp41.h +++ b/src/sgp41/sgp41.h @@ -23,6 +23,7 @@ public: void end(void); int getTvocIndex(void); int getNoxIndex(void); + int getTvocRaw(void); private: bool onConditioning = true; @@ -36,6 +37,7 @@ private: uint16_t defaultRh = 0x8000; uint16_t defaultT = 0x6666; int tvoc = 0; + int tvocRaw; int nox = 0; #if defined(ESP8266) uint32_t conditioningPeriod;