MRFC522 and ESP8266

my mfrcc522 led is bright but it cant scan cards as well i am using it with esp8266 the code is

#include <deprecated.h>
#include <MFRC522.h>
#include <MFRC522Extended.h>
#include <require_cpp11.h>

/* -----------------------------------------------------------------------------

  • Project: RFID attendance system using NodeMCU
  • Date: 6/03/2024

This code was created by Electronics Tech channel for
the RFID attendance project with NodeMCU.
---------------------------------------------------------------------------/
//c:\Users\Himanshu\Downloads\RFID-Attendance-system-V2.0-master\RFID-Attendance-system-V2.0-master\NodeMCU_RFIDv2.0\NodeMCU_RFIDv2.0.ino
******libraries********************************
//RFID-----------------------------
#include <SPI.h>
#include <MFRC522.h>
//NodeMCU--------------------------
#include <ESP8266WiFi.h>
#include <ESP8266HTTPClient.h>

//************************************************************************
#define SS_PIN D2 //D8
#define RST_PIN D1 //D3
//************************************************************************
MFRC522 mfrc522(SS_PIN, RST_PIN); // Create MFRC522 instance.
//************************************************************************
/* Set these to your desired credentials. /
const char ssid = "5";
const char password = "123456789H";
const char
device_token = "a28e4d22c5b74030";
//
**********************************************************************
String URL = "http://192.168.43.187/rfidattendance/getdata.php"; //computer IP or the server domain
String getData, Link;
String OldCardID = "";
unsigned long previousMillis = 0;
//************************************************************************
void setup() {
delay(1000);
Serial.begin(115200);
SPI.begin(); // Init SPI bus
mfrc522.PCD_Init(); // Init MFRC522 card
//---------------------------------------------
connectToWiFi();
}
//************************************************************************
void loop() {
//check if there's a connection to Wi-Fi or not
if(!WiFi.isConnected()){
connectToWiFi(); //Retry to connect to Wi-Fi
}
//---------------------------------------------
if (millis() - previousMillis >= 15000) {
previousMillis = millis();
OldCardID="";
}
delay(50);
//---------------------------------------------
//look for new card
if ( ! mfrc522.PICC_IsNewCardPresent()) {
return;//got to start of loop if there is no card present
}
// Select one of the cards
if ( ! mfrc522.PICC_ReadCardSerial()) {
return;//if read card serial(0) returns 1, the uid struct contians the ID of the read card.
}
String CardID ="";
for (byte i = 0; i < mfrc522.uid.size; i++) {
CardID += mfrc522.uid.uidByte[i];
}
//---------------------------------------------
if( CardID == OldCardID ){
return;
}
else{
OldCardID = CardID;
}
//---------------------------------------------
// Serial.println(CardID);
SendCardID(CardID);
delay(1000);
}
//send the Card UID to the website*
void SendCardID( String Card_uid ){
Serial.println("Sending the Card ID");
if(WiFi.isConnected()){
HTTPClient http; //Declare object of class HTTPClient
//GET Data
getData = "?card_uid=" + String(Card_uid) + "&device_token=" + String(device_token); // Add the Card ID to the GET array in order to send it
//GET methode
Link = URL + getData ;
http.begin(Link); //initiate HTTP request //Specify content-type header

int httpCode = http.GET();   //Send the request
String payload = http.getString();    //Get the response payload

// Serial.println(Link); //Print HTTP return code
Serial.println(httpCode); //Print HTTP return code
Serial.println(Card_uid); //Print Card ID
Serial.println(payload); //Print request response payload

if (httpCode == 200) {
  if (payload.substring(0, 5) == "login") {
    String user_name = payload.substring(5);
//  Serial.println(user_name);

  }
  else if (payload.substring(0, 6) == "logout") {
    String user_name = payload.substring(6);
//  Serial.println(user_name);
    
  }
  else if (payload == "succesful") {

  }
  else if (payload == "available") {

  }
  delay(100);
  http.end();  //Close connection
}

}
}
//**connect to the WiFi
void connectToWiFi(){
WiFi.mode(WIFI_OFF); //Prevents reconnection issue (taking too long to connect)
delay(1000);
WiFi.mode(WIFI_STA);
Serial.print("Connecting to ");
Serial.println(ssid);
WiFi.begin(ssid, password);

while (WiFi.status() != WL_CONNECTED) {
  delay(500);
  Serial.print(".");
}
Serial.println("");
Serial.println("Connected");

Serial.print("IP address: ");
Serial.println(WiFi.localIP());  //IP address assigned to your ESP

delay(1000);

}
//=======================================================================
the output is only : 15:19:01.811 -> ⸮⸮⸮⸮
please help me it is my major project

@weaponxthor

Welcome to the forum

Your post hijacking an old topic has been moved to its own topic in the Programming category of the forum

Please follow the advice given in the link below when posting code, in particular the section entitled 'Posting code and common code problems'

Use code tags (the < CODE/ > icon above the compose window) to make it easier to read and copy for examination

https://forum.arduino.cc/t/how-to-get-the-best-out-of-this-forum

In my experience the easiest way to tidy up the code and add the code tags is as follows

Start by tidying up your code by using Tools/Auto Format in the IDE to make it easier to read. Then use Edit/Copy for Forum and paste what was copied in a new reply. Code tags will have been added to the code to make it easy to read in the forum thus making it easier to provide help.

check the serial monitor baudrate is set to the same as your code, e.g.

Serial.begin(115200);

can you give a link to the MRFC522 module you are using
give details of the wiring between ESP8255 and MFRC522 and you power the device?

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.