2023-06-14

This commit is contained in:
hans-jurgen 2023-06-14 16:24:32 +02:00
parent 347e9add03
commit 824dc39de9
2 changed files with 32 additions and 40 deletions

View File

@ -13,9 +13,9 @@ platform = espressif32
board = nodemcu-32s
framework = arduino
monitor_speed = 115200
monitor_port = COM4
monitor_port = /dev/ttyUSB0
monitor_filters = time
upload_port = COM4
upload_port = /dev/ttyUSB0
lib_deps =
knolleary/PubSubClient @ 2.8
adafruit/Adafruit GFX Library @ 1.11.3
@ -25,19 +25,21 @@ lib_deps =
build_flags =
-DSCAN=32
[env:debug] ; Entwicklungssystem
build_flags = ${env.build_flags}
-DDEBUG=1
-DGRENZWERT=3.80
-DSTASSID=\"St.-Peters-Gasse-Post\"
-DSTAPSK=\"1952994784599318\"
-DSTASSID=\"St.-Peters-Gasse\"
-DSTAPSK=\"1952994784599317\"
-DGATEWAY=\"192.168.127.1\"
-DDNS=\"192.168.127.1\"
-DSECONDARDNS=\"8.8.8.8\"
-DMYIP=\"192.168.127.48\"
-DSUBNET=\"255.255.255.0\"
-Dmqtt_server=\"hjkmqtt.dedyn.io\"
-Dmqtt_port=61883
-DINNEN=\"hjk/devices/WETTERSTATION/telemetry/temperature_BMP_280\"
-DINNEN=\"hjk/devices/MESSUNITTEMPBORIS/telemetry/temperature_Htu_21\"
-DCO2=\"hjk/devices/WETTERSTATION/telemetry/co2\"
-DAKKU=\"hjk/devices/WETTERSTATION/telemetry/battery\"
-DWETTER=\"hjk/devices/WETTERSTATION/telemetry/temperature_Htu_21\"
@ -49,15 +51,16 @@ build_flags = ${env.build_flags}
build_flags = ${env.build_flags}
-DDEBUG=1
-DGRENZWERT=2.80
-DSTASSID=\"St.-Peters-Gasse-Post\"
-DSTAPSK=\"1952994784599318\"
-DGATEWAY=\"192.168.127.1\"
-DDNS=\"192.168.127.1\"
-DSTASSID=\"Westside\"
-DSTAPSK=\"BorisundEva\"
-DGATEWAY=\"192.168.2.1\"
-DDNS=\"192.168.2.1\"
-DMYIP=\"192.168.2.45\"
-DSUBNET=\"255.255.255.0\"
-DSECONDARDNS=\"8.8.8.8\"
-DMYIP=\"192.168.127.48\"
-Dmqtt_server=\"hjkmqtt.dedyn.io\"
-Dmqtt_port=8883
-DINNEN=\"hjk/devices/WETTERSTATIONBORIS/telemetry/temperature_BMP_280\"
-Dmqtt_port=61883
-DINNEN=\"hjk/devices/MESSUNITTEMPBORIS/telemetry/temperature_Htu_21\"
-DCO2=\"hjk/devices/WETTERSTATIONBORIS/telemetry/co2\"
-DAKKU=\"hjk/devices/WETTERSTATIONBORIS/telemetry/battery\"
-DWETTER=\"hjk/devices/WETTERSTATIONBORIS/telemetry/temperature_Htu_21\"

View File

@ -92,14 +92,14 @@ uint16_t myTEST = display.color565(30, 30, 0);
uint16_t myCOLORS[8]={myRED,myGREEN,myBLUE,myWHITE,myYELLOW,myCYAN,myMAGENTA,myBLACK};
// Wifi
char ssid[] = "St.-Peters-Gasse"; // your network SSID (name)
char pass[] = "1952994784599317"; // your network password
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;
String hostname = "GROSSZEICHENDISPLAY2";
String hostname = "GROSSZEICHBORIS";
int status = WL_IDLE_STATUS;
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)
@ -176,12 +176,12 @@ void IRAM_ATTR display_updater(){
void print_wifi_status() {
// SSID des WiFi Netzwerkes ausgeben:
Serial.print("SSID: ");
Serial.println(WiFi.SSID());
/* Serial.print("SSID: ");
Serial.println(WiFi.SSID()); */
// WiFi IP Adresse des ESP32 ausgeben:
IPAddress ip = WiFi.localIP();
/* IPAddress ip = WiFi.localIP();
Serial.print("IP Address: ");
Serial.println(ip);
Serial.println(ip); */
// WiFi Signalstärke ausgeben:
long rssi = WiFi.RSSI();
Serial.print("signal strength (RSSI):");
@ -299,14 +299,16 @@ void reconnect() {
if (client.connect(clientName)) {
/* MQTTStatus.setPic(3); */
Serial.println("connected");
client.subscribe(topic_Co2);
/* client.subscribe(topic_Co2);
//client.subscribe(topic_Covid);Ja
client.subscribe(topic_Wetter);
client.subscribe(topic_Pressure);
client.subscribe(topic_Innen);
client.subscribe(topic_Luftfeuchtigkeit);
client.subscribe(topic_Akku);
client.subscribe(topic_Helligkeit);
client.subscribe(topic_Helligkeit); */
client.subscribe("hjk/devices/WETTERSTATION/telemetry/#");
client.subscribe("hjk/devices/MESSUNITTEMPBORIS/telemetry/#");
} else {
Serial.print("failed, rc=");
Serial.print(client.state());
@ -449,7 +451,7 @@ void Test()
void setup() {
startTime = millis();
Serial.begin(115200);
WiFi.mode( WIFI_OFF );
//WiFi.mode( WIFI_OFF );
delay( 10 );
Serial.println("Start");
// initialise_wifi();
@ -672,35 +674,22 @@ static void setup_wifi() {
if (!secondarDNS.fromString(SECONDARDNS)) { // try to parse into the IPAddress
Serial.println("UnParsable GATEWAY");
}
//WiFi.config( ip, dns, gateway, subnet );
if (!subnet.fromString(SUBNET)) { // try to parse into the IPAddress
Serial.println("UnParsable GATEWAY");
}
if (!WiFi.config(ip, gateway, subnet, dns, secondarDNS))
{
Serial.println("STA Failed to configure");
}
Serial.println();
Serial.print("Connecting to ");
Serial.print(ssid);
Serial.print(" ");
// WiFi.forceSleepWake();
delay( 1 );
WiFi.persistent( false );
WiFi.setHostname(hostname.c_str()); //define hostname
WiFi.mode( WIFI_STA );
WiFi.config( ip, gateway, subnet, dns, dns );
//WiFi.begin( WLAN_SSID, WLAN_PASSWD );
Serial.println(ssid);
WiFi.begin(ssid, pass);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
ErrCount ++;
if (ErrCount >= MaxErrCount){
// ---------------------------------
// Status ändern !!! -1
//datenSave(-1);
// ---------------------------------
endTime = millis();
unsigned long Pause = stoerung -((endTime - startTime) * 1000); // Pause
ESP.deepSleep(Pause); // Pause
@ -710,7 +699,7 @@ static void setup_wifi() {
Serial.println(" WiFi connected");
client.setServer(mqtt_server, mqtt_port);
client.setCallback(callback);
Serial.print("IP address: \t");
Serial.print("IP Address: \t");
Serial.println(WiFi.localIP());
}