How can i make blynk send me notifications

ive everything OK except that i cant make blynk send me notifications on detecting fire (my project is fire alarm)


#define BLYNK_TEMPLATE_ID           "TMPL9TyjJvJ_"
#define BLYNK_DEVICE_NAME           "Quickstart Device"
#define BLYNK_AUTH_TOKEN            "McK2HZeK31pbVd8Yhg0di-0V26rO-HaS"


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


#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>

char auth[] = BLYNK_AUTH_TOKEN;

// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "m";
char pass[] = "moha3455";

BlynkTimer timer;
int pinValue = 0;

#define LED1 D1
#define LED2 D2
#define Buzzer D3
#define Sensor D0

void setup() {
  Serial.begin(9600);
  pinMode(LED1, OUTPUT);
  pinMode(LED2, OUTPUT);
  pinMode(Buzzer, OUTPUT);
  pinMode(Sensor, INPUT);
  Blynk.begin(auth, ssid, pass);
  timer.setInterval(1000L, notifiaction);
}
BLYNK_WRITE(V0) {
  pinValue = param.asInt();
}

void notifiaction() {
  int sensor = digitalRead(Sensor);
  if (pinValue == 1) {
    Serial.println("System is ON");
    if (sensor == 1) {
      digitalWrite(LED2, HIGH);
      digitalWrite(LED1, LOW);
      digitalWrite(Buzzer, HIGH);
    } else if (sensor == 0) {
      Blynk.notify("WARNING! A fire was detected");
      digitalWrite(LED2, LOW);
      digitalWrite(LED1, HIGH);
      digitalWrite(Buzzer, LOW);
    }
  } else if (pinValue == 0) {
    Serial.println("System is OFF");
  }
}

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

Blynk.notify has been replaced with blynk.logevent, more details here

This is the Legacy way of triggering notifications.

You should read this…

Pete.

The events limit reached. You will no longer get new events today
and notification setting is empty and here is my code tell me if there is a mistake in it

// Template ID, Device Name and Auth Token are provided by the Blynk.Cloud
// See the Device Info tab, or Template settings
#define BLYNK_TEMPLATE_ID           "TMPL9TyjJvJ_"
#define BLYNK_DEVICE_NAME           "Quickstart Device"
#define BLYNK_AUTH_TOKEN            "" // I deleted it 


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


#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>

char auth[] = BLYNK_AUTH_TOKEN;

// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "med";
char pass[] = "moed5555";

BlynkTimer timer;
int pinValue = 0;

#define LED1 D1
#define LED2 D2
#define Buzzer D3
#define Sensor D0

void setup() {
  Serial.begin(9600);
  pinMode(LED1, OUTPUT);
  pinMode(LED2, OUTPUT);
  pinMode(Buzzer, OUTPUT);
  pinMode(Sensor, INPUT);
  Blynk.begin(auth, ssid, pass);
  timer.setInterval(1000L, notifiaction);
}
BLYNK_WRITE(V0) {
  pinValue = param.asInt();
}

void notifiaction() {
  bool alert_sent = false ;
  int sensor = digitalRead(Sensor);
  if (pinValue == 1) {
    Serial.println("System is ON");
    if (sensor == 1 && alert_sent == false) {
      Blynk.logEvent("alert_fire");
      alert_sent = true ;
      digitalWrite(LED2, HIGH);
      digitalWrite(LED1, LOW);
      digitalWrite(Buzzer, HIGH);
    } else if (sensor == 0) {
      alert_sent = false ;
      digitalWrite(LED2, LOW);
      digitalWrite(LED1, HIGH);
      digitalWrite(Buzzer, LOW);
    }
  } else if (pinValue == 0) {
    Serial.println("System is OFF");
  }
}

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

Please edit your post and add triple backticks ( ``` ) before and after your sketch.

1 Like

I’ve moved your latest post to this existing topic, as it’s basically about the same subject.

First off, have you read the link I provided?

If you have, then you will realise that although events are used to trigger notifications, this is a two stage process which requires the event to be told to send a notification when the event is triggered. You haven’t shared any screenshots of your event setup, and the corresponding notifications tab in that event configuration scree, so it’s not possible to know whether you’ve set everything up correctly.

I’d suggest that you read, or re-read, my events tutorial. When you do this, you’ll probably figure-out which step in the process you’ve missed.

If you can’t figure it out then post the event/notification screenshots from your system which match mine from the tutorial, along with screenshots of the event timeline.

Pete.

ice_screenshot_٢٠٢٢٠٤٢٧-١٣٢٥١٠|589x500

Your first screenshot wasn’t posted correctly, so it’s impossible to tell if you have anything in the Notifications tab for that event.

Pete.

thank you sir , it worked
this is extremely wonderful

So you didn’t need to post the screenshots, because it’s working?

Pete.