2024-07-03

This commit is contained in:
hans-jurgen 2024-07-03 10:48:23 +02:00
parent 881f501dd0
commit 94d3c9f64e
2 changed files with 64 additions and 15 deletions

View File

@ -20,9 +20,11 @@ upload_port = /dev/ttyUSB0
lib_deps = lib_deps =
knolleary/PubSubClient @ 2.8 knolleary/PubSubClient @ 2.8
adafruit/Adafruit HTU21DF Library @ 1.0.5 adafruit/Adafruit HTU21DF Library @ 1.0.5
adafruit/Adafruit BMP280 Library @ 2.6.6
wollewald/ADS1115_WE @ 1.4.3 wollewald/ADS1115_WE @ 1.4.3
adafruit/Adafruit MCP9808 Library @ 2.0.0 adafruit/Adafruit MCP9808 Library @ 2.0.0
adafruit/Adafruit BusIO @ 1.16.1
adafruit/Adafruit BME280 Library @ 2.2.4
adafruit/Adafruit Unified Sensor @ 1.1.14
build_flags = build_flags =
-DTEMPTEST33=1 -DTEMPTEST33=1
@ -35,17 +37,18 @@ build_flags =
build_flags = ${env.build_flags} build_flags = ${env.build_flags}
-DDEBUG=0 -DDEBUG=0
-DNOADS=0 -DNOADS=0
-DNAME=\"WETTERSTATIONBORIS\" -DNAME=\"WETTERSTATION\"
-DSTASSID=\"St.-Peters-Gasse\" -DSTASSID=\"MagentaWLAN-RGDO\"
-DSTAPSK=\"1952994784599317\" -DSTAPSK=\"93329248424922704583\"
-DGATEWAY=\"192.168.127.1\" -DGATEWAY=\"192.168.127.1\"
-DDNS=\"192.168.127.1\" -DDNS=\"192.168.127.1\"
-DKMYIP=\"192.168.127.49\" -DKMYIP=\"192.168.127.40\"
-Dmqtt_server=\"hjkmqtt.dedyn.io\" -Dmqtt_server=\"hjkmqtt.dedyn.io\"
-Dmqtt_port=61883 -Dmqtt_port=61883
-DTERROR=5 -DTERROR=5
-DTLOWBATT=60 -DTLOWBATT=60
-DTINTERVAL=1 -DTINTERVAL=1
-DKorrekturLuftdruck=0.0
[env:marcel] ; Produktivsystem: [env:marcel] ; Produktivsystem:
build_flags = ${env.build_flags} build_flags = ${env.build_flags}
@ -62,6 +65,7 @@ build_flags = ${env.build_flags}
-DTERROR=20 -DTERROR=20
-DTLOWBATT=60 -DTLOWBATT=60
-DTINTERVAL=10 -DTINTERVAL=10
-DKorrekturLuftdruck=0.0
[env:boris] ; Produktivsystem: [env:boris] ; Produktivsystem:
build_flags = ${env.build_flags} build_flags = ${env.build_flags}
@ -78,3 +82,39 @@ build_flags = ${env.build_flags}
-DTERROR=20 -DTERROR=20
-DTLOWBATT=60 -DTLOWBATT=60
-DTINTERVAL=5 -DTINTERVAL=5
-DKorrekturLuftdruck=0.0
[env:hjk]
build_flags = ${env.build_flags}
-DDEBUG=0
-DNOADS=0
-DNAME=\"WETTERSTATION\"
-DSTASSID=\"MagentaWLAN-RGDO\"
-DSTAPSK=\"93329248424922704583\"
-DGATEWAY=\"192.168.127.1\"
-DDNS=\"192.168.127.1\"
-DKMYIP=\"192.168.127.41\"
-Dmqtt_server=\"hjkmqtt.dedyn.io\"
-Dmqtt_port=61883
-DTERROR=5
-DTLOWBATT=60
-DTINTERVAL=10
-DKorrekturLuftdruck=23.6
[env:filamentbox]
build_flags = ${env.build_flags}
-DDEBUG=0
-DNOADS=0
-DNAME=\"filamenbox\"
-DSTASSID=\"MagentaWLAN-RGDO\"
-DSTAPSK=\"93329248424922704583\"
-DGATEWAY=\"192.168.127.1\"
-DDNS=\"192.168.127.1\"
-DKMYIP=\"192.168.127.42\"
-Dmqtt_server=\"hjkmqtt.dedyn.io\"
-Dmqtt_port=61883
-DTERROR=5
-DTLOWBATT=60
-DTINTERVAL=15
-DKorrekturLuftdruck=0.0

View File

@ -5,7 +5,7 @@
#include <PubSubClient.h> #include <PubSubClient.h>
#include <Ticker.h> #include <Ticker.h>
#define BUILTIN_LED D15 // #define BUILTIN_LED D2
#define TRIGGER_PIN D7 #define TRIGGER_PIN D7
#define START_STOP_PIN D6 #define START_STOP_PIN D6
@ -25,7 +25,8 @@ PubSubClient client(espClient);
#include<mess_htu21.h> #include<mess_htu21.h>
#include <mess_BMP280.h> //#include <mess_BMP280.h>
#include <mess_BME280.h>
#include <mess_Ub.h> #include <mess_Ub.h>
@ -72,6 +73,10 @@ long int Feldstaerke;
void setup() { void setup() {
startTime = millis(); startTime = millis();
/* pinMode(BUILTIN_LED, OUTPUT);
digitalWrite(BUILTIN_LED, LOW);
delay(5000);
digitalWrite(BUILTIN_LED, HIGH); */
Serial.begin(74880); Serial.begin(74880);
while ( !Serial ) delay(100); // wait for native usb while ( !Serial ) delay(100); // wait for native usb
WiFi.mode( WIFI_OFF ); WiFi.mode( WIFI_OFF );
@ -84,15 +89,19 @@ void setup() {
readSystemStatus(); readSystemStatus();
Serial.printf("Systemstatus : 0x%02x \n", SystemStatus); Serial.printf("Systemstatus : 0x%02x \n", SystemStatus);
SystemStatus = 0x00; SystemStatus = 0x00;
writeSystemStatus();
delay(500); delay(500);
#if (MQTT == 0) #if (MQTT == 0)
init_HTU21(); init_HTU21();
Init_BMP280(); //Init_BMP280();
Sensor_BME280();
init_MCP9808(); init_MCP9808();
initADS(); initADS();
#endif #endif
if (!F_ADS1115 == true){ if (!F_ADS1115 == true){
AKKU = getBattery(); // ca. 170 ms AKKU = getBattery(); // ca. 170 ms
Serial.println("ALTE UB MESSUNG:");
} }
else{ else{
MessungADS(); MessungADS();
@ -105,9 +114,9 @@ void setup() {
if (F_ADS1115 == true){ if (F_ADS1115 == true){
MessungADS(); MessungADS();
} }
if (F_BMP280 == true){ /* if (F_BMP280 == true){
read_BMP_280(); read_BMP_280();
} }*/
if (F_MCP9808 == true){ if (F_MCP9808 == true){
valTemp = getTemperature_MCP9808(); valTemp = getTemperature_MCP9808();
} }
@ -142,7 +151,7 @@ void loop() {
} }
if (F_HTU_21D) M2M_HTU21D(hostname.c_str()); if (F_HTU_21D) M2M_HTU21D(hostname.c_str());
if (F_BMP280) M2M_BMP280(hostname.c_str()); M2M_BME280(hostname.c_str());
if (F_MCP9808) M2M_Temperatur_MCP9808(hostname.c_str()); if (F_MCP9808) M2M_Temperatur_MCP9808(hostname.c_str());
sprintf(msg,"%ld", Feldstaerke); sprintf(msg,"%ld", Feldstaerke);
sprintf(topic, "%s%s%s", "hjk/devices/", hostname.c_str(), "/telemetry/RSSI" ); sprintf(topic, "%s%s%s", "hjk/devices/", hostname.c_str(), "/telemetry/RSSI" );
@ -152,7 +161,7 @@ void loop() {
client.publish(topic, msg, true); client.publish(topic, msg, true);
client.loop(); client.loop();
delay(500); delay(500);
digitalWrite(BUILTIN_LED, HIGH); //digitalWrite(BUILTIN_LED, HIGH);
/* ESP.deepSleep(5e6); /* ESP.deepSleep(5e6);
delay(100); */ delay(100); */
endTime = millis(); endTime = millis();
@ -264,7 +273,7 @@ void callback(char* topic1, byte* payload, unsigned int length)
void reconnect() { void reconnect() {
// Loop until we're reconnected // Loop until we're reconnected
sprintf(clientName, "%s%s", "ESP8266Client", sID); sprintf(clientName, "%s%s", "ESP8266Wetter", sID);
while (!client.connected()) { while (!client.connected()) {
Serial.print("Attempting MQTT connection..."); Serial.print("Attempting MQTT connection...");
//verifyFingerprint(); //verifyFingerprint();
@ -272,9 +281,9 @@ void reconnect() {
if (client.connect(clientName)) { if (client.connect(clientName)) {
Serial.println("connected"); Serial.println("connected");
// Once connected, publish an announcement... // Once connected, publish an announcement...
client.publish("outTopic", "hello world"); // client.publish("outTopic", "hello world");
// ... and resubscribe // ... and resubscribe
client.subscribe("inTopic"); // client.subscribe("inTopic");
} else { } else {
Serial.print("failed, rc="); Serial.print("failed, rc=");
Serial.print(client.state()); Serial.print(client.state());