fix flow check and add reset when pump is off

This commit is contained in:
interfisch 2025-07-14 18:50:26 +02:00
parent 8601e58d03
commit 37ef9a780d
2 changed files with 10 additions and 3 deletions

View file

@ -9,7 +9,7 @@ uint16_t flow_counter=0; //maximum counts/s measured with Eden 128 Pump was 171
void flow_setup();
void flow_loop(unsigned long loopmillis);
bool checkFlow(float minflow,unsigned long maxtime);
bool checkFlow(float minflow,unsigned long maxtime,bool reset=false);
void IRAM_ATTR isr_flow();
unsigned long last_read_flow=0;
@ -58,8 +58,12 @@ void flow_loop(unsigned long loopmillis) {
}
bool checkFlow(float minflow,unsigned long maxtime) { //L/min, milliseconds
bool checkFlow(float minflow,unsigned long maxtime,bool reset) { //L/min, milliseconds
static unsigned long last_flow_low=0; //0=flow ok
if (reset) {
last_flow_low=0;
return true;
}
if (flow<minflow) { //flow too low
if (last_flow_low==0) { //not set yet
last_flow_low=millis();
@ -74,6 +78,7 @@ bool checkFlow(float minflow,unsigned long maxtime) { //L/min, milliseconds
}
}
void IRAM_ATTR isr_flow() {
flow_counter++;
flow_counter_sum++;

View file

@ -249,12 +249,14 @@ void loop() {
pump_loop(loopmillis);
#ifdef FLOW_PIN
if (isPumpRunning(1)) { //Check pump 1 flow
if (checkFlow(0.2, 20*1000)) {
if (!checkFlow(0.2, 20*1000)) {
Serial.println("pumpError flow too low");
if (mqtt){
publishInfo("error/pump","pumpError flow too low. flow="+String(flow));
}
}
}else{
checkFlow(0,0,true); //reset reset timer
}
#endif
#endif