Skip to content

Commit

Permalink
release 0.8b
Browse files Browse the repository at this point in the history
  • Loading branch information
IgorYbema committed Sep 23, 2020
1 parent a118595 commit 0a3ee09
Show file tree
Hide file tree
Showing 10 changed files with 15 additions and 11 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
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 0a3ee09

Please sign in to comment.