From 4b32af69a7e7f109c25124b9352aae1d61629022 Mon Sep 17 00:00:00 2001 From: Gunnar Skjold Date: Tue, 18 Feb 2020 07:37:42 +0100 Subject: [PATCH 1/6] Fixed typo --- lib/HanToJson/src/HanToJson.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/HanToJson/src/HanToJson.cpp b/lib/HanToJson/src/HanToJson.cpp index 3b084861..d5c19b8d 100644 --- a/lib/HanToJson/src/HanToJson.cpp +++ b/lib/HanToJson/src/HanToJson.cpp @@ -146,7 +146,7 @@ static void hanToJsonAidon3phaseIT(int listSize, JsonObject& data, HanReader& ha data["PO"] = hanReader.getInt( (int)Aidon_List3PhaseIT::ActiveExportPower); data["QO"] = hanReader.getInt( (int)Aidon_List3PhaseIT::ReactiveExportPower); data["I1"] = ((double) hanReader.getInt( (int)Aidon_List3PhaseIT::CurrentL1)) / 10; - data["I1"] = 0; + data["I2"] = 0; data["I3"] = ((double) hanReader.getInt( (int)Aidon_List3PhaseIT::CurrentL3)) / 10; data["U1"] = ((double) hanReader.getInt( (int)Aidon_List3PhaseIT::VoltageL1)) / 10; data["U2"] = ((double) hanReader.getInt( (int)Aidon_List3PhaseIT::VoltageL2)) / 10; From 52bc2b14c99cc1ba196ac6796791c5c0bdbe3d23 Mon Sep 17 00:00:00 2001 From: Gunnar Skjold Date: Sun, 23 Feb 2020 20:31:10 +0100 Subject: [PATCH 2/6] Some changes after testing --- src/AmsToMqttBridge.ino | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/AmsToMqttBridge.ino b/src/AmsToMqttBridge.ino index a1be1c67..50aa7835 100644 --- a/src/AmsToMqttBridge.ino +++ b/src/AmsToMqttBridge.ino @@ -234,7 +234,7 @@ void loop() { else led_off(); } - if(now - lastRead > 150) { + if(now - lastRead > 100) { yield(); readHanPort(); lastRead = now; @@ -332,6 +332,11 @@ void mqttMessageReceived(String &topic, String &payload) void readHanPort() { if (hanReader.read()) { + // Empty serial buffer. For some reason this seems to make a difference. Some garbage on the wire after package? + while(hanSerial->available()) { + hanSerial->read(); + } + lastSuccessfulRead = millis(); if(config.getMeterType() > 0) { @@ -534,9 +539,10 @@ void sendMqttData(String data) } void rgb_led(int color, int mode) { -// Activate red and green LEDs +// Activate red and green LEDs if RGB LED is present (HAS_RGB_LED=1) +// If no RGB LED present (HAS_RGB_LED=0 or not defined), all output goes to ESP onboard LED // color: 1=red, 2=green, 3=yellow -// mode: 0=OFF, 1=ON, 2=Short blink +// mode: 0=OFF, 1=ON, >=2 -> Short blink(s), number of blinks: (mode - 1) #ifndef HAS_RGB_LED #define LEDPIN_RGB_RED LED_PIN #define LEDPIN_RGB_GREEN LED_PIN From d8dfaaa73034a36e0ef2e6b7e7f9105554bc2e52 Mon Sep 17 00:00:00 2001 From: Gunnar Skjold Date: Mon, 24 Feb 2020 07:46:48 +0100 Subject: [PATCH 3/6] Version hardening --- platformio.ini | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) 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} From 478d63505d2a82d79d3ff6a9a1accec31f880582 Mon Sep 17 00:00:00 2001 From: Gunnar Skjold Date: Mon, 24 Feb 2020 07:47:12 +0100 Subject: [PATCH 4/6] Allow compiling when RGB is not defined --- src/AmsToMqttBridge.ino | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/AmsToMqttBridge.ino b/src/AmsToMqttBridge.ino index 50aa7835..f1c41d5c 100644 --- a/src/AmsToMqttBridge.ino +++ b/src/AmsToMqttBridge.ino @@ -271,19 +271,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; From 78e531a7e9aa28176871ba88c473538ba22afec8 Mon Sep 17 00:00:00 2001 From: Gunnar Skjold Date: Mon, 24 Feb 2020 07:47:39 +0100 Subject: [PATCH 5/6] Changed term for production and consumption when local production is defined --- src/web/AmsWebServer.cpp | 3 ++- web/index.html | 34 +++++++++++++++++----------------- 2 files changed, 19 insertions(+), 18 deletions(-) diff --git a/src/web/AmsWebServer.cpp b/src/web/AmsWebServer.cpp index 5fd0202e..ee435af8 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) : ""); 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 @@