mirror of
https://github.com/airgradienthq/arduino.git
synced 2025-07-15 00:46:31 +02:00
Add parameter tvoc_raw
for SGP41
This commit is contained in:
@ -60,7 +60,7 @@ enum {
|
|||||||
APP_SM_WIFI_MANAGER_STA_CONNECTED, /** Connecting to WiFi worked */
|
APP_SM_WIFI_MANAGER_STA_CONNECTED, /** Connecting to WiFi worked */
|
||||||
APP_SM_WIFI_OK_SERVER_CONNECTING, /** Once connected to WiFi an attempt to
|
APP_SM_WIFI_OK_SERVER_CONNECTING, /** Once connected to WiFi an attempt to
|
||||||
reach the server is performed */
|
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 */
|
/** Exceptions during WIFi Setup */
|
||||||
APP_SM_WIFI_MANAGER_CONNECT_FAILED, /** Cannot connect to WiFi (e.g. wrong
|
APP_SM_WIFI_MANAGER_CONNECT_FAILED, /** Cannot connect to WiFi (e.g. wrong
|
||||||
password, WPA Enterprise etc.) */
|
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 dispSmState = APP_SM_NORMAL; /** Save LED SM */
|
||||||
|
|
||||||
static int tvocIndex = -1;
|
static int tvocIndex = -1;
|
||||||
|
static int tvocRawIndex = -1;
|
||||||
static int noxIndex = -1;
|
static int noxIndex = -1;
|
||||||
static int co2Ppm = -1;
|
static int co2Ppm = -1;
|
||||||
static int pm25 = -1;
|
static int pm25 = -1;
|
||||||
@ -1440,10 +1441,12 @@ static void updateDispLedBar(void) {
|
|||||||
*/
|
*/
|
||||||
static void tvocPoll(void) {
|
static void tvocPoll(void) {
|
||||||
tvocIndex = ag.sgp41.getTvocIndex();
|
tvocIndex = ag.sgp41.getTvocIndex();
|
||||||
|
tvocRawIndex = ag.sgp41.getTvocRaw();
|
||||||
noxIndex = ag.sgp41.getNoxIndex();
|
noxIndex = ag.sgp41.getNoxIndex();
|
||||||
|
|
||||||
Serial.printf("tvocIndexindex: %d\r\n", tvocIndex);
|
Serial.printf(" TVOC index: %d\r\n", tvocIndex);
|
||||||
Serial.printf(" NOx index: %d\r\n", noxIndex);
|
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) {
|
if (tvocIndex >= 0) {
|
||||||
root["tvoc_index"] = tvocIndex;
|
root["tvoc_index"] = tvocIndex;
|
||||||
}
|
}
|
||||||
|
if (tvocRawIndex >= 0) {
|
||||||
|
root["tvoc_raw"] = tvocRawIndex;
|
||||||
|
}
|
||||||
if (noxIndex >= 0) {
|
if (noxIndex >= 0) {
|
||||||
root["noxIndex"] = noxIndex;
|
root["noxIndex"] = noxIndex;
|
||||||
}
|
}
|
||||||
|
@ -57,7 +57,7 @@ enum {
|
|||||||
APP_SM_WIFI_MANAGER_STA_CONNECTED, /** Connecting to WiFi worked */
|
APP_SM_WIFI_MANAGER_STA_CONNECTED, /** Connecting to WiFi worked */
|
||||||
APP_SM_WIFI_OK_SERVER_CONNECTING, /** Once connected to WiFi an attempt to
|
APP_SM_WIFI_OK_SERVER_CONNECTING, /** Once connected to WiFi an attempt to
|
||||||
reach the server is performed */
|
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 */
|
/** Exceptions during WIFi Setup */
|
||||||
APP_SM_WIFI_MANAGER_CONNECT_FAILED, /** Cannot connect to WiFi (e.g. wrong
|
APP_SM_WIFI_MANAGER_CONNECT_FAILED, /** Cannot connect to WiFi (e.g. wrong
|
||||||
password, WPA Enterprise etc.) */
|
password, WPA Enterprise etc.) */
|
||||||
@ -408,6 +408,7 @@ static bool wifiHasConfig = false;
|
|||||||
static String wifiSSID = "";
|
static String wifiSSID = "";
|
||||||
|
|
||||||
int tvocIndex = -1;
|
int tvocIndex = -1;
|
||||||
|
int tvocRawIndex = -1;
|
||||||
int noxIndex = -1;
|
int noxIndex = -1;
|
||||||
int co2Ppm = 0;
|
int co2Ppm = 0;
|
||||||
|
|
||||||
@ -554,6 +555,9 @@ static void sendDataToServer(void) {
|
|||||||
if (tvocIndex > 0) {
|
if (tvocIndex > 0) {
|
||||||
root["tvoc_index"] = loopCount;
|
root["tvoc_index"] = loopCount;
|
||||||
}
|
}
|
||||||
|
if (tvocRawIndex >= 0) {
|
||||||
|
root["tvoc_raw"] = tvocRawIndex;
|
||||||
|
}
|
||||||
if (noxIndex > 0) {
|
if (noxIndex > 0) {
|
||||||
root["nox_index"] = loopCount;
|
root["nox_index"] = loopCount;
|
||||||
}
|
}
|
||||||
@ -769,10 +773,12 @@ static void updateWiFiConnect(void) {
|
|||||||
*/
|
*/
|
||||||
static void tvocPoll(void) {
|
static void tvocPoll(void) {
|
||||||
tvocIndex = ag.sgp41.getTvocIndex();
|
tvocIndex = ag.sgp41.getTvocIndex();
|
||||||
|
tvocRawIndex = ag.sgp41.getTvocRaw();
|
||||||
noxIndex = ag.sgp41.getNoxIndex();
|
noxIndex = ag.sgp41.getNoxIndex();
|
||||||
|
|
||||||
Serial.printf("tvocIndexindex: %d\r\n", tvocIndex);
|
Serial.printf(" TVOC index: %d\r\n", tvocIndex);
|
||||||
Serial.printf(" NOx index: %d\r\n", noxIndex);
|
Serial.printf("TVOC raw index: %d\r\n", tvocRawIndex);
|
||||||
|
Serial.printf(" NOx index: %d\r\n", noxIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -120,6 +120,7 @@ void Sgp41::_handle(void) {
|
|||||||
for (;;) {
|
for (;;) {
|
||||||
vTaskDelay(pdMS_TO_TICKS(1000));
|
vTaskDelay(pdMS_TO_TICKS(1000));
|
||||||
if (getRawSignal(srawVoc, srawNox)) {
|
if (getRawSignal(srawVoc, srawNox)) {
|
||||||
|
tvocRaw = srawVoc;
|
||||||
nox = noxAlgorithm()->process(srawNox);
|
nox = noxAlgorithm()->process(srawNox);
|
||||||
tvoc = vocAlgorithm()->process(srawVoc);
|
tvoc = vocAlgorithm()->process(srawVoc);
|
||||||
AgLog("Polling SGP41 success: tvoc: %d, nox: %d", tvoc, nox);
|
AgLog("Polling SGP41 success: tvoc: %d, nox: %d", tvoc, nox);
|
||||||
@ -241,3 +242,10 @@ bool Sgp41::_noxConditioning(void) {
|
|||||||
err = sgpSensor()->executeConditioning(defaultRh, defaultT, srawVoc);
|
err = sgpSensor()->executeConditioning(defaultRh, defaultT, srawVoc);
|
||||||
return (err == 0);
|
return (err == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get TVOC raw value
|
||||||
|
*
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
int Sgp41::getTvocRaw(void) { return tvocRaw; }
|
||||||
|
@ -23,6 +23,7 @@ public:
|
|||||||
void end(void);
|
void end(void);
|
||||||
int getTvocIndex(void);
|
int getTvocIndex(void);
|
||||||
int getNoxIndex(void);
|
int getNoxIndex(void);
|
||||||
|
int getTvocRaw(void);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool onConditioning = true;
|
bool onConditioning = true;
|
||||||
@ -36,6 +37,7 @@ private:
|
|||||||
uint16_t defaultRh = 0x8000;
|
uint16_t defaultRh = 0x8000;
|
||||||
uint16_t defaultT = 0x6666;
|
uint16_t defaultT = 0x6666;
|
||||||
int tvoc = 0;
|
int tvoc = 0;
|
||||||
|
int tvocRaw;
|
||||||
int nox = 0;
|
int nox = 0;
|
||||||
#if defined(ESP8266)
|
#if defined(ESP8266)
|
||||||
uint32_t conditioningPeriod;
|
uint32_t conditioningPeriod;
|
||||||
|
Reference in New Issue
Block a user