Skip to main content
2nd part of answer.
Source Link
jose can u c
  • 7k
  • 2
  • 17
  • 27

Your code:

timer.setInterval(16000L,notifyOnButtonPress);

Is calling this function every 16s.

This code:

if (floatLevelLow && floatLevelLow != floatSavedState) {

needs some parentheses to force your desired order-of-operations. As it stands now, you are asking the result of floatLevelLow && floatLevelLow and comparing if that is not equal to floatSavedState. That's likely not what you want.

Did you mean:

if (floatLevelLow && (floatLevelLow != floatSavedState)) {

EDIT:

Also, your if/else is missing brackets around the 2nd clause and should be:

} else if (floatLevelLow != floatSavedState) {
     // send notification if this is first time or if the float level has
     // changed since the last notification.
     Serial.println("Resevoir Water is High!");
     Blynk.notify("Alert : Water level high");
     floatSavedState = floatLevelLow;
}

Your code:

timer.setInterval(16000L,notifyOnButtonPress);

Is calling this function every 16s.

This code:

if (floatLevelLow && floatLevelLow != floatSavedState) {

needs some parentheses to force your desired order-of-operations. As it stands now, you are asking the result of floatLevelLow && floatLevelLow and comparing if that is not equal to floatSavedState. That's likely not what you want.

Did you mean:

if (floatLevelLow && (floatLevelLow != floatSavedState)) {

Your code:

timer.setInterval(16000L,notifyOnButtonPress);

Is calling this function every 16s.

This code:

if (floatLevelLow && floatLevelLow != floatSavedState) {

needs some parentheses to force your desired order-of-operations. As it stands now, you are asking the result of floatLevelLow && floatLevelLow and comparing if that is not equal to floatSavedState. That's likely not what you want.

Did you mean:

if (floatLevelLow && (floatLevelLow != floatSavedState)) {

EDIT:

Also, your if/else is missing brackets around the 2nd clause and should be:

} else if (floatLevelLow != floatSavedState) {
     // send notification if this is first time or if the float level has
     // changed since the last notification.
     Serial.println("Resevoir Water is High!");
     Blynk.notify("Alert : Water level high");
     floatSavedState = floatLevelLow;
}
Source Link
jose can u c
  • 7k
  • 2
  • 17
  • 27

Your code:

timer.setInterval(16000L,notifyOnButtonPress);

Is calling this function every 16s.

This code:

if (floatLevelLow && floatLevelLow != floatSavedState) {

needs some parentheses to force your desired order-of-operations. As it stands now, you are asking the result of floatLevelLow && floatLevelLow and comparing if that is not equal to floatSavedState. That's likely not what you want.

Did you mean:

if (floatLevelLow && (floatLevelLow != floatSavedState)) {