From 9c09740a414f1ce94b0cf742c55034b26975b937 Mon Sep 17 00:00:00 2001 From: Gunnar Skjold Date: Sat, 15 Feb 2020 21:04:18 +0100 Subject: [PATCH] Production graph and fixed vcc value --- src/HwTools.cpp | 4 +- src/web/AmsWebServer.cpp | 10 ++- src/web/AmsWebServer.h | 2 +- web/index.html | 135 +++++++++++++++++++++++++++------------ 4 files changed, 105 insertions(+), 46 deletions(-) diff --git a/src/HwTools.cpp b/src/HwTools.cpp index 3be1d543..797a3385 100644 --- a/src/HwTools.cpp +++ b/src/HwTools.cpp @@ -3,9 +3,9 @@ double HwTools::getVcc() { #if defined(ARDUINO_ESP8266_WEMOS_D1MINI) - return (((double) ESP.getVcc()) / 1000) * 1.1; // This board has a voltage divider on VCC, add 10% + return (((double) ESP.getVcc()) / 1024) * 1.1; // This board has a voltage divider on VCC, add 10% #elif defined(ESP8266) - return ((double) ESP.getVcc()) / 1000; + return ((double) ESP.getVcc()) / 1024; #endif return -1; } diff --git a/src/web/AmsWebServer.cpp b/src/web/AmsWebServer.cpp index a8f66fe3..c8cb7a4b 100644 --- a/src/web/AmsWebServer.cpp +++ b/src/web/AmsWebServer.cpp @@ -43,6 +43,7 @@ void AmsWebServer::loop() { void AmsWebServer::setJson(StaticJsonDocument<1024> json) { if(!json.isNull()) { p = json["data"]["P"].as(); + po = json["data"]["PO"].as(); if(json["data"].containsKey("U1")) { u1 = json["data"]["U1"].as(); @@ -134,6 +135,8 @@ void AmsWebServer::indexHtml() { String html = String((const __FlashStringHelper*) INDEX_HTML); html.replace("${version}", VERSION); html.replace("${data.P}", String(p)); + html.replace("${data.PO}", String(po)); + html.replace("${display.production}", config->getProductionCapacity() > 0 ? "" : "none"); html.replace("${data.U1}", u1 > 0 ? String(u1, 1) : ""); html.replace("${data.I1}", u1 > 0 ? String(i1, 1) : ""); @@ -302,14 +305,17 @@ void AmsWebServer::dataJson() { maxPwr = 10000; } } + int maxPrd = config->getProductionCapacity() * 1000; json["up"] = this->json["up"]; json["t"] = this->json["t"]; json["data"] = this->json["data"]; - json["pct"] = min(p*100/maxPwr, 100); + json["p_pct"] = min(p*100/maxPwr, 100); + json["po_pct"] = min(po*100/maxPrd, 100); } else { - json["pct"] = -1; + json["p_pct"] = -1; + json["po_pct"] = -1; println(" json is empty"); } diff --git a/src/web/AmsWebServer.h b/src/web/AmsWebServer.h index 00f15af2..7c82a836 100644 --- a/src/web/AmsWebServer.h +++ b/src/web/AmsWebServer.h @@ -35,7 +35,7 @@ private: MQTTClient* mqtt; StaticJsonDocument<1024> json; int maxPwr; - int p; + int p, po; double u1, u2, u3, i1, i2, i3, tpi, tpo, tqi, tqo; #if defined(ESP8266) diff --git a/web/index.html b/web/index.html index 28ad7f9f..ba858f18 100644 --- a/web/index.html +++ b/web/index.html @@ -98,62 +98,72 @@
-
+
${data.P} W
-
-
+
P1
${data.U1} V
${data.I1} A
-
+
P2
${data.U2} V
${data.I2} A
-
+
P3
${data.U3} V
${data.I3} A

-
+
Active in
${data.tPI} kWh
-
+
Active out
${data.tPO} kWh
-
+
Reactive in
${data.tQI} kvarh
-
+
Reactive out
${data.tQO} kvarh
-
+
+
+ ${data.PO} W +
+ +
+

@@ -184,7 +194,19 @@