2025-11-1900

This commit is contained in:
2025-11-19 16:10:53 +01:00
parent 1b5539ff7f
commit 3c02ce3dd3
3 changed files with 82 additions and 21 deletions

View File

@@ -25,4 +25,5 @@ void read_HTU21D() {
htu21Data.Feuchte = htu.readHumidity();
htu21Data.Temp = htu21Data.Temp + HTU_Korrectur;
htu21Data.Feuchte = htu21Data.Feuchte + HTUKorrekturFeuchte;
Serial.printf("HTU21D: Temperarur Innen %3.2f °C und\n Luftfeuchtigkeit %3.2f %%\n\n", htu21Data.Temp, htu21Data.Feuchte );
}

View File

@@ -39,6 +39,12 @@ build_flags = ${env.build_flags}
-DSTASSID=\"MagentaWLAN-RGDO\"
-DSTAPSK=\"93329248424922704583\"
-DGATEWAY=\"192.168.127.1\"
-DDNS=\"192.168.127.1\"
-DSECONDARDNS=\"8.8.8.8\"
-DMYIP=\"192.168.127.52\"
-DSUBNET=\"255.255.255.0\"
-Dmqtt_server=\"192.168.127.193\"
-DMQTTPORT=1883
-DCO2Wert=\"hjk/devices/257923/telemetry/co2\"
-DAKKU=\"hjk/devices/WETTERSTATION/telemetry/battery\"
-DWETTER=\"hjk/devices/WETTERSTATION/telemetry/temperature_Htu_21\"
@@ -53,14 +59,23 @@ build_flags = ${env.build_flags}
-DAKKU_GREZWERT=2.90
[env:hjk] ; Sulzfeld
[env:marcel] ; Sulzfeld
build_flags = ${env.build_flags}
-DCO2Wert=\"hjk/devices/257923/telemetry/co2\"
-DAKKU=\"hjk/devices/WETTERSTATION2/telemetry/battery\"
-DWETTER=\"hjk/devices/WETTERSTATION2/telemetry/temperature_Htu_21\"
-DLUFTDRUCK=\"hjk/devices/WETTERSTATION2/telemetry/pressure\"
-DFEUCHTIGKEIT=\"hjk/devices/WETTERSTATION2/telemetry/humity\"
-DHELL=\"hjk/devices/WETTERSTATION/telemetry/Lux\"
-DSTASSID=\"EasyBox-838169\"
-DSTAPSK=\"RcZmua6Xv4R4V5Kf\"
-DGATEWAY=\"192.168.2.1\"
-DDNS=\"192.168.2.1\"
-DSECONDARDNS=\"192.168.2.1\"
-DMYIP=\"192.168.2.80\"
-DSUBNET=\"255.255.255.0\"
-Dmqtt_server=\"hjkmqtt.dedyn.io\"
-DMQTTPORT=6883
-DAKKU=\"hjk/devices/WETTERSTATIONMARCEL/telemetry/battery\"
-DWETTER=\"hjk/devices/WETTERSTATIONMARCEL/telemetry/temperature_Htu_21\"
-DLUFTDRUCK=\"hjk/devices/WETTERSTATIONMARCEL/telemetry/pressure\"
-DFEUCHTIGKEIT=\"hjk/devices/WETTERSTATIONMARCEL/telemetry/humity\"
-DHELL=\"hjk/devices/DisplayMarcel/telemetry/Lux\"
-DHTU_Korrectur=-0.55
-DBME_Korrectur=-0.00
-DKorrekturLuftdruck=0.00

View File

@@ -21,6 +21,9 @@
#include <mess_BME280.h>
#include <mess_HTU21D.h>
#ifndef CO2Wert
#include <CO2.h>
#endif
// Pins for LED MATRIX
#ifdef ESP32
@@ -72,7 +75,7 @@ unsigned long endTime;
#include <Wire.h>
#include <WiFi.h>
#include <PubSubClient.h>
#define mqtt_port 61883
#define mqtt_port MQTTPORT
WiFiClient espClient;
PubSubClient client(espClient);
@@ -116,13 +119,15 @@ u_int16_t EndederAbdunklung = 7;
uint8_t SekOld = 99;
// Wifi
char ssid[] = "MagentaWLAN-RGDO"; // your network SSID (name)
char pass[] = "93329248424922704583"; // your network password
IPAddress ip( 192, 168, 127, 52);
IPAddress gateway( 192, 168, 127, 1 );
IPAddress subnet( 255, 255, 255, 0 );
IPAddress dns1(192, 168, 127, 1); // DNS-Server 1
IPAddress dns2(192, 168, 127, 1); // DNS-Server 2
// Wifi
char ssid[] = STASSID; // your network SSID (name)
char pass[] = STAPSK; // your network password
IPAddress ip;
IPAddress gateway;
IPAddress subnet;
IPAddress dns; // DNS-Server
IPAddress secondarDNS;
/* char ssid[] = "EasyBox-838169"; // your network SSID (name)
char pass[] = "RcZmua6Xv4R4V5Kf"; // your network password
@@ -170,17 +175,21 @@ const char* const PROGMEM DAY_NAMES[] = {"Sonntag", "Montag", "Dienstag", "Mittw
const char* const PROGMEM DAY_SHORT[] = {"So", "Mo", "Di", "Mi", "Do", "Fr", "Sa", "So"};
//MQTT
#define mqtt_port 61883
const char* mqtt_server = "hjkmqtt.dedyn.io";
/* #define mqtt_port 61883
const char* mqtt_server = "hjkmqtt.dedyn.io"; */
char topic_0[50];
char msg[20];
char clientName[30];
#ifdef Covid
const char* topic_Covid = "hjk/devices/Covid19/telemetry/Covid19";
#endif
const char* topic_Wetter = WETTER;
const char* topic_Pressure = LUFTDRUCK;
const char* topic_Luftfeuchtigkeit = FEUCHTIGKEIT;
const char* topic_Akku = AKKU;
const char* topic_Co2 = CO2Wert;
#ifdef CO2Wert
const char* topic_Co2 = CO2Wert;
#endif
const char* topic_Helligkeit = HELL;
@@ -343,8 +352,10 @@ void reconnect() {
if (client.connect(clientName)) {
/* MQTTStatus.setPic(3); */
Serial.println("connected");
client.subscribe(topic_Co2);
client.subscribe(topic_Covid);
#ifdef CO2Wert
client.subscribe(topic_Co2);
#endif
//client.subscribe(topic_Covid);
client.subscribe(topic_Wetter);
client.subscribe(topic_Pressure);
client.subscribe(topic_Luftfeuchtigkeit);
@@ -669,6 +680,9 @@ void setup() {
}
read_HTU21D();
Init_BME280();
#ifndef CO2Wert
beginC02();
#endif
delay(5000);
WiFi.mode( WIFI_OFF );
// WiFi.forceSleepBegin();
@@ -794,6 +808,23 @@ static void setup_wifi() {
long ErrCount = 0;
if (!ip.fromString(MYIP)) { // try to parse into the IPAddress
Serial.println("UnParsable IP");
}
if (!dns.fromString(DNS)) { // try to parse into the IPAddress
Serial.println("UnParsable DNS");
}
if (!gateway.fromString(GATEWAY)) { // try to parse into the IPAddress
Serial.println("UnParsable GATEWAY");
}
if (!secondarDNS.fromString(SECONDARDNS)) { // try to parse into the IPAddress
Serial.println("UnParsable GATEWAY");
}
if (!subnet.fromString(SUBNET)) { // try to parse into the IPAddress
Serial.println("UnParsable GATEWAY");
}
delay(10);
// We start by connecting to a WiFi network
Serial.println();
@@ -803,7 +834,7 @@ static void setup_wifi() {
//WiFi.forceSleepWake();
delay( 1 );
WiFi.config( ip, gateway, subnet, dns1, dns2);
WiFi.config( ip, gateway, subnet, dns, secondarDNS);
WiFi.begin(ssid, pass);
@@ -846,6 +877,20 @@ void loop() {
AkkuAlarm();
}
#ifndef CO2Wert
if ((timeinfo.tm_sec % 30) == 0)
{
if (readCo2Flag == true) //eadCo2Flag
{
CO2Wert = readCO2();
Serial.print("CO = \t"); Serial.println(CO2Wert);
readCo2Flag = false;
}
}else{
readCo2Flag = true;
}
#endif
if ((timeinfo.tm_min % 2) == 0)
{
if (readHtuFlag == true)