Notifications to blynk

• Hardware model + communication type. For example: ESP8266 01 WIFI
• Smartphone OS :IOS
• Blynk server region : Malaysia
• Blynk Library version : 1.1.0

hi, im having a problem, so my coding is fine but it wont send any notification to blynk, means after the card detected or not detected , blynk didnt receive any notifications, that’s the problem im occuring rn

here’s my coding :


#define BLYNK_TEMPLATE_ID ""
#define BLYNK_TEMPLATE_NAME ""
#define BLYNK_AUTH_TOKEN ""

#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <SPI.h>
#include <MFRC522.h>
#include <DurianBlynkESP8266.h>
#include <SoftwareSerial.h>

#define ESP8266_BAUD 9600
#define EspSerial Serial1
#define SS_PIN 10
#define RST_PIN 9
#define trigPin 6
#define echoPin 7
#define buzzerPin 4
#define relayPin 8

#ifdef BLYNK_TEMPLATE_ID && BLYNK_TEMPLATE_NAME
char templateID[] = ""; 
char templateName[] = ""; 
#endif

char auth[] = BLYNK_AUTH_TOKEN;
char ssid[] = "";
char pass[] = "";

MFRC522 rfid(SS_PIN, RST_PIN);
LiquidCrystal_I2C lcd(0x27, 16, 2);
SoftwareSerial EspSerial(2, 3); // RX, TX
DBlynk DBlynk(&EspSerial);

void setup() 
{

  Serial.begin(9600);
  EspSerial.begin(ESP8266_BAUD);
  delay(10);
  SPI.begin();
  rfid.PCD_Init();

  pinMode(trigPin, OUTPUT);
  pinMode(echoPin, INPUT);
  pinMode(buzzerPin, OUTPUT);
  pinMode(relayPin, OUTPUT);

  lcd.init();
  lcd.backlight();
  lcd.setCursor(0, 0);
  lcd.print("WELCOME");
  DBlynk.begin(templateID, templateName, auth, ssid, pass);

}

void loop() 
{
  DBlynk.run();
  lcd.clear();
  lcd.setCursor(0, 0);
  lcd.print("WELCOME");

  long duration, distance;
  digitalWrite(trigPin, LOW);
  delayMicroseconds(2);
  digitalWrite(trigPin, HIGH);
  delayMicroseconds(10);
  digitalWrite(trigPin, LOW);
  duration = pulseIn(echoPin, HIGH);
  distance = (duration / 2) / 29.1;

  if (distance < 10 && distance > 0) {
    lcd.clear();
    lcd.setCursor(0, 0);
    lcd.print("Scan Your Card");

    unsigned long startTime = millis();
    while (millis() - startTime < 10000) {
      if (rfid.PICC_IsNewCardPresent() && rfid.PICC_ReadCardSerial()) {
        if (verifyCard()) {
          lcd.clear();
          lcd.setCursor(0, 0);
          lcd.print("Verified Card");
          buzz(50, 4);
          DBlynk.notify("A VERIFIED CARD HAS BEEN SCANNED");
          
        } else {
          lcd.clear();
          lcd.setCursor(0, 0);
          lcd.print("Not Real");
          digitalWrite(relayPin, HIGH);
          delay(1000);
          digitalWrite(relayPin, LOW); // Matikan relay
          DBlynk.notify("A FAKE OKU CARD HAS BEEN DETECTED");
        }
        delay(2000);
        break;
      }
    }

    if (millis() - startTime >= 10000) {
      lcd.clear();
      lcd.setCursor(0, 0);
      lcd.print("Try Again :)");
      DBlynk.notify("A CAR JUST PARKED WITHOUT A CARD");
      digitalWrite(relayPin, HIGH);
      delay(1000);
      digitalWrite(relayPin, LOW);
      delay(2000);
    }
  }
}

bool verifyCard() {
  byte realCardID[] = {0xD9, 0x15, 0x6B, 0xB3};

  if (rfid.uid.size != 0) {
    if (memcmp(rfid.uid.uidByte, realCardID, rfid.uid.size) == 0) {
      return true; 
    }
  }
  return false; 
}

void buzz(int duration, int repeat) {
  for (int i = 0; i < repeat; i++) {
    digitalWrite(buzzerPin, HIGH);
    delay(duration);
    digitalWrite(buzzerPin, LOW);
    delay(duration);
  }
}

@ajim Please edit your post, using the pencil icon at the bottom, and add triple backticks at the beginning and end of your code so that it displays correctly.
Triple backticks look like this:
```

Copy and paste these if you can’t find the correct symbol on your keyboard.

Pete.

done

You seem to be using a non-Blynk library.
Why is this?

You’re not likely to get support or answers to your questions from this forum unless you use the official Blynk libraries.

Pete.

okayy my bad :frowning:

If you have a Blynk IoT account and the Blynk IoT app then download the latest Blynk IoT libraries and uni stall the ones you are currently using.

This tutorial explains how to use use Notifications in Blynk IoT…

Pete.