Hello all
I have a problem in notification in Blynk.
I use Blynk 2.0 and I set notifications for first time and it work! It’s send notifications for my phone, but when I turn off the device and turn on again the notifications didn’t work! And my phone doesn’t receive any notifications, knowing that I didn’t change any things in code or events (notification settings)
This is my code:
#define BLYNK_TEMPLATE_ID ""
#define BLYNK_DEVICE_NAME "IAQM2"
#define BLYNK_PRINT Serial
#include <WiFi.h>
#include <WiFiClient.h>
#include <BlynkSimpleEsp32.h>
#include <DHT.h>
#include "Adafruit_CCS811.h"
char ssid[] = "";
char pass[] = "";
#define DHTTYPE DHT11
#define DHTPIN 16
Adafruit_CCS811 ccs;
float mq135 = 36;
float mq7 = 39;
DHT dht(DHTPIN, DHTTYPE);
BlynkTimer timer;
void sendSensor()
{
//DHT11
float h = dht.readHumidity();
float t = dht.readTemperature();
Blynk.virtualWrite(V1, t);
Blynk.virtualWrite(V2, h);
if(t == 50){
Blynk.logEvent("temperature");
}
if(h > 60){
Blynk.logEvent("humidity");
}
//MQ-135
float co2 = analogRead(mq135);
Blynk.virtualWrite(V3, co2);
if(co2 > 2534){
Blynk.logEvent("co2");
}
//MQ-7
float co = analogRead(mq7);
Blynk.virtualWrite(V4, co);
if(co > 1950){
Blynk.logEvent("co");
}
//CCS811
ccs.readData();
int TVOC = ccs.getTVOC();
Blynk.virtualWrite(V5, TVOC);
if(TVOC > 860){
Blynk.logEvent("voc");
}
}
void setup()
{
Serial.begin(9600);
dht.begin();
if (!ccs.begin()) {
Serial.println("Failed to start CCS 811 sensor! Please check your wiring.");
while (1);
}
// Wait for the sensor to be ready.
while (!ccs.available());
Blynk.begin("", ssid, pass);
timer.setInterval(1000L, sendSensor);
}
void loop()
{
Blynk.run();
timer.run();
}