/*My project is a Library management system using rfid cards. Im trying to generate a code wherein User first scan a book and then the record will be pushed in Issued_Books table in Firebase . Then the user scans his id to ensure that the book will be issued on his/her id. But in my program is scanning only books id. It fails to scan users Id after that. Im a beginner so can anyone guide me? */
//My loop code is as following:
void loop() {
if ( !mfrc522.PICC_IsNewCardPresent() ) {
delay(50);
return;
}
if ( !mfrc522.PICC_ReadCardSerial() ) {
delay(50);
return;
}
String book;
for ( byte i = 0; i< mfrc522.uid.size; i++ ) {
Serial.print(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " ");
Serial.print(mfrc522.uid.uidByte[i], HEX);
book.concat(String(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " "));
book.concat(String(mfrc522.uid.uidByte[i], HEX));}
book.toUpperCase();
Firebase.pushString("Issued_Books/Book_rfid",book);
Serial.println();
if ( !mfrc522.PICC_IsNewCardPresent() ) {
delay(50);
return;
}
if ( !mfrc522.PICC_ReadCardSerial() ) {
delay(50);
return;
}
String user;
//Serial.print("Scan your id: ");
for ( byte i = 0; i< mfrc522.uid.size; i++ ) {
Serial.print(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " ");
Serial.print(mfrc522.uid.uidByte[i], HEX);
user.concat(String(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " "));
user.concat(String(mfrc522.uid.uidByte[i], HEX));}
user.toUpperCase();
//Serial.print(F("Card UID: "));
Firebase.setString("Issued_Books/Book_rfid/user_rfid",user);
delay(3000);
}