V 1.40 funtioniert soweit, Temperatur zu hoch wg. Aufwärmung

This commit is contained in:
rxf
2024-08-22 07:53:34 +02:00
parent eb1a102120
commit 8de24db46d
8 changed files with 44 additions and 9 deletions

BIN
CYD_Bad.tgz Normal file

Binary file not shown.

View File

@@ -12,12 +12,12 @@
platform = espressif32 platform = espressif32
board = esp32dev board = esp32dev
framework = arduino framework = arduino
lib_compat_mode = strict
lib_deps = lib_deps =
https://github.com/me-no-dev/AsyncTCP/archive/refs/heads/master.zip
https://github.com/marvinroger/async-mqtt-client/archive/refs/heads/develop.zip
bblanchon/ArduinoJson@^7.1.0 bblanchon/ArduinoJson@^7.1.0
adafruit/Adafruit BME280 Library@^2.2.4 adafruit/Adafruit BME280 Library@^2.2.4
lvgl/lvgl@^9.1.0 lvgl/lvgl@^9.1.0
bodmer/TFT_eSPI@^2.5.43 bodmer/TFT_eSPI@^2.5.43
knolleary/PubSubClient@^2.8 knolleary/PubSubClient@^2.8
ayushsharma82/ElegantOTA@^3.1.5
monitor_speed = 115200 monitor_speed = 115200

View File

@@ -22,7 +22,7 @@
#include <TFT_eSPI.h> #include <TFT_eSPI.h>
#include "Weifi.h" #include "weifi.h"
#include "mqtt.h" #include "mqtt.h"
#include "handlebme280.h" #include "handlebme280.h"
#include "grafik.h" #include "grafik.h"
@@ -49,6 +49,13 @@ void setUpdatetime(int time) {
updateTime = time * 1000; updateTime = time * 1000;
} }
char * getChipID(void) {
static char chipid[20];
uint64_t chipid64 = ESP.getEfuseMac();
sprintf(chipid, "%04X%08X", (uint16_t)(chipid64 >> 32), (uint32_t)chipid64);
return chipid;
}
void setup() { void setup() {
setlocale(LC_ALL, "de_DE"); setlocale(LC_ALL, "de_DE");
String LVGL_Arduino = String("LVGL Library Version: ") + lv_version_major() + "." + lv_version_minor() + "." + lv_version_patch(); String LVGL_Arduino = String("LVGL Library Version: ") + lv_version_major() + "." + lv_version_minor() + "." + lv_version_patch();
@@ -107,7 +114,7 @@ void loop() {
if (millis() - bmeReadtimer > bmeReadTime) { if (millis() - bmeReadtimer > bmeReadTime) {
bmeReadtimer = millis(); bmeReadtimer = millis();
bmedata = readBME280(); bmedata = readBME280();
doPublish(bmedata.temp+arcTemp.value_offset, bmedata.hum+arcHum.value_offset); doPublish(bmedata.temp+arcTemp.value_offset, bmedata.hum+arcHum.value_offset, bmedata.temp, bmedata.hum);
} }
if (millis() - updatetimer > updateTime) { if (millis() - updatetimer > updateTime) {
updatetimer = millis(); updatetimer = millis();
@@ -122,6 +129,10 @@ void loop() {
} }
client.loop(); client.loop();
server.handleClient();
ElegantOTA.loop();
lv_task_handler(); // let the GUI do its work lv_task_handler(); // let the GUI do its work
lv_tick_inc(5); // tell LVGL how much time has passed lv_tick_inc(5); // tell LVGL how much time has passed
delay(5); // let this time pass delay(5); // let this time pass

View File

@@ -27,6 +27,7 @@ extern struct tm timeinfo;
#endif #endif
void setBMEreadtime(int time); void setBMEreadtime(int time);
char * getChipID(void);
#endif #endif

View File

@@ -75,11 +75,13 @@ void reconnect(void)
client.subscribe(MQTT_TOPIC "#"); client.subscribe(MQTT_TOPIC "#");
} }
void doPublish(float temp, float hum) { void doPublish(float temp, float hum, float tm, float hm) {
char payload[50]; char payload[50];
sprintf(payload, "{\"temperature\":%.1f,\"humidity\":%.1f}", temp, hum); sprintf(payload, "{\"temperature\":%.1f,\"tempmess\":%.1f,\"humidity\":%.1f,\"hummess\":%.1f}", temp, hum, tm, hm);
char * chipID = getChipID();
client.publish(MQTT_PUB_TEMP, payload); char topic[50];
sprintf(topic, "CYD/get/%s/bme280", chipID);
client.publish(topic, payload);
Serial.printf("Published: %s %s\n", MQTT_PUB_TEMP, payload); Serial.printf("Published: %s %s\n", MQTT_PUB_TEMP, payload);
} }

View File

@@ -26,6 +26,6 @@ extern PubSubClient client;
void reconnect(void); void reconnect(void);
void doPublish(float temp, float hum); void doPublish(float temp, float hum, float tm, float hm);
void checkMQTT(void); void checkMQTT(void);
void setup_mqtt(void); void setup_mqtt(void);

View File

@@ -4,6 +4,7 @@
#include "mqtt.h" #include "mqtt.h"
#include "main.h" #include "main.h"
struct tm gettheTime(int repeat) { struct tm gettheTime(int repeat) {
if(!getLocalTime(&timeinfo)){ if(!getLocalTime(&timeinfo)){
Serial.println("Failed to obtain time"); Serial.println("Failed to obtain time");
@@ -56,9 +57,19 @@ void connectToWifi() {
configTime(gmtOffset_sec, daylightOffset_sec, ntpServer); configTime(gmtOffset_sec, daylightOffset_sec, ntpServer);
printLocalTime(); printLocalTime();
server.on("/", []() {
server.send(200, "text/plain", "Hi! This is ElegantOTA Demo.");
});
ElegantOTA.begin(&server); // Start ElegantOTA
server.begin();
Serial.println("HTTP server started");
} }
/* /*
void WiFiEvent(WiFiEvent_t event) { void WiFiEvent(WiFiEvent_t event) {
Serial.printf("[WiFi-event] event: %d\n", event); Serial.printf("[WiFi-event] event: %d\n", event);

View File

@@ -2,6 +2,11 @@
#define WEIFI_H #define WEIFI_H
#include <WiFi.h> #include <WiFi.h>
#include <WiFiClient.h>
#include <WebServer.h>
#include <ElegantOTA.h>
#include "time.h" #include "time.h"
#include "config.h" #include "config.h"
@@ -14,6 +19,11 @@ const char *ntpServer = "pool.ntp.org";
const long gmtOffset_sec = 3600; const long gmtOffset_sec = 3600;
const int daylightOffset_sec = 3600; const int daylightOffset_sec = 3600;
WebServer server(80);
#else
extern WebServer server;
#endif #endif