From a8f9b3896760b6b3842882e3dbb345cf5cde1236 Mon Sep 17 00:00:00 2001 From: hans-jurgen Date: Mon, 22 May 2023 14:29:45 +0200 Subject: [PATCH] 2023-05-58 --- include/mess_Ub.h | 4 ++-- include/mess_Ub_old.h | 2 +- platformio.ini | 1 - src/main.cpp | 35 ++++++++++++++++++++++------------- 4 files changed, 25 insertions(+), 17 deletions(-) diff --git a/include/mess_Ub.h b/include/mess_Ub.h index 4e785be..6cc07f2 100644 --- a/include/mess_Ub.h +++ b/include/mess_Ub.h @@ -1,9 +1,9 @@ #include -ADC_MODE(ADC_); +ADC_MODE(ADC_VDD); const float MinimalSpannung = 2.85; -float korectur = 9.2800899887514060742407199100112e-4; +float korectur = 0.000954598; char floatString[15] = {0}; float AKKU; diff --git a/include/mess_Ub_old.h b/include/mess_Ub_old.h index b46a741..2a18215 100644 --- a/include/mess_Ub_old.h +++ b/include/mess_Ub_old.h @@ -1,7 +1,7 @@ #include const float MinimalSpannung = 2.85; -float korectur = 1.02910; +float koa = 0.984326019; char floatString[15] = {0}; float AKKU; diff --git a/platformio.ini b/platformio.ini index a267eff..a2f85fc 100644 --- a/platformio.ini +++ b/platformio.ini @@ -28,7 +28,6 @@ build_flags = -DTEMPTEST33=1 -DNOBATT=0 -DMaxErrCount=20 - -DMQTT=0 diff --git a/src/main.cpp b/src/main.cpp index efd0421..be2188a 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -27,7 +27,7 @@ PubSubClient client(espClient); #include -#include +#include #include @@ -66,6 +66,7 @@ char topic[100]; char topic_1[50]; char topicWert[20]; char msg[20]; +long int Feldstaerke; @@ -90,8 +91,13 @@ void setup() { init_MCP9808(); initADS(); #endif - valTemp = getTemperature_MCP9808(); - AKKU = getBattery(korectur); // ca. 170 ms + if (!F_ADS1115 == true){ + AKKU = getBattery(); // ca. 170 ms + } + else{ + MessungADS(); + AKKU = readChannel(ADS1115_COMP_0_GND); + } // ca. 280 ms if (F_HTU_21D == true){ read_HTU21D(); @@ -127,21 +133,23 @@ void loop() { int currentMillis = millis(); if (currentMillis - previousMillis >= 10000) { previousMillis = currentMillis; - /* read_HTU21D(); - read_BMP_280(); - valTemp = getTemperature_MCP9808(); */ dtostrf(AKKU,8,2,ADSData.Akku); sprintf(topic, "%s%s%s", "hjk/devices/", hostname.c_str(), "/telemetry/battery" ); client.publish(topic, ADSData.Akku, true); - #if(MQTT == 0) - M2M_HTU21D(hostname.c_str()); - M2M_BMP280(hostname.c_str()); - M2M_Temperatur_MCP9808(hostname.c_str()); - #endif - long int Feldstaerke = WiFi.RSSI(); + if (F_ADS1115 == true){ + sprintf(topic, "%s%s%s", "hjk/devices/", hostname.c_str(), "/telemetry/Solar" ); + client.publish(topic, ADSData.Solar, true); + } + + if (F_HTU_21D) M2M_HTU21D(hostname.c_str()); + if (F_BMP280) M2M_BMP280(hostname.c_str()); + if (F_MCP9808) M2M_Temperatur_MCP9808(hostname.c_str()); sprintf(msg,"%ld", Feldstaerke); sprintf(topic, "%s%s%s", "hjk/devices/", hostname.c_str(), "/telemetry/RSSI" ); client.publish(topic, msg, true); + sprintf(msg,"0x%0x", SystemStatus); + sprintf(topic, "%s%s%s", "hjk/devices/", hostname.c_str(), "/telemetry/SystemStatus" ); + client.publish(topic, msg, true); client.loop(); delay(500); digitalWrite(BUILTIN_LED, HIGH); @@ -229,7 +237,8 @@ void setup_wifi() { } Serial.println(" WiFi connected"); Serial.print("IP address: \t"); - Serial.print(WiFi.localIP()); Serial.print("\tRESSI: "); Serial.println(WiFi.RSSI()); + Feldstaerke = WiFi.RSSI(); + Serial.print(WiFi.localIP()); Serial.print("\tRESSI: "); Serial.println(Feldstaerke); /* delay(2000); ESP.deepSleep(2e6, WAKE_RF_DEFAULT); delay(100); */