Add parameter tvoc_raw for SGP41

This commit is contained in:
Phat Nguyen
2024-02-17 13:36:32 +07:00
parent b475c5c1ec
commit 23513cf88c
4 changed files with 28 additions and 6 deletions

View File

@ -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);
}
/**