From 0612154ebc2122044b109bc5000f262b9ed7975b Mon Sep 17 00:00:00 2001 From: hans-jurgen Date: Wed, 25 Sep 2024 13:09:30 +0200 Subject: [PATCH] =?UTF-8?q?2024-09-2500=20Wohnzimmer=20Anzeige=20ge=C3=A4n?= =?UTF-8?q?dert?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- platformio.ini | 7 ++++--- src/main.cpp | 35 +++++++++++++++++++++++++++++++---- 2 files changed, 35 insertions(+), 7 deletions(-) diff --git a/platformio.ini b/platformio.ini index 58ef445..34e6e29 100644 --- a/platformio.ini +++ b/platformio.ini @@ -13,14 +13,14 @@ platform = espressif32 board = nodemcu-32s framework = arduino monitor_speed = 115200 -monitor_port = COM3 +monitor_port = /dev/ttyACM0 monitor_filters = time -upload_port = COM3 +upload_port = /dev/ttyACM0 lib_deps = knolleary/PubSubClient @ 2.8 adafruit/Adafruit GFX Library @ 1.11.3 2dom/PxMatrix LED MATRIX library @ 1.8.2 - adafruit/Adafruit BusIO @ 1.7.2 + adafruit/Adafruit BusIO @ 1.16.1 build_flags = -DSCAN=32 @@ -40,6 +40,7 @@ build_flags = ${env.build_flags} -Dmqtt_server=\"hjkmqtt.dedyn.io\" -Dmqtt_port=61883 -DINNEN=\"hjk/devices/TEMPWOHNZIM/telemetry/temperature\" + -DHUNIDITY=\"hjk/devices/TEMPWOHNZIM/telemetry/humidity\" -DFLUR=\"hjk/devices/TEMPFLUR/telemetry/temperature\" -DCO2=\"hjk/devices/257923/telemetry/co2\" -DAKKU=\"hjk/devices/WETTERSTATION/telemetry/battery\" diff --git a/src/main.cpp b/src/main.cpp index 892af11..797fa03 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -126,6 +126,7 @@ int Pressure = 0; float TempWohn = -99.90; float TempFlur = -99.99; float Luftfeuchtigkeit = 0.00; +float LuftfeuchtigkeitWohnug = 0.00; float Akku = -99.00; int Helligkeit = 255; @@ -149,6 +150,7 @@ const char* topic_Wetter = WETTER; const char* topic_Pressure = LUFTDRUCK; const char* topic_Luftfeuchtigkeit = FEUCHTIGKEIT; const char* topic_Helligkeit = HELLIGKEIT; +const char* topic_Humidity = HUNIDITY; #ifdef FLUR const char* topic_Flur = FLUR; #endif @@ -291,6 +293,12 @@ void callback(char* topic1, byte* payload, unsigned int length) { Serial.println(" %"); Luftfeuchtigkeit = atof(msg); } + if(strcmp(topic1, topic_Humidity)== 0){ + Serial.print("Luftfeuchtigkeit Wohnung: "); + Serial.print(msg); + Serial.println(" %"); + LuftfeuchtigkeitWohnug = atof(msg); + } if(strcmp(topic1, topic_Akku)== 0){ Serial.print("Wetterstation Akku: "); Serial.print(msg); @@ -326,10 +334,9 @@ void reconnect() { client.subscribe(topic_Flur); #endif client.subscribe(topic_Luftfeuchtigkeit); + client.subscribe(topic_Humidity); client.subscribe(topic_Akku); client.subscribe(topic_Helligkeit); - //client.subscribe("hjk/devices/WETTERSTATIONBORIS/telemetry/#"); - //client.subscribe("hjk/devices/MESSUNITTEMPBORIS/telemetry/#"); } else { Serial.print("failed, rc="); Serial.print(client.state()); @@ -460,6 +467,22 @@ void ZeigeWetter(double Wetter1, int yPos = 2, int xPos = 1) display.print("C"); } } +void ZeigeFeuchtigkeit(double Wetter1, int yPos = 2, int xPos = 1) +{ + if (xPos < 2) xPos = 2; + if (yPos < 0) yPos = 0; + if (Wetter1 > -99.9){ + char szWetter[10]; + //Serial.print("Aussentemperatur: "); Serial.println(Wetter1,3); + dtostrf(Wetter1, 4, 1, szWetter); + display.setCursor(xPos, yPos); + display.fillRect(xPos, yPos-2, 64-xPos, 8+2, (myBLACK)); + display.setTextColor(myBLUE); + display.print(szWetter); + display.print(" %"); + + } +} void Test() { display.setCursor(1, 40); @@ -740,7 +763,7 @@ void loop() { ZeigeDatum(timeinfo, 1, 1); ZeigeZeit(timeinfo, TimeX, TimeY); //ZeigeZeit(timeinfo, 1,40); - ZeigeCO(1,CoY); + //ZeigeCO(1,CoY); /* if ((timeinfo.tm_min % 10) == 0){ /* if (Covid19 != 0){ scroll_text(matrix_height-8,20,"Landkreis Heilbronn", 30,30,30, true); @@ -772,7 +795,11 @@ void loop() { scroll_text2(matrix_height-24,20,"ich w\201nsche Euch allen ein", 128,128,0, true); scroll_text2(matrix_height-24,20,"Frohes neues Jahr 2022.", 128,255,0, true); */ - ZeigeWetter(double(TempWohn), WetterY,WetterX); + if (timeinfo.tm_min %2 != 0){ + ZeigeWetter(double(TempWohn), WetterY,WetterX); + }else { + ZeigeFeuchtigkeit(double(LuftfeuchtigkeitWohnug), WetterY,WetterX); + } //Serial.println("START"); if (Aussentemp > -99.9){ char szWetter[10];