Using Timer after blynk.notify()

Hello,
I want to use the Blynk.Notify() and then run a timer so I won’t send messages to my app in every run of the code.

an example:
I have a temp sensor that record temprature. I want blynk to notify me when the temprature exceeds 50C. but even if it does reach that point it will take some time to get below this point and the arduino will run this code a lot of times until the temprature will drop below 50C. and I don’t want to get million notification over something that I am aware. but on the off chance that I wanted to deal with the problem and forgot I do want to be nitified again after let’s say 5 minutes or 30 minutes…

Is there something I can do to execute the nitification only once every set amount of time? :confused:

Thanks in advance. :slight_smile:

bool tempflag = true;

if ((temp > x) && (tempflag == true)){
   blynk.notify("Temperature is > x");
   tempflag = false;
}
if (temp <= x){
  tempflag = true;
}
1 Like

ok that is cool if I can deal with the problem. but if I want it to remind me let’s say every 10 minutes? until I solve it?

SimpleTimer to call a function every 10 minutes and in the function just:

tempflag = true;

ok that’s what I thought. but where should I put this simple timer? in the loop section?
and after the 10 minutes to check and notify?

I wanted to start a timer from the function that sets the flag itself. but I’m not sure if that stops the code? or just start the timer on another thread.

You need to learn how SimpleTimer works as I’m not going to do all your coding for you.

You can start the 10 minute Timer inside the temperature reading function but you should be calling the temperature reading function at intervals (1s, 10s, 30s etc) with a separate SimpleTimer function.

Look at the SimpleTimer used in https://github.com/blynkkk/blynk-library/blob/master/examples/GettingStarted/PushData/PushData.ino and study Arduino Playground - HomePage