My RFID Tag Can't Get Scanned

My RFID Tag can’t get scanned when i use a Blynk Template code,

I use the template from this Youtube video :
https://youtu.be/LqRDissHtys

I have tried to scan the RFID Tag with a simple code just to see the ID, and it works.

But why can’t i scan the RFID Tag when i use the Blynk Template code ? Is there something wrong with the code ?

If there’s something wrong, how to fix it ? Please explain it step by step, I don’t really understand how to code, thank you for anyone who helps :pray:t2:

• ESP8266 + WiFi
• Blynk server
• Blynk Library 1.2.0

This is the sketch code

#include <SPI.h>
#define BLYNK_TEMPLATE_ID "TMPL6BZv75tjv"
#define BLYNK_TEMPLATE_NAME "DoorLockFix2"
#define BLYNK_AUTH_TOKEN "ORpZeeVcfoZMfbDiETGwXketRj7Mno87"
#include <MFRC522.h>
#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
 
#define SS_PIN 4  // sda
#define RST_PIN 2
 
int lock = D1;    
 
MFRC522 mfrc522(RST_PIN, SS_PIN);        // Create MFRC522 instance.
char auth[] = BLYNK_AUTH_TOKEN;    //Blynk Authentication Token -- sent via Email from Blynk
 
char ssid[] = "bb 6 no 1";   //Enter WiFi Name
char pass[] = "oliverap";   //Enter Wifi Password
 
SimpleTimer timer;
int fflag = 0; 
int eflag = 0; 
int jflag = 0; 
WidgetTerminal terminal(V2);
 
void setup() {
        Serial.begin(9600);        // Initialize serial communications with the PC
        Blynk.begin(auth, ssid, pass);
      pinMode(lock,OUTPUT);
      digitalWrite(lock, LOW);
        SPI.begin();                // Init SPI bus
        mfrc522.PCD_Init();        // Init MFRC522 card
        //Serial.println("Scan a MIFARE Classic PICC to demonstrate Value Blocks.");
          timer.setInterval(1000L, iot_rfid);
}
 
void loop() {
        
  timer.run(); // Initiates SimpleTimer
  Blynk.run();
 
       
}
 
void iot_rfid()
{
 
        // Prepare key - all keys are set to FFFFFFFFFFFFh at chip delivery from the factory.
        MFRC522::MIFARE_Key key;
        for (byte i = 0; i < 6; i++) {
                key.keyByte[i] = 0xFF;
        }
        // Look for new cards
        if ( ! mfrc522.PICC_IsNewCardPresent()) {
                return;
        }
 
        // Select one of the cards
        if ( ! mfrc522.PICC_ReadCardSerial()) {
                return;
        }
        // Now a card is selected. The UID and SAK is in mfrc522.uid.
        
        // Dump UID
        Serial.print("Card UID:");
        for (byte i = 0; i < mfrc522.uid.size; i++) {
               Serial.print(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " ");
               Serial.print(mfrc522.uid.uidByte[i], DEC);
        } 
        Serial.println();
 
        // Dump PICC type
        byte piccType = mfrc522.PICC_GetType(mfrc522.uid.sak);
    //    Serial.print("PICC type: ");
//Serial.println(mfrc522.PICC_GetTypeName(piccType));
        if (        piccType != MFRC522::PICC_TYPE_MIFARE_MINI 
                &&        piccType != MFRC522::PICC_TYPE_MIFARE_1K
                &&        piccType != MFRC522::PICC_TYPE_MIFARE_4K) {
                //Serial.println("This sample only works with MIFARE Classic cards.");
                return;
        }
        
        // Enter RFID Tag ID here 
        if( ((mfrc522.uid.uidByte[0] == 11) && (mfrc522.uid.uidByte[1] == 22) && (mfrc522.uid.uidByte[2] == 33) && (mfrc522.uid.uidByte[3] == 44)) && (fflag == 1) )
        {
         Serial.println("User01");   //Enter User1 Name
         Blynk.virtualWrite(V2, "User01" );   //Enter User1 Name
         digitalWrite(lock, HIGH); 
         delay(3000); 
         digitalWrite(lock, LOW); 
        }
  
        else
        if(( (mfrc522.uid.uidByte[0] == 11) && (mfrc522.uid.uidByte[1] == 12) && (mfrc522.uid.uidByte[2] == 13) && (mfrc522.uid.uidByte[3] == 14))&& (eflag == 1) )
        {
         Serial.println("User02");   //Enter User2 Name 
         Blynk.virtualWrite(V2, "User02" );   //Enter User2 Name
         digitalWrite(lock, HIGH); 
         delay(3000); 
         digitalWrite(lock, LOW); 
        }
        else
        if( ((mfrc522.uid.uidByte[0] == 21) && (mfrc522.uid.uidByte[1] == 22) && (mfrc522.uid.uidByte[2] == 23) && (mfrc522.uid.uidByte[3] == 24))&& (jflag == 1) )
        {
         Serial.println("User03");   //Enter User3 Name
         Blynk.virtualWrite(V2, "User03" );   //Enter User3 Name
         digitalWrite(lock, HIGH); 
         delay(3000); 
         digitalWrite(lock, LOW); 
        }
 
        else 
        Serial.println("Unregistered User");
  
}
 
// in Blynk app writes values to the Virtual Pin 3
BLYNK_WRITE(V3)
{
   fflag = param.asInt(); // assigning incoming value from pin V3 to a variable
  // Blynk.virtualWrite(V2, fflag );
 
}
 
 
// in Blynk app writes values to the Virtual Pin 4
BLYNK_WRITE(V4)
{
   eflag = param.asInt(); // assigning incoming value from pin V4 to a variable
 
}
 
BLYNK_WRITE(V5)
{
   jflag = param.asInt(); // assigning incoming value from pin V5 to a variable
 
}

I think you’ll have to explain quite a lot more about how you’ve configured your Blynk datastreams and widgets, and what sort of information you’re seeing in your serial monitor when you scan your various RFID tags.

Pete.

This is the serial monitor from the Blynk Code, it supposedly shows the RFID Tag ID when i tap on it, but it shows nothing.


This is the serial monitor from the code without using Blynk, it shows the RFID Tag ID when i tap on it.

These are the Datastreams that i use on the device.

And these are the Widget Settings on my device

I’d start by updating your Blynk library to 1.2.0

What version of the ESP8266 core do you have installed in the Boards Manager menu of the IDE?

The “Connected to WiFi” message AFTER the “Readt (ping)” message is very odd.

When you’re posting serial monitor output it’s better to copy the text and paste it with triple backticks, as you do when you’re posting code.

If you take a look at your last screenshot you’ll see that it’s virtually illegible, because of the way that you’ve combined multiple images into one.

Pete.

Have the same problem. I was able to solve it by placing the ff in order on the very top of the sketch : TAKE NOTE OF THE TEMPLATE ID, TEMPLATE NAME AND TOKEN IN THE FOLLOWING ORDER

[Unformatted code removed by moderator]

@Valbay 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.