43 GeneralPurposeMeasurement* getNOXchannel() {
49 if (millis() - lastReadTime > 1000) {
50 readValuesFromDevice();
51 lastReadTime = millis();
56 void readValuesFromDevice() {
58 float temperature = TEMPERATURE_NOT_AVAILABLE;
59 float humidity = HUMIDITY_NOT_AVAILABLE;
61 temperature = th->getChannel()->getLastTemperature();
62 humidity = th->getChannel()->getValueDoubleSecond();
67 if (temperature >= -45 && temperature <= 130) {
68 compensationT =
static_cast<uint16_t
>((temperature + 45) * 65535 / 175);
70 compensationT = defaultCompenstaionT;
73 if (humidity >= 0 && humidity <= 100) {
74 compensationRh =
static_cast<uint16_t
>(humidity * 65535 / 100);
76 compensationRh = defaultCompenstaionRh;
79 if (skipFirstReadingsCounter > 0) {
80 error = sgp.executeConditioning(compensationRh, compensationT, srawVoc);
81 skipFirstReadingsCounter--;
83 error = sgp.measureRawSignals(compensationRh, compensationT, srawVoc,
88 if (retryCount <= 10) {
91 if (retryCount > 10) {
103 uint16_t defaultCompenstaionRh = 0x8000;
104 uint16_t defaultCompenstaionT = 0x6666;
105 uint16_t compensationRh = 0;
106 uint16_t compensationT = 0;
107 int8_t retryCount = 0;
108 ::SensirionI2CSgp41 sgp;
109 GeneralPurposeMeasurement *vocchannel =
nullptr;
110 GeneralPurposeMeasurement *noxchannel =
nullptr;
111 ThermHygroMeter *th =
nullptr;
112 uint32_t lastReadTime = 0;
113 int skipFirstReadingsCounter = 10;
virtual void setValue(const double &value)
Method used to set new value for channel with driver which accepts MeasurementDriver::setValue() meth...
Definition general_purpose_channel_base.cpp:560