diff --git a/HeishaMon/featureboard.cpp b/HeishaMon/featureboard.cpp index b8272da0..ae5e2c64 100644 --- a/HeishaMon/featureboard.cpp +++ b/HeishaMon/featureboard.cpp @@ -10,7 +10,7 @@ #define FETCHTEMPSTIME 5000 // how often Dallas temps are read in msec #define MAXTEMPDIFFPERSEC 0.5 // what is the allowed temp difference per second which is allowed (to filter bad values) -#define FETCHS0TIME 5000 // how often s0 Watts are reported +#define MINREPORTEDS0TIME 5000 // how often s0 Watts are reported (not faster than this) OneWire oneWire(ONE_WIRE_BUS); DallasTemperature DS18B20(&oneWire); @@ -118,31 +118,35 @@ ICACHE_RAM_ATTR void onS0Pulse1() { ICACHE_RAM_ATTR void onS0Pulse2() { new_pulse_s0[1] = millis(); + } void initS0Sensors(s0Data actS0Data[]) { - pinMode(actS0Data[0].gpiopin, INPUT_PULLUP); attachInterrupt(digitalPinToInterrupt(actS0Data[0].gpiopin), onS0Pulse1, RISING); - actS0Data[0].lastPulse = millis(); - + actS0Data[0].nextReport = millis() + 1000 * actS0Data[0].reportInterval; //initial report after interval, not directly at boot pinMode(actS0Data[1].gpiopin, INPUT_PULLUP); attachInterrupt(digitalPinToInterrupt(actS0Data[1].gpiopin), onS0Pulse2, RISING); - actS0Data[1].lastPulse = millis(); + actS0Data[1].nextReport = millis() + 1000 * actS0Data[1].reportInterval; //initial report after interval, not directly at boot } void s0Loop(s0Data actS0Data[], PubSubClient &mqtt_client, void (*log_message)(char*)) { for (int i = 0 ; i < NUM_S0_COUNTERS ; i++) { //first handle new detected pulses - if (new_pulse_s0[i] > 0) { + if ((new_pulse_s0[i] > 0) && ((new_pulse_s0[i] - actS0Data[i].lastPulse) > 50L)){ //50ms debounce filter, this also prevents division by zero to occur a few lines further down the road if pulseInterval = 0 actS0Data[i].pulseInterval = new_pulse_s0[i] - actS0Data[i].lastPulse; - actS0Data[i].watt = (3600000000.0 / actS0Data[i].pulseInterval) / actS0Data[i].ppkwh; + if (actS0Data[i].lastPulse > 0) { //Do not calculate watt for the first pulse since reboot because we will always report a too high watt. Better to show 0 watt at first pulse. + actS0Data[i].watt = (3600000000.0 / actS0Data[i].pulseInterval) / actS0Data[i].ppkwh; + } actS0Data[i].lastPulse = new_pulse_s0[i]; actS0Data[i].pulses++; new_pulse_s0[i] = 0; - //Serial1.print("S0 port "); Serial1.print(i); Serial1.print(" detected pulse. Pulses since last report: "); Serial1.println(actS0Data[i].pulses); + if ((actS0Data[i].nextReport - millis()) < (( 1000 * actS0Data[i].reportInterval) - MINREPORTEDS0TIME )) { //it is already MINREPORTEDS0TIME millis ago since last report + actS0Data[i].nextReport = millis(); // report now + } + Serial1.print("S0 port "); Serial1.print(i); Serial1.print(" detected pulse. Pulses since last report: "); Serial1.println(actS0Data[i].pulses); } //then report after each reportInterval diff --git a/HeishaMon/version.h b/HeishaMon/version.h index f7e5259b..7334da4e 100644 --- a/HeishaMon/version.h +++ b/HeishaMon/version.h @@ -1 +1 @@ -static const char* heishamon_version = "0.7"; +static const char* heishamon_version = "0.8b"; diff --git a/HeishaMon/webfunctions.cpp b/HeishaMon/webfunctions.cpp index fda379e1..6e7b655d 100644 --- a/HeishaMon/webfunctions.cpp +++ b/HeishaMon/webfunctions.cpp @@ -635,10 +635,10 @@ void handleSettings(ESP8266WebServer *httpServer, char* wifi_hostname, char* ota httptext = httptext + "S0 port " + (i + 1) + " imp/kwh:
"; httptext = httptext + ""; httptext = httptext + "

"; - httptext = httptext + "S0 port " + (i + 1) + " reporting interval:
"; + httptext = httptext + "S0 port " + (i + 1) + " reporting interval during standby/low power usage:
"; httptext = httptext + ""; httptext = httptext + "

"; - httptext = httptext + "S0 port " + (i + 1) + " minimal power measured: Watt"; + httptext = httptext + "S0 port " + (i + 1) + " standby/low power usage threshold: Watt"; } httptext = httptext + ""; diff --git a/README.md b/README.md index e6c71656..292cf8ac 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,9 @@ Suomen kielellä [README_FI.md](README_FI.md) luettavissa täällä. *Help on translation to other languages is welcome.* # Current releases -Current beta release is version 0.6b. The [compiled binary](binaries/HeishaMon.ino.d1-v0.6.bin) can be installed on a Wemos D1 mini (and generally on any ESP8266 based board - but without guarantee). You can also download the code and compile it yourself (see required libraries below). +Current beta release is version 0.8b. The [compiled binary](binaries/HeishaMon.ino.d1-v0.8b.bin) can be installed on a Wemos D1 mini, on the HeishaMon PCB and generally on any ESP8266 based board compatible with Wemos build settings (at least 4MB flash). You can also download the code and compile it yourself (see required libraries below). \ +Changed from 0.6 to 0.7 is a bug fix for the webinterface which resulted in the page become slow after minutes of having the page open. And from 0.7 to 0.8 is a better S0 kWh meter algoritm. + # Using the software The current arduino beta image is able to communicate with the Panasonic Aquarea H-series (and most probably with the new J-series as well, since PCB looks identical). \ diff --git a/binaries/HeishaMon.ino.d1-v0.6b-iy-1.bin b/binaries/HeishaMon.ino.d1-v0.6b-iy-1.bin deleted file mode 100644 index 247d66dd..00000000 Binary files a/binaries/HeishaMon.ino.d1-v0.6b-iy-1.bin and /dev/null differ diff --git a/binaries/HeishaMon.ino.d1-v0.6b-iy-2.bin b/binaries/HeishaMon.ino.d1-v0.6b-iy-2.bin deleted file mode 100644 index 41adb166..00000000 Binary files a/binaries/HeishaMon.ino.d1-v0.6b-iy-2.bin and /dev/null differ diff --git a/binaries/HeishaMon.ino.d1_v0.7b.bin b/binaries/HeishaMon.ino.d1-v0.7b.bin similarity index 100% rename from binaries/HeishaMon.ino.d1_v0.7b.bin rename to binaries/HeishaMon.ino.d1-v0.7b.bin diff --git a/binaries/HeishaMon.ino.d1-v0.6c-iy-2.bin b/binaries/HeishaMon.ino.d1-v0.8b.bin similarity index 74% rename from binaries/HeishaMon.ino.d1-v0.6c-iy-2.bin rename to binaries/HeishaMon.ino.d1-v0.8b.bin index aa59f24d..1fe50c93 100644 Binary files a/binaries/HeishaMon.ino.d1-v0.6c-iy-2.bin and b/binaries/HeishaMon.ino.d1-v0.8b.bin differ diff --git a/binaries/HeishaMon.ino.generic-v0.6c.bin b/binaries/HeishaMon.ino.generic-v0.6c.bin deleted file mode 100644 index 816240bb..00000000 Binary files a/binaries/HeishaMon.ino.generic-v0.6c.bin and /dev/null differ diff --git a/binaries/HeishaMon.ino.genericModel.bin b/binaries/HeishaMon.ino.genericModel.bin deleted file mode 100644 index 816240bb..00000000 Binary files a/binaries/HeishaMon.ino.genericModel.bin and /dev/null differ diff --git a/binaries/HeishaMon.ino.generic_06b.bin b/binaries/HeishaMon.ino.generic_06b.bin deleted file mode 100644 index ebab2031..00000000 Binary files a/binaries/HeishaMon.ino.generic_06b.bin and /dev/null differ