BLYNK
BLYNK.IO       📲 GETTING STARTED       📗 DOCS       👉 SKETCH BUILDER

Need help with Notifications

Hi All,
I am trying to get the notification on email and mobile, if the temperature is above 28 degree. Below is my program. But I am not getting any notification. Can anyone please help me ?

#define BLYNK_TEMPLATE_ID "TemplateID"
#define BLYNK_DEVICE_NAME "DeviceName"
#define BLYNK_AUTH_TOKEN "AuthToken"

#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <DHT.h>


char auth[] = BLYNK_AUTH_TOKEN;

char ssid[] = "Wifi Username";  // type your wifi name
char pass[] = "Wifi Password";  // type your wifi password

#define DHTPIN 2          // Mention the digital pin where you connected 
#define DHTTYPE DHT11     // DHT 11  
DHT dht(DHTPIN, DHTTYPE);
BlynkTimer timer;

void sendSensor(){
  float h = dht.readHumidity();
  float t = dht.readTemperature(); // or dht.readTemperature(true) for Fahrenheit
  if (isnan(h) || isnan(t)) {
    Serial.println("Failed to read from DHT sensor!");
    return;
  }

  Serial.println(t);
  Blynk.virtualWrite(V5, h);
  Blynk.virtualWrite(V6, t);
    Serial.print("Temperature : ");
    Serial.print(t);
    Serial.print("    Humidity : ");
    Serial.println(h);


  if(t > 28){
    Blynk.email("techtrendsshameer@gmail.com", "Alert", "Temperature over 28C!");
    Blynk.logEvent("temp_alert");
  }
}

void setup(){
   Serial.begin(115200);
  Blynk.begin(auth, ssid, pass);
  dht.begin();
  timer.setInterval(2500L, sendSensor);
}

void loop(){
  Blynk.run();
  timer.run();
}

Thanks
Shameer

@shameermohamed please edit your post and add triple backticks ( ``` ) before and after your sketch like this
triple backticks

Now Notifications, Email, Twitter widgets has been replaced with events so you should remove blynk.email
also read this
https://docs.blynk.io/en/getting-started/events-tutorial

I tried. I added only Blynk.logEvent and tried. Still same problem

Can you post some screenshots how did you configure the event please ?

@shameermohamed I’ve moved your post to a topic of it’s own, as it’s significantly different from the one you choose to post in.

I’ve also sent you a PM regarding contacting me via my photography website.

Pete.

Ok. Thank you

What about the notification tab

Seeing the rest of that screen would be useful.

Pete.

Hey, Thanks everyone. My issue resolved. Before I gave time limit as 1 hour. Now I changed that to 1 minute and getting notifications.

Thank you all for your valuable time.

Regards,
Shameer

Can you see anything in the timeline ?

Yes. I can see the notification in the timeline and also in the IOT Remote app in mobile.

So what’s the problem exactly ?

Before I gave time limit as 1 hour. Now I changed that to 1 minute and getting notifications.

Check this out
https://docs.blynk.io/en/blynk.console/templates/events/custom-events/events-notification-settings#notification-limits
and keep in mind that you’re limited to send 100 event per device per day.