You will receive notifications every second, it is better to put a flag in your code
About setInterval, try this :
// Setup a function to be called every 10 seconds
timer.setInterval(10000L, sendSensor);
// Setup a function to be called every second
timer.setInterval(1000L, ledStatus);
about flag
if(digitalRead(FLOAT_SENSOR2) == HIGH)
{
// turn LED on:
digitalWrite(LED, HIGH);
if(flag==0){
Blynk.notify("First water level detected");
flag=1; //Toggle flag
}
}
else
{
// turn LED off:
digitalWrite(LED, LOW);
flag=0; //Reset notify when FLOAT_SENSOR2 is low
The flag prevents sending multiple alerts.
You have to add the flag condition to the email function, otherwise you will receive an email every second and it’s not allowed .
One timer object (HeartbeatTimer) with multiple timers is a better way to describe it.
If you read the “Staggering Timers” section of the topic I linked to then you’ll see how to avoid having your first two timers coinciding every 5 seconds, and them all coinciding every 60 seconds. This can get quite critical when you have shorter duration timers and functions that take a while to execute.