2023-06-14
This commit is contained in:
parent
347e9add03
commit
824dc39de9
|
@ -13,9 +13,9 @@ platform = espressif32
|
||||||
board = nodemcu-32s
|
board = nodemcu-32s
|
||||||
framework = arduino
|
framework = arduino
|
||||||
monitor_speed = 115200
|
monitor_speed = 115200
|
||||||
monitor_port = COM4
|
monitor_port = /dev/ttyUSB0
|
||||||
monitor_filters = time
|
monitor_filters = time
|
||||||
upload_port = COM4
|
upload_port = /dev/ttyUSB0
|
||||||
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
|
||||||
|
@ -25,19 +25,21 @@ lib_deps =
|
||||||
build_flags =
|
build_flags =
|
||||||
-DSCAN=32
|
-DSCAN=32
|
||||||
|
|
||||||
|
|
||||||
[env:debug] ; Entwicklungssystem
|
[env:debug] ; Entwicklungssystem
|
||||||
build_flags = ${env.build_flags}
|
build_flags = ${env.build_flags}
|
||||||
-DDEBUG=1
|
-DDEBUG=1
|
||||||
-DGRENZWERT=3.80
|
-DGRENZWERT=3.80
|
||||||
-DSTASSID=\"St.-Peters-Gasse-Post\"
|
-DSTASSID=\"St.-Peters-Gasse\"
|
||||||
-DSTAPSK=\"1952994784599318\"
|
-DSTAPSK=\"1952994784599317\"
|
||||||
-DGATEWAY=\"192.168.127.1\"
|
-DGATEWAY=\"192.168.127.1\"
|
||||||
-DDNS=\"192.168.127.1\"
|
-DDNS=\"192.168.127.1\"
|
||||||
-DSECONDARDNS=\"8.8.8.8\"
|
-DSECONDARDNS=\"8.8.8.8\"
|
||||||
-DMYIP=\"192.168.127.48\"
|
-DMYIP=\"192.168.127.48\"
|
||||||
|
-DSUBNET=\"255.255.255.0\"
|
||||||
-Dmqtt_server=\"hjkmqtt.dedyn.io\"
|
-Dmqtt_server=\"hjkmqtt.dedyn.io\"
|
||||||
-Dmqtt_port=61883
|
-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\"
|
-DCO2=\"hjk/devices/WETTERSTATION/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\"
|
||||||
|
@ -49,15 +51,16 @@ build_flags = ${env.build_flags}
|
||||||
build_flags = ${env.build_flags}
|
build_flags = ${env.build_flags}
|
||||||
-DDEBUG=1
|
-DDEBUG=1
|
||||||
-DGRENZWERT=2.80
|
-DGRENZWERT=2.80
|
||||||
-DSTASSID=\"St.-Peters-Gasse-Post\"
|
-DSTASSID=\"Westside\"
|
||||||
-DSTAPSK=\"1952994784599318\"
|
-DSTAPSK=\"BorisundEva\"
|
||||||
-DGATEWAY=\"192.168.127.1\"
|
-DGATEWAY=\"192.168.2.1\"
|
||||||
-DDNS=\"192.168.127.1\"
|
-DDNS=\"192.168.2.1\"
|
||||||
|
-DMYIP=\"192.168.2.45\"
|
||||||
|
-DSUBNET=\"255.255.255.0\"
|
||||||
-DSECONDARDNS=\"8.8.8.8\"
|
-DSECONDARDNS=\"8.8.8.8\"
|
||||||
-DMYIP=\"192.168.127.48\"
|
|
||||||
-Dmqtt_server=\"hjkmqtt.dedyn.io\"
|
-Dmqtt_server=\"hjkmqtt.dedyn.io\"
|
||||||
-Dmqtt_port=8883
|
-Dmqtt_port=61883
|
||||||
-DINNEN=\"hjk/devices/WETTERSTATIONBORIS/telemetry/temperature_BMP_280\"
|
-DINNEN=\"hjk/devices/MESSUNITTEMPBORIS/telemetry/temperature_Htu_21\"
|
||||||
-DCO2=\"hjk/devices/WETTERSTATIONBORIS/telemetry/co2\"
|
-DCO2=\"hjk/devices/WETTERSTATIONBORIS/telemetry/co2\"
|
||||||
-DAKKU=\"hjk/devices/WETTERSTATIONBORIS/telemetry/battery\"
|
-DAKKU=\"hjk/devices/WETTERSTATIONBORIS/telemetry/battery\"
|
||||||
-DWETTER=\"hjk/devices/WETTERSTATIONBORIS/telemetry/temperature_Htu_21\"
|
-DWETTER=\"hjk/devices/WETTERSTATIONBORIS/telemetry/temperature_Htu_21\"
|
||||||
|
|
45
src/main.cpp
45
src/main.cpp
|
@ -92,14 +92,14 @@ uint16_t myTEST = display.color565(30, 30, 0);
|
||||||
uint16_t myCOLORS[8]={myRED,myGREEN,myBLUE,myWHITE,myYELLOW,myCYAN,myMAGENTA,myBLACK};
|
uint16_t myCOLORS[8]={myRED,myGREEN,myBLUE,myWHITE,myYELLOW,myCYAN,myMAGENTA,myBLACK};
|
||||||
|
|
||||||
// Wifi
|
// Wifi
|
||||||
char ssid[] = "St.-Peters-Gasse"; // your network SSID (name)
|
char ssid[] = STASSID; // your network SSID (name)
|
||||||
char pass[] = "1952994784599317"; // your network password
|
char pass[] = STAPSK; // your network password
|
||||||
IPAddress ip;
|
IPAddress ip;
|
||||||
IPAddress gateway;
|
IPAddress gateway;
|
||||||
IPAddress subnet;
|
IPAddress subnet;
|
||||||
IPAddress dns; // DNS-Server
|
IPAddress dns; // DNS-Server
|
||||||
IPAddress secondarDNS;
|
IPAddress secondarDNS;
|
||||||
String hostname = "GROSSZEICHENDISPLAY2";
|
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)
|
||||||
|
@ -176,12 +176,12 @@ void IRAM_ATTR display_updater(){
|
||||||
|
|
||||||
void print_wifi_status() {
|
void print_wifi_status() {
|
||||||
// SSID des WiFi Netzwerkes ausgeben:
|
// SSID des WiFi Netzwerkes ausgeben:
|
||||||
Serial.print("SSID: ");
|
/* Serial.print("SSID: ");
|
||||||
Serial.println(WiFi.SSID());
|
Serial.println(WiFi.SSID()); */
|
||||||
// WiFi IP Adresse des ESP32 ausgeben:
|
// WiFi IP Adresse des ESP32 ausgeben:
|
||||||
IPAddress ip = WiFi.localIP();
|
/* IPAddress ip = WiFi.localIP();
|
||||||
Serial.print("IP Address: ");
|
Serial.print("IP Address: ");
|
||||||
Serial.println(ip);
|
Serial.println(ip); */
|
||||||
// WiFi Signalstärke ausgeben:
|
// WiFi Signalstärke ausgeben:
|
||||||
long rssi = WiFi.RSSI();
|
long rssi = WiFi.RSSI();
|
||||||
Serial.print("signal strength (RSSI):");
|
Serial.print("signal strength (RSSI):");
|
||||||
|
@ -299,14 +299,16 @@ void reconnect() {
|
||||||
if (client.connect(clientName)) {
|
if (client.connect(clientName)) {
|
||||||
/* MQTTStatus.setPic(3); */
|
/* MQTTStatus.setPic(3); */
|
||||||
Serial.println("connected");
|
Serial.println("connected");
|
||||||
client.subscribe(topic_Co2);
|
/* client.subscribe(topic_Co2);
|
||||||
//client.subscribe(topic_Covid);Ja
|
//client.subscribe(topic_Covid);Ja
|
||||||
client.subscribe(topic_Wetter);
|
client.subscribe(topic_Wetter);
|
||||||
client.subscribe(topic_Pressure);
|
client.subscribe(topic_Pressure);
|
||||||
client.subscribe(topic_Innen);
|
client.subscribe(topic_Innen);
|
||||||
client.subscribe(topic_Luftfeuchtigkeit);
|
client.subscribe(topic_Luftfeuchtigkeit);
|
||||||
client.subscribe(topic_Akku);
|
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 {
|
} else {
|
||||||
Serial.print("failed, rc=");
|
Serial.print("failed, rc=");
|
||||||
Serial.print(client.state());
|
Serial.print(client.state());
|
||||||
|
@ -449,7 +451,7 @@ void Test()
|
||||||
void setup() {
|
void setup() {
|
||||||
startTime = millis();
|
startTime = millis();
|
||||||
Serial.begin(115200);
|
Serial.begin(115200);
|
||||||
WiFi.mode( WIFI_OFF );
|
//WiFi.mode( WIFI_OFF );
|
||||||
delay( 10 );
|
delay( 10 );
|
||||||
Serial.println("Start");
|
Serial.println("Start");
|
||||||
// initialise_wifi();
|
// initialise_wifi();
|
||||||
|
@ -672,35 +674,22 @@ static void setup_wifi() {
|
||||||
if (!secondarDNS.fromString(SECONDARDNS)) { // try to parse into the IPAddress
|
if (!secondarDNS.fromString(SECONDARDNS)) { // try to parse into the IPAddress
|
||||||
Serial.println("UnParsable GATEWAY");
|
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))
|
if (!WiFi.config(ip, gateway, subnet, dns, secondarDNS))
|
||||||
{
|
{
|
||||||
Serial.println("STA Failed to configure");
|
Serial.println("STA Failed to configure");
|
||||||
}
|
}
|
||||||
Serial.println();
|
Serial.println();
|
||||||
Serial.print("Connecting to ");
|
Serial.print("Connecting to ");
|
||||||
Serial.print(ssid);
|
Serial.println(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 );
|
|
||||||
|
|
||||||
WiFi.begin(ssid, pass);
|
WiFi.begin(ssid, pass);
|
||||||
|
|
||||||
while (WiFi.status() != WL_CONNECTED) {
|
while (WiFi.status() != WL_CONNECTED) {
|
||||||
delay(500);
|
delay(500);
|
||||||
Serial.print(".");
|
Serial.print(".");
|
||||||
ErrCount ++;
|
ErrCount ++;
|
||||||
if (ErrCount >= MaxErrCount){
|
if (ErrCount >= MaxErrCount){
|
||||||
// ---------------------------------
|
|
||||||
// Status ändern !!! -1
|
|
||||||
//datenSave(-1);
|
|
||||||
// ---------------------------------
|
|
||||||
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
|
||||||
|
@ -710,7 +699,7 @@ static void setup_wifi() {
|
||||||
Serial.println(" WiFi connected");
|
Serial.println(" WiFi connected");
|
||||||
client.setServer(mqtt_server, mqtt_port);
|
client.setServer(mqtt_server, mqtt_port);
|
||||||
client.setCallback(callback);
|
client.setCallback(callback);
|
||||||
Serial.print("IP address: \t");
|
Serial.print("IP Address: \t");
|
||||||
Serial.println(WiFi.localIP());
|
Serial.println(WiFi.localIP());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user