V1.3.1 - MQTT published BME-Werte

This commit is contained in:
rxf
2024-07-22 18:03:22 +02:00
parent ad9d426a23
commit bcba2bc319
6 changed files with 112 additions and 48 deletions

View File

@@ -30,11 +30,10 @@
#include <locale.h>
#define BMWREADTIME 10000
#define NTPREADTIME 1000
long bmeReadtimer = 0;
long ntpReadtimer = 0;
long updatetimer = 0;
BME280Data bmedata;
@@ -42,6 +41,14 @@ int currentSecond = -1;
void showDateTime(struct tm tinfo);
void setBMEreadtime(int time) {
bmeReadTime = time * 1000;
}
void setUpdatetime(int time) {
updateTime = time * 1000;
}
void setup() {
setlocale(LC_ALL, "de_DE");
String LVGL_Arduino = String("LVGL Library Version: ") + lv_version_major() + "." + lv_version_minor() + "." + lv_version_patch();
@@ -98,14 +105,18 @@ void loop() {
if (timeinfo.tm_sec == 0) { // minute over
showDateTime(timeinfo);
}
if (millis() - bmeReadtimer > BMWREADTIME) {
if (millis() - bmeReadtimer > bmeReadTime) {
bmeReadtimer = millis();
bmedata = readBME280();
publishMQTTmessage(bmedata.temp, bmedata.hum);
}
if (millis() - updatetimer > updateTime) {
updatetimer = millis();
updatechartData(bmedata.temp, bmedata.hum);
setValuetoArc(arcTemp, bmedata.temp);
setValuetoArc(arcHum, bmedata.hum);
updatechartData(bmedata.temp, bmedata.hum);
}
lv_task_handler(); // let the GUI do its work
lv_tick_inc(5); // tell LVGL how much time has passed
delay(5); // let this time pass