#define BLYNK_TEMPLATE_ID "TMPL4M-HSejf-"
#define BLYNK_TEMPLATE_NAME "Fire Detection"
#define BLYNK_AUTH_TOKEN "VZJIAD2Ud6Kvw6wCOknkNGT22Ot5f_hp"
#define BLYNK_PRINT Serial
#include <WiFi.h>
#include <WiFiClient.h>
#include <BlynkSimpleEsp32.h>
char auth[] = BLYNK_AUTH_TOKEN;
char ssid[] = "Odiny";
char pass[] = "lewandowski1";
BlynkTimer timer;
#define fire 23
#define GREEN 13
#define RED 14
#define buzzer 12
int fire_Val = 0;
WidgetLED led(V1);
void setup()
{
Serial.begin(9600);
pinMode(GREEN, OUTPUT);
pinMode(fire, INPUT);
pinMode(RED, OUTPUT);
pinMode(buzzer, OUTPUT);
Blynk.begin(auth, ssid, pass);
delay(2000);
timer.setInterval(500L, mySensor);
}
void loop()
{
Blynk.run();
timer.run();
}
void mySensor()
{
fire_Val = digitalRead(fire);
if (fire_Val == LOW)
{
Blynk.logEvent("fire_alert");
digitalWrite(GREEN, LOW);
digitalWrite(RED, HIGH);
digitalWrite(buzzer, HIGH);
Blynk.virtualWrite(V0, 1);
Serial.print("fIRE Level: ");
Serial.println(fire_Val);
led.on();
}
else
{
digitalWrite(GREEN, HIGH);
digitalWrite(RED, LOW);
digitalWrite(buzzer, LOW);
Blynk.virtualWrite(V0, 0);
Serial.print("fIRE Level: ");
Serial.println(fire_Val);
led.off();
}
}```
I guess it’s an issue with notification permissions on your phone, but you have other issues with your sketch, as you’ll quickly use-up yout 100 events per 24 hour period with yout code.
You’re calling mySensor()
twice oper sendond, so after 50 seconds where fire_Val == LOW
you’ll have logged your 100 event limit.
You should read this…
Pete.