diff --git a/doc/Aidon-HAN-Interface-Description-v11A-ID-34331.pdf b/doc/Aidon-HAN-Interface-Description-v11A-ID-34331.pdf new file mode 100644 index 00000000..7f9d43d8 Binary files /dev/null and b/doc/Aidon-HAN-Interface-Description-v11A-ID-34331.pdf differ diff --git a/platformio.ini b/platformio.ini index e4c322ba..fde67eb4 100755 --- a/platformio.ini +++ b/platformio.ini @@ -4,10 +4,10 @@ extra_configs = platformio-user.ini [common] framework = arduino -lib_deps = HanReader@1.0.0, ArduinoJson@6.14.1, MQTT@^2.4.7, DallasTemperature@3.8.1, EspSoftwareSerial@6.7.1, Base64@^1.0.0 +lib_deps = HanReader@1.0.0, ArduinoJson@6.14.1, MQTT@2.4.7, DallasTemperature@3.8.1, EspSoftwareSerial@6.7.1, Base64@1.0.0 [env:hw1esp12e] -platform = espressif8266 +platform = espressif8266@2.3.3 board = esp12e framework = ${common.framework} lib_deps = ${common.lib_deps} @@ -18,7 +18,7 @@ extra_scripts = scripts/makeweb.py [env:esp12e] -platform = espressif8266 +platform = espressif8266@2.3.3 board = esp12e framework = ${common.framework} lib_deps = ${common.lib_deps} @@ -27,7 +27,7 @@ extra_scripts = scripts/makeweb.py [env:d1mini] -platform = espressif8266 +platform = espressif8266@2.3.3 board = d1_mini framework = ${common.framework} lib_deps = ${common.lib_deps} @@ -36,7 +36,7 @@ extra_scripts = scripts/makeweb.py [env:esp32] -platform = espressif32 +platform = espressif32@1.11.2 board = esp32dev framework = ${common.framework} lib_deps = ${common.lib_deps} @@ -45,7 +45,7 @@ extra_scripts = scripts/makeweb.py [env:lolind32] -platform = espressif32 +platform = espressif32@1.11.2 board = lolin_d32 framework = ${common.framework} lib_deps = ${common.lib_deps} @@ -54,7 +54,7 @@ extra_scripts = scripts/makeweb.py [env:featheresp32] -platform = espressif32 +platform = espressif32@1.11.2 board = featheresp32 framework = ${common.framework} lib_deps = ${common.lib_deps} diff --git a/src/AmsData.cpp b/src/AmsData.cpp index 8bd1ed39..fdd9c890 100644 --- a/src/AmsData.cpp +++ b/src/AmsData.cpp @@ -163,10 +163,12 @@ void AmsData::extractFromAidon(HanReader& hanReader, int listSize) { activeExportPower = hanReader.getInt( (int)Aidon_List3PhaseIT::ActiveExportPower); reactiveExportPower = hanReader.getInt( (int)Aidon_List3PhaseIT::ReactiveExportPower); l1current = ((double) hanReader.getInt( (int)Aidon_List3PhaseIT::CurrentL1)) / 10; + l2current = 0; l3current = ((double) hanReader.getInt( (int)Aidon_List3PhaseIT::CurrentL3)) / 10; l1voltage = ((double) hanReader.getInt( (int)Aidon_List3PhaseIT::VoltageL1)) / 10; l2voltage = ((double) hanReader.getInt( (int)Aidon_List3PhaseIT::VoltageL2)) / 10; l3voltage = ((double) hanReader.getInt( (int)Aidon_List3PhaseIT::VoltageL3)) / 10; + //l2current = ((activeImportPower * sqrt(3)) - (l1voltage * l1current) - (l3voltage * l3current)) / l2voltage; threePhase = true; break; } diff --git a/src/AmsData.h b/src/AmsData.h index 80b6543a..df9f3ec5 100644 --- a/src/AmsData.h +++ b/src/AmsData.h @@ -48,15 +48,15 @@ public: bool isThreePhase(); private: - unsigned long lastUpdateMillis; - int listType; - unsigned long packageTimestamp; + unsigned long lastUpdateMillis = 0; + int listType = 0; + unsigned long packageTimestamp = 0; String listId, meterId, meterType; - unsigned long meterTimestamp; - int activeImportPower, reactiveImportPower, activeExportPower, reactiveExportPower; - double l1voltage, l2voltage, l3voltage, l1current, l2current, l3current; - double activeImportCounter, reactiveImportCounter, activeExportCounter, reactiveExportCounter; - bool threePhase; + unsigned long meterTimestamp = 0; + int activeImportPower = 0, reactiveImportPower = 0, activeExportPower = 0, reactiveExportPower = 0; + double l1voltage = 0, l2voltage = 0, l3voltage = 0, l1current = 0, l2current = 0, l3current = 0; + double activeImportCounter = 0, reactiveImportCounter = 0, activeExportCounter = 0, reactiveExportCounter = 0; + bool threePhase = false; void extractFromKaifa(HanReader& hanReader, int listSize); void extractFromAidon(HanReader& hanReader, int listSize); diff --git a/src/AmsToMqttBridge.ino b/src/AmsToMqttBridge.ino index 44a9b199..dae6a981 100644 --- a/src/AmsToMqttBridge.ino +++ b/src/AmsToMqttBridge.ino @@ -273,19 +273,19 @@ void errorBlink() { switch(lastError) { case 0: if(lastErrorBlink - lastSuccessfulRead > 30000) { - rgb_led(RGB_RED, 2); // If no message received from AMS in 30 sec, blink once + rgb_led(1, 2); // If no message received from AMS in 30 sec, blink once return; } break; case 1: if(!config.getMqttHost().isEmpty() && mqtt.lastError() != 0) { - rgb_led(RGB_RED, 3); // If MQTT error, blink twice + rgb_led(1, 3); // If MQTT error, blink twice return; } break; case 2: if(WiFi.getMode() != WIFI_AP && WiFi.status() != WL_CONNECTED) { - rgb_led(RGB_RED, 4); // If WiFi not connected, blink three times + rgb_led(1, 4); // If WiFi not connected, blink three times return; } break; diff --git a/src/web/AmsWebServer.cpp b/src/web/AmsWebServer.cpp index 5fd0202e..63f7714a 100644 --- a/src/web/AmsWebServer.cpp +++ b/src/web/AmsWebServer.cpp @@ -104,7 +104,8 @@ void AmsWebServer::indexHtml() { html.replace("${data.P}", String(data.getActiveImportPower())); html.replace("${data.PO}", String(data.getActiveExportPower())); - html.replace("${display.production}", config->getProductionCapacity() > 0 ? "" : "none"); + html.replace("${display.export}", config->getProductionCapacity() > 0 ? "" : "none"); + html.replace("${text.import}", config->getProductionCapacity() > 0 ? "Import" : "Consumption"); html.replace("${data.U1}", u1 > 0 ? String(u1, 1) : ""); html.replace("${data.I1}", u1 > 0 ? String(i1, 1) : ""); @@ -292,7 +293,7 @@ void AmsWebServer::dataJson() { StaticJsonDocument<768> json; String jsonStr; - if(data.getActiveImportPower() > 0) { + if(data.getLastUpdateMillis() > 0) { int maxPwr = this->maxPwr; if(maxPwr == 0) { if(data.isThreePhase()) { @@ -356,10 +357,10 @@ void AmsWebServer::dataJson() { json["meterType"] = config->getMeterType(); json["currentMillis"] = now; double vcc = hw.getVcc(); - json["vcc"] = vcc > 0 ? vcc : 0; + json["vcc"] = serialized(String(vcc, 3)); double temp = hw.getTemperature(); - json["temp"] = temp; + json["temp"] = serialized(String(temp, 2)); json.createNestedObject("wifi"); float rssi = WiFi.RSSI(); @@ -382,13 +383,12 @@ void AmsWebServer::dataJson() { } json["status"]["esp"] = espStatus; - unsigned long lastHan = json.isNull() ? 0 : json["up"].as(); String hanStatus; if(config->getMeterType() == 0) { hanStatus = "secondary"; - } else if(now - lastHan < 15000) { + } else if(now - data.getLastUpdateMillis() < 15000) { hanStatus = "success"; - } else if(now - lastHan < 30000) { + } else if(now - data.getLastUpdateMillis() < 30000) { hanStatus = "warning"; } else { hanStatus = "danger"; diff --git a/web/index.html b/web/index.html index e57688b5..56fa19c6 100644 --- a/web/index.html +++ b/web/index.html @@ -92,7 +92,7 @@
${data.P} W
- @@ -139,11 +139,11 @@
-
+
${data.PO} W
-
@@ -194,15 +194,15 @@