Compare commits

...

No commits in common. "main" and "master" have entirely different histories.
main ... master

6 changed files with 1085 additions and 1034 deletions

View File

@ -13,14 +13,14 @@ platform = espressif32
board = nodemcu-32s board = nodemcu-32s
framework = arduino framework = arduino
monitor_speed = 115200 monitor_speed = 115200
monitor_port = COM3 monitor_port = /dev/ttyACM0
monitor_filters = time monitor_filters = time
upload_port = COM3 upload_port = /dev/ttyACM0
lib_deps = lib_deps =
knolleary/PubSubClient @ 2.8 knolleary/PubSubClient @ 2.8
adafruit/Adafruit GFX Library @ 1.11.3 adafruit/Adafruit GFX Library @ 1.11.3
2dom/PxMatrix LED MATRIX library @ 1.8.2 2dom/PxMatrix LED MATRIX library @ 1.8.2
adafruit/Adafruit BusIO @ 1.7.2 adafruit/Adafruit BusIO @ 1.16.1
build_flags = build_flags =
-DSCAN=32 -DSCAN=32
@ -29,7 +29,7 @@ build_flags =
[env:debug] ; Entwicklungssystem [env:debug] ; Entwicklungssystem
build_flags = ${env.build_flags} build_flags = ${env.build_flags}
-DDEBUG=1 -DDEBUG=1
-DGRENZWERT=3.60 -DGRENZWERT=3.70
-DSTASSID=\"MagentaWLAN-RGDO\" -DSTASSID=\"MagentaWLAN-RGDO\"
-DSTAPSK=\"93329248424922704583\" -DSTAPSK=\"93329248424922704583\"
-DGATEWAY=\"192.168.127.1\" -DGATEWAY=\"192.168.127.1\"
@ -40,7 +40,8 @@ build_flags = ${env.build_flags}
-Dmqtt_server=\"hjkmqtt.dedyn.io\" -Dmqtt_server=\"hjkmqtt.dedyn.io\"
-Dmqtt_port=61883 -Dmqtt_port=61883
-DINNEN=\"hjk/devices/TEMPWOHNZIM/telemetry/temperature\" -DINNEN=\"hjk/devices/TEMPWOHNZIM/telemetry/temperature\"
-DFLUR=\"hjk/devices/TEMPFLUR/telemetry/temperature\" -DHUNIDITY=\"hjk/devices/TEMPWOHNZIM/telemetry/humidity\"
;-DFLUR=\"hjk/devices/TEMPFLUR/telemetry/temperature\"
-DCO2=\"hjk/devices/257923/telemetry/co2\" -DCO2=\"hjk/devices/257923/telemetry/co2\"
-DAKKU=\"hjk/devices/WETTERSTATION/telemetry/battery\" -DAKKU=\"hjk/devices/WETTERSTATION/telemetry/battery\"
-DWETTER=\"hjk/devices/WETTERSTATION/telemetry/temperature_Htu_21\" -DWETTER=\"hjk/devices/WETTERSTATION/telemetry/temperature_Htu_21\"
@ -67,3 +68,4 @@ build_flags = ${env.build_flags}
-DLUFTDRUCK=\"hjk/devices/WETTERSTATIONBORIS/telemetry/pressure\" -DLUFTDRUCK=\"hjk/devices/WETTERSTATIONBORIS/telemetry/pressure\"
-DFEUCHTIGKEIT=\"hjk/devices/WETTERSTATIONBORIS/telemetry/humity\" -DFEUCHTIGKEIT=\"hjk/devices/WETTERSTATIONBORIS/telemetry/humity\"
-DHELLIGKEIT=\"hjk/devices/WETTERSTATIONBORIS/telemetry/Lux\" -DHELLIGKEIT=\"hjk/devices/WETTERSTATIONBORIS/telemetry/Lux\"
-DHUNIDITY=\"hjk/devices/TEMPWOHNZIM/telemetry/humidity\"

View File

@ -1,4 +1,3 @@
#include <Arduino.h> #include <Arduino.h>
// This is how many color levels the display shows - the more the slower the update // This is how many color levels the display shows - the more the slower the update
@ -48,7 +47,7 @@ Ticker display_ticker;
#endif #endif
#define MaxErrCount 30 #define MaxErrCount 30
const unsigned long stoerung = 15 * 60000000UL; // Minuten * Mikrosekunden für Sleep Mode const unsigned long stoerung = 1 * 60000000UL; // Minuten * Mikrosekunden für Sleep Mode
unsigned long startTime; unsigned long startTime;
unsigned long endTime; unsigned long endTime;
#include <Wire.h> #include <Wire.h>
@ -100,7 +99,7 @@ IPAddress gateway;
IPAddress subnet; IPAddress subnet;
IPAddress dns; // DNS-Server IPAddress dns; // DNS-Server
IPAddress secondarDNS; IPAddress secondarDNS;
String hostname = "GROSSZEICHENDISPLAY"; String hostname = "GROSSZEICHBORIS";
int status = WL_IDLE_STATUS; int status = WL_IDLE_STATUS;
const char* NTP_SERVER = "de.pool.ntp.org"; const char* NTP_SERVER = "de.pool.ntp.org";
const char* TZ_INFO = "CET-1CEST-2,M3.5.0/02:00:00,M10.5.0/03:00:00"; // enter your time zone (https://remotemonitoringsystems.ca/time-zone-abbreviations.php) const char* TZ_INFO = "CET-1CEST-2,M3.5.0/02:00:00,M10.5.0/03:00:00"; // enter your time zone (https://remotemonitoringsystems.ca/time-zone-abbreviations.php)
@ -116,7 +115,7 @@ const int TimeX = 1;
const int WetterY = 32; const int WetterY = 32;
const int WetterX = 18; const int WetterX = 18;
const int CoY = 43; const int CoY = 41;
@ -127,6 +126,7 @@ int Pressure = 0;
float TempWohn = -99.90; float TempWohn = -99.90;
float TempFlur = -99.99; float TempFlur = -99.99;
float Luftfeuchtigkeit = 0.00; float Luftfeuchtigkeit = 0.00;
float LuftfeuchtigkeitWohnug = 0.00;
float Akku = -99.00; float Akku = -99.00;
int Helligkeit = 255; int Helligkeit = 255;
@ -150,6 +150,7 @@ const char* topic_Wetter = WETTER;
const char* topic_Pressure = LUFTDRUCK; const char* topic_Pressure = LUFTDRUCK;
const char* topic_Luftfeuchtigkeit = FEUCHTIGKEIT; const char* topic_Luftfeuchtigkeit = FEUCHTIGKEIT;
const char* topic_Helligkeit = HELLIGKEIT; const char* topic_Helligkeit = HELLIGKEIT;
const char* topic_Humidity = HUNIDITY;
#ifdef FLUR #ifdef FLUR
const char* topic_Flur = FLUR; const char* topic_Flur = FLUR;
#endif #endif
@ -162,7 +163,6 @@ void scroll_text2(uint8_t ypos, unsigned long scroll_delay, String text, uint8_t
void scroll_Grad(uint8_t ypos, unsigned long scroll_delay, String text, uint8_t colorR, uint8_t colorG, uint8_t colorB, boolean blink); void scroll_Grad(uint8_t ypos, unsigned long scroll_delay, String text, uint8_t colorR, uint8_t colorG, uint8_t colorB, boolean blink);
bool getNTPtime(int sec); bool getNTPtime(int sec);
void showTime(tm localTime); void showTime(tm localTime);
void writeLinie();
static uint32_t lastTime = 0; // millis() memory static uint32_t lastTime = 0; // millis() memory
static void setup_wifi(); static void setup_wifi();
@ -293,6 +293,12 @@ void callback(char* topic1, byte* payload, unsigned int length) {
Serial.println(" %"); Serial.println(" %");
Luftfeuchtigkeit = atof(msg); 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){ if(strcmp(topic1, topic_Akku)== 0){
Serial.print("Wetterstation Akku: "); Serial.print("Wetterstation Akku: ");
Serial.print(msg); Serial.print(msg);
@ -328,15 +334,15 @@ void reconnect() {
client.subscribe(topic_Flur); client.subscribe(topic_Flur);
#endif #endif
client.subscribe(topic_Luftfeuchtigkeit); client.subscribe(topic_Luftfeuchtigkeit);
client.subscribe(topic_Humidity);
client.subscribe(topic_Akku); client.subscribe(topic_Akku);
client.subscribe(topic_Helligkeit); client.subscribe(topic_Helligkeit);
//client.subscribe("hjk/devices/WETTERSTATIONBORIS/telemetry/#");
//client.subscribe("hjk/devices/MESSUNITTEMPBORIS/telemetry/#");
} else { } else {
Serial.print("failed, rc="); Serial.print("failed, rc=");
Serial.print(client.state()); Serial.print(client.state());
Serial.println(" try again in 5 seconds"); Serial.println(" try again in 5 seconds");
// Wait 5 seconds before retrying display.setCursor(1,56);
display.print("ERROR: MQTT!!!");
delay(5000); delay(5000);
} }
} }
@ -462,6 +468,57 @@ void ZeigeWetter(double Wetter1, int yPos = 2, int xPos = 1)
display.print("C"); 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 ZeigeTemperatur(float temperatur, uint16_t Color){
char szWetter[15];
if (temperatur > -99)
{
dtostrf(temperatur, 5, 1, szWetter);
display.setFont();
display.setCursor(1, 30);
display.setTextColor(Color);
display.fillRect(0, 29, 40, 9, myBLACK);
display.print(szWetter);
display.setCursor(31, 25);
display.setFont(&Picopixel);
display.print("o");
display.setCursor(34, 36);
display.setFont();
display.print("C");
display.setFont(0);
}
}
void ZeigeInnenFeuchtigkeit(float Luftfeuchtigkeit){
char szWetter[15];
if (Luftfeuchtigkeit > 0)
{
dtostrf(Luftfeuchtigkeit, 2, 0, szWetter);
display.setFont();
display.setCursor(45, 30);
display.setTextColor(myWHITE);
display.fillRect(45, 30, 64, 7, myBLACK);
display.print(szWetter);
display.print("%");
display.setFont(0);
}
}
void Test() void Test()
{ {
display.setCursor(1, 40); display.setCursor(1, 40);
@ -471,17 +528,6 @@ void Test()
display.setFont(); display.setFont();
} }
void writeLinie()
{
for (int i=0; i <= 63; i++){
display.fillRect(0, i, 60, 1, (myGREEN));
Serial.println(i);
delay(1000);
display.fillRect(1, i, 60, 1, (myBLACK));
}
}
void setup() { void setup() {
startTime = millis(); startTime = millis();
Serial.begin(115200); Serial.begin(115200);
@ -498,7 +544,7 @@ void setup() {
// Define multiplex implemention here {BINARY, STRAIGHT} (default is BINARY) // Define multiplex implemention here {BINARY, STRAIGHT} (default is BINARY)
display.setMuxPattern(BINARY); display.setMuxPattern(BINARY);
// Set the multiplex pattern {LINE, ZIGZAG,ZZAGG, ZZAGG, WZAGZIG, VZAG, ZAGZIG} (default is LINE) // Set the multiplex pattern {LINE, ZIGZAG,ZZAGG, ZAGGIZ, WZAGZIG, VZAG, ZAGZIG} (default is LINE)
display.setScanPattern(LINE); display.setScanPattern(LINE);
@ -519,7 +565,7 @@ void setup() {
// Set the time in microseconds that we pause after selecting each mux channel // Set the time in microseconds that we pause after selecting each mux channel
// (May help if some rows are missing / the mux chip is too slow) // (May help if some rows are missing / the mux chip is too slow)
display.setMuxDelay(0,0,0,0,0); //display.setMuxDelay(0,1,0,0,0);
// Set the number of panels that make up the display area width (default is 1) // Set the number of panels that make up the display area width (default is 1)
//display.setPanelsWidth(2); //display.setPanelsWidth(2);
@ -724,6 +770,7 @@ static void setup_wifi() {
Serial.print("."); Serial.print(".");
ErrCount ++; ErrCount ++;
if (ErrCount >= MaxErrCount){ if (ErrCount >= MaxErrCount){
Serial.print("\tKeine Kontakt zum WLAN !!!");
endTime = millis(); endTime = millis();
unsigned long Pause = stoerung -((endTime - startTime) * 1000); // Pause unsigned long Pause = stoerung -((endTime - startTime) * 1000); // Pause
ESP.deepSleep(Pause); // Pause ESP.deepSleep(Pause); // Pause
@ -745,7 +792,6 @@ void loop() {
reconnect(); reconnect();
} }
client.loop(); client.loop();
//writeLinie();
if (millis() - lastTime >= 1000) if (millis() - lastTime >= 1000)
{ {
@ -753,8 +799,11 @@ void loop() {
blinkSek = !blinkSek; blinkSek = !blinkSek;
ZeigeDatum(timeinfo, 1, 1); ZeigeDatum(timeinfo, 1, 1);
ZeigeZeit(timeinfo, TimeX, TimeY); ZeigeZeit(timeinfo, TimeX, TimeY);
ZeigeTemperatur(TempWohn, myWHITE);
ZeigeInnenFeuchtigkeit(LuftfeuchtigkeitWohnug);
//ZeigeZeit(timeinfo, 1,40); //ZeigeZeit(timeinfo, 1,40);
//ZeigeCO(1,CoY); ZeigeCO(1,CoY);
/* if ((timeinfo.tm_min % 10) == 0){ /* if ((timeinfo.tm_min % 10) == 0){
/* if (Covid19 != 0){ /* if (Covid19 != 0){
scroll_text(matrix_height-8,20,"Landkreis Heilbronn", 30,30,30, true); scroll_text(matrix_height-8,20,"Landkreis Heilbronn", 30,30,30, true);
@ -786,17 +835,22 @@ void loop() {
scroll_text2(matrix_height-24,20,"ich w\201nsche Euch allen ein", 128,128,0, true); 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); */ 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"); //Serial.println("START");
if (Aussentemp > -99.9){ if (Aussentemp > -99.9){
char szWetter[10]; char szWetter[10];
//dtostrf(TempFlur, 4, 1, szWetter); dtostrf(TempFlur, 4, 1, szWetter);
//Serial.print(Aussentemp); Serial.print(" "); Serial.println(szWetter); //Serial.print(Aussentemp); Serial.print(" "); Serial.println(szWetter);
//scroll_Grad(matrix_height-8,30," Flur: " + String(szWetter), 64,64,64, true); #ifdef FLUR
scroll_Grad(matrix_height-8,30," Flur: " + String(szWetter), 64,64,64, true);
#endif
/* Achtung sehr wichtig, /* Achtung sehr wichtig,
wenn das gesamt Laufschrift mehr wenn das gesamt Laufschrift mehr
als 30 Sekunden Dauert muss ein .... */ als 30 Sekunden Dauert muss ein .... */
//client.loop();
/* eingeführt werden, sonst kommt es zu /* eingeführt werden, sonst kommt es zu
einen Socket Fehler !!!! */ einen Socket Fehler !!!! */
scroll_text(matrix_height-8,30,"Luftdruck: " + String(Pressure) + " hPa", 255,255,255, true); scroll_text(matrix_height-8,30,"Luftdruck: " + String(Pressure) + " hPa", 255,255,255, true);
@ -817,15 +871,10 @@ void loop() {
einen Socket Fehler !!!! */ einen Socket Fehler !!!! */
dtostrf(Luftfeuchtigkeit, 4, 1, szWetter); dtostrf(Luftfeuchtigkeit, 4, 1, szWetter);
scroll_text(matrix_height-8,30,"Luftfeuchtigkeit: " + String(szWetter) + " %", 64,64,64, true); scroll_text(matrix_height-8,30,"Luftfeuchtigkeit: " + String(szWetter) + " %", 64,64,64, true);
} }
if ((Akku <= GRENZWERT) && (Akku > 0)){ if ((Akku <= GRENZWERT) && (Akku > 0)){
client.loop();
scroll_text(matrix_height-8,40,"Akku: " + String(Akku) + " Volt", 255, 0, 0, true); scroll_text(matrix_height-8,40,"Akku: " + String(Akku) + " Volt", 255, 0, 0, true);
scroll_text(matrix_height-8,40,"Akku aufladen!", 255, 0, 0, true); scroll_text(matrix_height-8,40,"Akku aufladen!", 255, 0, 0, true);
} else{
client.loop();
scroll_text(matrix_height-8,30,"Akku: " + String(Akku) + " Volt", 0, 64, 0, true);
} }
//Serial.println("STOP"); //Serial.println("STOP");
} }