Blynk 2.0 - How to send Push notification to my phone?

I,m going to convert my Blynk 1.0 projects to Blynk 2.0 and i understand that “Blynk.notify()” is switched with “Blynk.logEvent()”

i have also enabled notification in template etc.

But when the temperature goes over 50 degrees celcius, i do not get any Push notifications to my phone.

Can someone help me with that?

Her is som screenshots and my code:

#define BLYNK_TEMPLATE_ID "REMOVED"
#define BLYNK_DEVICE_NAME "REMOVED"

#define BLYNK_PRINT Serial

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

#define ONE_WIRE_BUS 2
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);

BlynkTimer timer;

int dark=1000; //Specified in Hz
int light=1300; //Specified in Hz
int buzzPin=15;
int timeOn=1000; //specified in milliseconds
int timeOff=1000; //specified in millisecods

char auth[] = "ZHLgNlnDPgWr-kLpVd4OkG5-ZgkJPsN-";

char ssid[] = "JabediJabedi";
char pass[] = "Birkeb1er";

int ledred = 14;
int ledgreen = 12;
int ledblue = 13; 

void buzzer(){
 tone(buzzPin, dark);
 delay(timeOn);
 noTone(buzzPin);
 delay(timeOff);
}

void sensorData(){
  sensors.requestTemperatures();
  Serial.print("Temperatur: ");
  Serial.println(sensors.getTempCByIndex(0));
  Blynk.virtualWrite(V5, sensors.getTempCByIndex(0));
  ledgrid();
}

void ledgrid(){
  if (sensors.getTempCByIndex(0) <20){
  digitalWrite(ledblue, HIGH);
  digitalWrite(ledgreen, LOW);
  digitalWrite(ledred, LOW);
  noTone(buzzPin);
  }
if (sensors.getTempCByIndex(0) >=20 && sensors.getTempCByIndex(0) <=50){
  digitalWrite(ledblue, LOW);
  digitalWrite(ledgreen, HIGH);
  digitalWrite(ledred, LOW);
  noTone(buzzPin);
}
if (sensors.getTempCByIndex(0) >50){
  digitalWrite(ledblue, LOW);
  digitalWrite(ledgreen, LOW);
  digitalWrite(ledred, HIGH);
  buzzer();
  Blynk.logEvent("WARNNG! Over 50 grader i boksen!");
  }
}

void setup()
{
  timer.setInterval(2000L, sensorData);
  Serial.begin(9600);
  Blynk.begin(auth, ssid, pass);
  pinMode(ledred, OUTPUT);
  pinMode(ledgreen, OUTPUT);
  pinMode(ledblue, OUTPUT);
  pinMode(buzzPin, OUTPUT);
}

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

1 Like

I think you’re supposed to put the event code in this command.
In your case the event code is “high_temperature_warning”

Pete.

4 Likes

Ahaa!

That did the trick. Thanks :slight_smile:

Thanks I had the same problem I solved thanks to you

6 posts were split to a new topic: Need help with Notifications