2025-11-1900
This commit is contained in:
@@ -25,4 +25,5 @@ void read_HTU21D() {
|
|||||||
htu21Data.Feuchte = htu.readHumidity();
|
htu21Data.Feuchte = htu.readHumidity();
|
||||||
htu21Data.Temp = htu21Data.Temp + HTU_Korrectur;
|
htu21Data.Temp = htu21Data.Temp + HTU_Korrectur;
|
||||||
htu21Data.Feuchte = htu21Data.Feuchte + HTUKorrekturFeuchte;
|
htu21Data.Feuchte = htu21Data.Feuchte + HTUKorrekturFeuchte;
|
||||||
|
Serial.printf("HTU21D: Temperarur Innen %3.2f °C und\n Luftfeuchtigkeit %3.2f %%\n\n", htu21Data.Temp, htu21Data.Feuchte );
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,6 +39,12 @@ build_flags = ${env.build_flags}
|
|||||||
-DSTASSID=\"MagentaWLAN-RGDO\"
|
-DSTASSID=\"MagentaWLAN-RGDO\"
|
||||||
-DSTAPSK=\"93329248424922704583\"
|
-DSTAPSK=\"93329248424922704583\"
|
||||||
-DGATEWAY=\"192.168.127.1\"
|
-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\"
|
-DCO2Wert=\"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\"
|
||||||
@@ -53,14 +59,23 @@ build_flags = ${env.build_flags}
|
|||||||
-DAKKU_GREZWERT=2.90
|
-DAKKU_GREZWERT=2.90
|
||||||
|
|
||||||
|
|
||||||
[env:hjk] ; Sulzfeld
|
[env:marcel] ; Sulzfeld
|
||||||
build_flags = ${env.build_flags}
|
build_flags = ${env.build_flags}
|
||||||
-DCO2Wert=\"hjk/devices/257923/telemetry/co2\"
|
-DSTASSID=\"EasyBox-838169\"
|
||||||
-DAKKU=\"hjk/devices/WETTERSTATION2/telemetry/battery\"
|
-DSTAPSK=\"RcZmua6Xv4R4V5Kf\"
|
||||||
-DWETTER=\"hjk/devices/WETTERSTATION2/telemetry/temperature_Htu_21\"
|
-DGATEWAY=\"192.168.2.1\"
|
||||||
-DLUFTDRUCK=\"hjk/devices/WETTERSTATION2/telemetry/pressure\"
|
-DDNS=\"192.168.2.1\"
|
||||||
-DFEUCHTIGKEIT=\"hjk/devices/WETTERSTATION2/telemetry/humity\"
|
-DSECONDARDNS=\"192.168.2.1\"
|
||||||
-DHELL=\"hjk/devices/WETTERSTATION/telemetry/Lux\"
|
-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
|
-DHTU_Korrectur=-0.55
|
||||||
-DBME_Korrectur=-0.00
|
-DBME_Korrectur=-0.00
|
||||||
-DKorrekturLuftdruck=0.00
|
-DKorrekturLuftdruck=0.00
|
||||||
|
|||||||
71
src/main.cpp
71
src/main.cpp
@@ -21,6 +21,9 @@
|
|||||||
|
|
||||||
#include <mess_BME280.h>
|
#include <mess_BME280.h>
|
||||||
#include <mess_HTU21D.h>
|
#include <mess_HTU21D.h>
|
||||||
|
#ifndef CO2Wert
|
||||||
|
#include <CO2.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
// Pins for LED MATRIX
|
// Pins for LED MATRIX
|
||||||
#ifdef ESP32
|
#ifdef ESP32
|
||||||
@@ -72,7 +75,7 @@ unsigned long endTime;
|
|||||||
#include <Wire.h>
|
#include <Wire.h>
|
||||||
#include <WiFi.h>
|
#include <WiFi.h>
|
||||||
#include <PubSubClient.h>
|
#include <PubSubClient.h>
|
||||||
#define mqtt_port 61883
|
#define mqtt_port MQTTPORT
|
||||||
WiFiClient espClient;
|
WiFiClient espClient;
|
||||||
PubSubClient client(espClient);
|
PubSubClient client(espClient);
|
||||||
|
|
||||||
@@ -116,13 +119,15 @@ u_int16_t EndederAbdunklung = 7;
|
|||||||
uint8_t SekOld = 99;
|
uint8_t SekOld = 99;
|
||||||
|
|
||||||
// Wifi
|
// Wifi
|
||||||
char ssid[] = "MagentaWLAN-RGDO"; // your network SSID (name)
|
// Wifi
|
||||||
char pass[] = "93329248424922704583"; // your network password
|
char ssid[] = STASSID; // your network SSID (name)
|
||||||
IPAddress ip( 192, 168, 127, 52);
|
char pass[] = STAPSK; // your network password
|
||||||
IPAddress gateway( 192, 168, 127, 1 );
|
IPAddress ip;
|
||||||
IPAddress subnet( 255, 255, 255, 0 );
|
IPAddress gateway;
|
||||||
IPAddress dns1(192, 168, 127, 1); // DNS-Server 1
|
IPAddress subnet;
|
||||||
IPAddress dns2(192, 168, 127, 1); // DNS-Server 2
|
IPAddress dns; // DNS-Server
|
||||||
|
IPAddress secondarDNS;
|
||||||
|
|
||||||
|
|
||||||
/* char ssid[] = "EasyBox-838169"; // your network SSID (name)
|
/* char ssid[] = "EasyBox-838169"; // your network SSID (name)
|
||||||
char pass[] = "RcZmua6Xv4R4V5Kf"; // your network password
|
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"};
|
const char* const PROGMEM DAY_SHORT[] = {"So", "Mo", "Di", "Mi", "Do", "Fr", "Sa", "So"};
|
||||||
|
|
||||||
//MQTT
|
//MQTT
|
||||||
#define mqtt_port 61883
|
/* #define mqtt_port 61883
|
||||||
const char* mqtt_server = "hjkmqtt.dedyn.io";
|
const char* mqtt_server = "hjkmqtt.dedyn.io"; */
|
||||||
char topic_0[50];
|
char topic_0[50];
|
||||||
char msg[20];
|
char msg[20];
|
||||||
char clientName[30];
|
char clientName[30];
|
||||||
|
#ifdef Covid
|
||||||
const char* topic_Covid = "hjk/devices/Covid19/telemetry/Covid19";
|
const char* topic_Covid = "hjk/devices/Covid19/telemetry/Covid19";
|
||||||
|
#endif
|
||||||
const char* topic_Wetter = WETTER;
|
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_Akku = AKKU;
|
const char* topic_Akku = AKKU;
|
||||||
const char* topic_Co2 = CO2Wert;
|
#ifdef CO2Wert
|
||||||
|
const char* topic_Co2 = CO2Wert;
|
||||||
|
#endif
|
||||||
|
|
||||||
const char* topic_Helligkeit = HELL;
|
const char* topic_Helligkeit = HELL;
|
||||||
|
|
||||||
@@ -343,8 +352,10 @@ void reconnect() {
|
|||||||
if (client.connect(clientName)) {
|
if (client.connect(clientName)) {
|
||||||
/* MQTTStatus.setPic(3); */
|
/* MQTTStatus.setPic(3); */
|
||||||
Serial.println("connected");
|
Serial.println("connected");
|
||||||
|
#ifdef CO2Wert
|
||||||
client.subscribe(topic_Co2);
|
client.subscribe(topic_Co2);
|
||||||
client.subscribe(topic_Covid);
|
#endif
|
||||||
|
//client.subscribe(topic_Covid);
|
||||||
client.subscribe(topic_Wetter);
|
client.subscribe(topic_Wetter);
|
||||||
client.subscribe(topic_Pressure);
|
client.subscribe(topic_Pressure);
|
||||||
client.subscribe(topic_Luftfeuchtigkeit);
|
client.subscribe(topic_Luftfeuchtigkeit);
|
||||||
@@ -669,6 +680,9 @@ void setup() {
|
|||||||
}
|
}
|
||||||
read_HTU21D();
|
read_HTU21D();
|
||||||
Init_BME280();
|
Init_BME280();
|
||||||
|
#ifndef CO2Wert
|
||||||
|
beginC02();
|
||||||
|
#endif
|
||||||
delay(5000);
|
delay(5000);
|
||||||
WiFi.mode( WIFI_OFF );
|
WiFi.mode( WIFI_OFF );
|
||||||
// WiFi.forceSleepBegin();
|
// WiFi.forceSleepBegin();
|
||||||
@@ -794,6 +808,23 @@ static void setup_wifi() {
|
|||||||
|
|
||||||
long ErrCount = 0;
|
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);
|
delay(10);
|
||||||
// We start by connecting to a WiFi network
|
// We start by connecting to a WiFi network
|
||||||
Serial.println();
|
Serial.println();
|
||||||
@@ -803,7 +834,7 @@ static void setup_wifi() {
|
|||||||
|
|
||||||
//WiFi.forceSleepWake();
|
//WiFi.forceSleepWake();
|
||||||
delay( 1 );
|
delay( 1 );
|
||||||
WiFi.config( ip, gateway, subnet, dns1, dns2);
|
WiFi.config( ip, gateway, subnet, dns, secondarDNS);
|
||||||
|
|
||||||
WiFi.begin(ssid, pass);
|
WiFi.begin(ssid, pass);
|
||||||
|
|
||||||
@@ -846,6 +877,20 @@ void loop() {
|
|||||||
AkkuAlarm();
|
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 ((timeinfo.tm_min % 2) == 0)
|
||||||
{
|
{
|
||||||
if (readHtuFlag == true)
|
if (readHtuFlag == true)
|
||||||
|
|||||||
Reference in New Issue
Block a user