read temp every minute and publish only if difference is more than 0.2
This commit is contained in:
parent
fe5552a0b1
commit
fa11355767
@ -19,7 +19,7 @@ namespace Mqtt {
|
||||
void disconnect();
|
||||
Task tReConnect(5 * TASK_MINUTE, TASK_FOREVER, connect, &ts);
|
||||
Task tPublishInit(TASK_IMMEDIATE, TASK_ONCE, publishInit, &ts);
|
||||
Task tPublishBmp(5 * TASK_MINUTE, TASK_FOREVER, publishBmp280, &ts);
|
||||
Task tPublishBmp(TASK_MINUTE, TASK_FOREVER, publishBmp280, &ts);
|
||||
Task tPublishCommand(TASK_SECOND, TASK_FOREVER, publishCommand, &ts);
|
||||
|
||||
AsyncMqttClient client;
|
||||
@ -120,7 +120,11 @@ namespace Mqtt {
|
||||
}
|
||||
|
||||
void publishBmp280() {
|
||||
static float lastTemp = 0;
|
||||
Bmp::data.readAll();
|
||||
if (abs(lastTemp - Bmp::data.temp) <= 0.2) return;
|
||||
lastTemp = Bmp::data.temp;
|
||||
Display::displayTemp(Bmp::data.temp);
|
||||
StaticJsonDocument<255> jsonDoc;
|
||||
jsonDoc["temperature"] = Bmp::data.temp;
|
||||
jsonDoc["pressure"] = Bmp::data.pressure;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user