[SOLVED] Flag Notifications NODEMCU

Hi All,

This is the first time I posted in this forum, I have learned a lot but I have some issues with mi project, almost all is done and works fine as expected, the only issue I have is basically the notifications. I’m trying just to send only one notification in different parts of the void but for some reason I was not able to complete this part.

void sendSensor2() {

sensors.requestTemperatures();
temperature2 = sensors.getTempC(tempSensor2);
Blynk.virtualWrite(2, temperature2);
if(digitalRead(button2) == HIGH){ //If Virtual button2 is HIGH the temperature logic continue  

  if (temperature2 > slide2){ //temperature2 higher than slide2
  digitalWrite(led2, HIGH);
  blynkled2.on();
        
        //This 'If' below works if the temperature is higher than expected and send a notification
        //I want just to send only one notification instead of every 15seg
        if (temperature2 > slide2+2){
        Blynk.notify(String("Warning: Temperature ")+temperature2+"°C Higher than "+slide2+"°C");
        blynkled2.on();
        }
        else{
        
        }
  }
        else if (temperature2 < slide2-1) {
        digitalWrite(led2, LOW);
        blynkled2.off();

          //This 'If' below works if the temperature is lower than expected and send a notification
          //I just want to send only one notification instead of every 15seg
          if (temperature2 < slide2-3){
          Blynk.notify(String("Warning Temperature ")+temperature2+"°C Lower than "+slide2+"°C");
          blynkled2.off();
          }
        else{
        
        }
  }
}


//If Virtual button is LOW no calculations are allowed and send a notification that Temperature is OFF
//I want just to send one notification instead of every 15seg
else{ 
  blynkled2.off();
  digitalWrite(led2, LOW);
  Blynk.notify("Temperature is OFF");
}
}

Here is a rough pseudo code idea. It utilises a BlynkTimer timer.setTimeout() function. More info here…

https://playground.arduino.cc/Code/SimpleTimer#Functions

SomeFunction() {
     if(Temp check and flag check are correct) {
          set flag
          send notification
          start timeout timer for flag reset
              (reset flag) // this could be another function called byt the timeout that resets the flag accordingly
     }  // end if
}  // end function

Thanks a lot Gunner I set 2 different flags, one for High Temperature and one for Low Temperature and now is working fine!