[SOLVED] Notifications happen too frequently

Hi all,

I’m building a temperature monitoring unit to notify me when the temp in a room reaches a certain point. Currently, the notifications happen too frequently. I am not sure why as I’m using a flag to avoid sending more notifications while a condition is true. Code below:

void readTemp() {
  DS18B20.requestTemperatures();
  temp = DS18B20.getTempFByIndex(0);
  Blynk.virtualWrite(0, temp);
  if ((temp <= 55) && (notified == false)) {
    Blynk.virtualWrite(V4, 1023);
    String phoneAlarm = String("Mud room temp is low: ") + temp + " °F";
    Blynk.notify(phoneAlarm);
    Blynk.email("jcs44@njit.edu", "Temperature Alarm: Mud Room", "Mud room temp is below 55 °F.");
    timer.setTimeout(30000L, resetNotified);
    notified == true;
  }
  else {
    Blynk.virtualWrite(V4, 0);
  }
}

void resetNotified() {
  notified = false;
}

FYI I initialize my boolean notified to false in my setup function. Any ideas?

Hello… this is NOT a how to code or code repair forum.

You have a few syntax errors in your code. e.g.

should be formatted properly

  if ((temp <= 55 && notified == false)) {

And here, you are using an equal to but should be using an assignment operator.

There may be more.

Sorry @Gunner - you did fix my problem though. Stupid coding on my part. Thanks.

No problem… I do sometimes try to help even as I try to keep order :wink:

Follow those links to Arduino’s site… I keep that one page open on my desktop all the time for reference.