Skip to content

Commit

Permalink
Merge pull request #161 from IgorYbema/master
Browse files Browse the repository at this point in the history
release 0.8b
  • Loading branch information
Egyras authored Sep 23, 2020
2 parents 1d91bb1 + 0ecd0e1 commit e651e02
Show file tree
Hide file tree
Showing 11 changed files with 18 additions and 12 deletions.
20 changes: 12 additions & 8 deletions HeishaMon/featureboard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion HeishaMon/version.h
Original file line number Diff line number Diff line change
@@ -1 +1 @@
static const char* heishamon_version = "0.7";
static const char* heishamon_version = "0.8b";
4 changes: 2 additions & 2 deletions HeishaMon/webfunctions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -635,10 +635,10 @@ void handleSettings(ESP8266WebServer *httpServer, char* wifi_hostname, char* ota
httptext = httptext + "S0 port " + (i + 1) + " imp/kwh:<br>";
httptext = httptext + "<input type=\"number\" id=\"s0_ppkwh_" + (i+1) + "\" onchange=\"changeMinWatt(" + (i+1) + ")\" name=\"s0_" + (i + 1) + "_ppkwh\" value=\"" + (actS0Data[i].ppkwh) + "\">";
httptext = httptext + "<br><br>";
httptext = httptext + "S0 port " + (i + 1) + " reporting interval:<br>";
httptext = httptext + "S0 port " + (i + 1) + " reporting interval during standby/low power usage:<br>";
httptext = httptext + "<input type=\"number\" id=\"s0_interval_" + (i+1) + "\" onchange=\"changeMinWatt(" + (i+1) + ")\" name=\"s0_" + (i + 1) + "_interval\" value=\"" + (actS0Data[i].reportInterval) + "\">";
httptext = httptext + "<br><br>";
httptext = httptext + "S0 port " + (i + 1) + " minimal power measured: <label id=\"s0_minwatt_" + (i+1) + "\">"+(int) round((3600 * 1000 / actS0Data[i].ppkwh)/ actS0Data[i].reportInterval)+"</label> Watt";
httptext = httptext + "S0 port " + (i + 1) + " standby/low power usage threshold: <label id=\"s0_minwatt_" + (i+1) + "\">"+(int) round((3600 * 1000 / actS0Data[i].ppkwh)/ actS0Data[i].reportInterval)+"</label> Watt";
}
httptext = httptext + "</div>";

Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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). \
Expand Down
Binary file removed binaries/HeishaMon.ino.d1-v0.6b-iy-1.bin
Binary file not shown.
Binary file removed binaries/HeishaMon.ino.d1-v0.6b-iy-2.bin
Binary file not shown.
File renamed without changes.
Binary file not shown.
Binary file removed binaries/HeishaMon.ino.generic-v0.6c.bin
Binary file not shown.
Binary file removed binaries/HeishaMon.ino.genericModel.bin
Binary file not shown.
Binary file removed binaries/HeishaMon.ino.generic_06b.bin
Binary file not shown.

0 comments on commit e651e02

Please sign in to comment.