[SOLVED] Emails Notifications Repeating

That worked after adding:

unsigned int notified = 0;

I also get:

“resetNotified was not declared”

How to declare it? Thank you

@flhtraveler you need to learn how to post formatted code on the forum. It has been covered many times.

Looking at your illegible code it looks like you have braces in the wrong place.

Move the } before void loop() to just before void resetNotified() and you should be good to go.

If this fails post a formatted sketch.

That worked in removing the declaration error. Now that I re-connected the temperature sensor I continue to get 3 emails per minute notifying me that the temperature is above 60 F. Here is the code:

#define BLYNK_PRINT Serial // Comment this out to disable prints and save space

#include <ESP8266WiFi.h>

#include <BlynkSimpleEsp8266.h>

#include <DHT.h>

#include <SimpleTimer.h>

#define DHTPIN D6

#define DHTTYPE DHT11

DHT dht(DHTPIN, DHTTYPE);

SimpleTimer timer;

float humidity, temp_f; // Values read from sensor

unsigned int notified = 0;

char auth[] = “e54a63f72f1b487b8fa19*********”; //insert here your token generated by Blynk

void setup()

{

Serial.begin(9600); // See the connection status in Serial Monitor

delay(10);

Blynk.begin(auth, “", "****”); //insert here your SSID and password

timer.setInterval(1000, sendData);

}

void sendData()

{

//Read the Temp and Humidity from DHT

float h = dht.readHumidity();

float t = dht.readTemperature(true);

//Write values to V04 and V05

Blynk.virtualWrite(4, h);

Blynk.virtualWrite(5, t);

if (t >= 60 && notified == 0){
notified = 1;
Blynk.email("***@", “ALARM”, “Temp is above 60F”);
timer.setTimeout(18000, resetNotified); // 5 min between emails

}

}

void resetNotified(){
notified = 0;

}

void loop()

{

Blynk.run();

timer.run();

}

I think it’s your timeout that needs a timerId, see http://playground.arduino.cc/Code/SimpleTimer#F_setTimeout

When you have it working post the formatted sketch here and don’t post any more unformatted versions on the forum.

Hi Dimitry,

Thank you for your reply. After several other replies from the community members and running hours of research I have not been able to find a solution to our problem. Basically I want an email to be sent after the temperature climbs above 60 degrees fahrenheit. The email is sent out but we get 3 emails per minute none stop. Can you please take a look at our code and let me know what else that I need to do to get Blynks email notification up & running smoothly. Here is the piece of code we plugged in:

if (t >= 60 && notified == 0){
notified = 1;
Blynk.email("************@************", “ALARM”, “Temp is above 60F”);
timer.setTimeout(18000, resetNotified); // 5 min between emails

@flhtraveler 18000 is 18s not 5 minutes!

Change 18000 to 300000L

I just changed from 18000 to 300000L however still getting 3 email per minute non stop. Is there anything else I can do?

@flhtraveler study this thread In case you see SMTHNG strange in Blynk

1 minute divide 18s is 3 and a bit, hence 3 emails per minute. Maximum is 4 per minutes as Blynk have a 15s minimum frequency between messages.

300000L is definitely your fix.

Post your code from the information you learnt by studying the details in the link I provided.

Yes you are right. The issue now is that my temperature is fixed at 66.2 however I get a notification every 5 minutes. I just want to get a notification one time only when the temperature climbs above 60 degrees. How to make this happen? This is the code I currently have:

if (t >= 60 && notified == 0){
notified = 1;
Blynk.email("andres.segrera@flhnorthamerica.com", “ALARM”, “Temp is above 60F”);
timer.setTimeout(300000L, resetNotified); // 5 min between emails

Of course.

Before we go any further did you study the link and how did your code suddenly change from 18s to 5minute intervals for emails?

This is the code you need, nothing else…

@Costas you also see the problem about dancing between 5.9 and 6.1 (Hysteresis should solve it) and you tried to make a better code but… you see the result :sweat_smile:

Here you go:

if (t >= 60 && notified == 0){ // check to see if flag is also set
  notified = 1; 
  Blynk.email("************@**************", "ALARM", "Temp is above 60F");
} else if(t < 58){ // set lower than 60... to stop the 59.9-60.0 bouncing. 
  notified = 0;
}
1 Like

The code is yours, I just corrected the 5 minutes from 18000 to 300000L :slight_smile:

No, it’s not my code, i’m just passing through reading everything in the forum :joy:

Edit: it’s truth, you also din’t made any code, it was Jamin…

@darkmoon I said the code belongs to @jamin, not you, see his first post in this thread.

lol im confused… the code is there for anyone who needs it :stuck_out_tongue:

also the last post I made actually fixes the 59.9-60.0 bug :wink:

1 Like

Forget it Jamin, it was my mistake, I was thinking that @Costas made the code.
I just wondering that the programming skills of fihtraveler are not so high and when you give him the timed solution he don’t have very clear what that solution do…
In every case, this post is marked as [solved] so I hope he hit the nail.

1 Like

Thank you all. I’ve ran tests and everything is working great. I used the the code posted by Jamin:

if (t >= 60 && notified == 0){ // check to see if flag is also set
  notified = 1; 
  Blynk.email("************@**************", "ALARM", "Temp is above 60F");
} else if(t < 58){ // set lower than 60... to stop the 59.9-60.0 bouncing. 
  notified = 0;
}
1 Like

A post was split to a new topic: Question about virtualWrites in timer and not main loop