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

@ -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; }

View File

@ -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;