I understand, I use an Arduino nano coupled to an RFID rc522 reader.
After several attempts to write the first sketch (the one that is supposed to write 3 values) nothing has transferred to the card.
an example is attached
#include <SPI.h>
#include <MFRC522.h>
const int SS_PIN = 10;
const int RST_PIN = 9;
MFRC522 mfrc522(SS_PIN, RST_PIN);
void setup() {
Serial.begin(9600);
SPI.begin();
mfrc522.PCD_Init();
Serial.println("Place your RFID tag on the reader to write data to it.");
}
void loop() {
// Look for a new card
if ( ! mfrc522.PICC_IsNewCardPresent()) {
return;
}
// Select the card
if ( ! mfrc522.PICC_ReadCardSerial()) {
return;
}
// Dump the card data
Serial.println("Writing data to RFID tag...");
Serial.print("UID: ");
for (byte i = 0; i < mfrc522.uid.size; i++) {
Serial.print(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " ");
Serial.print(mfrc522.uid.uidByte[i], HEX);
}
Serial.println();
// Write some data to the tag
byte data[] = "Hello, world!";
mfrc522.MIFARE_Write(4, data, 16);
mfrc522.MIFARE_Write(20, (byte)12345, 4);
mfrc522.MIFARE_Write(30, (float)3.14159265, 4);
Serial.println("Done!");
}
I found a code to write on a card using NDEF-MFRC522 library, and it works well
/**
* Example Arduino code that writes a URL to the tag in NDEF format
* allowing a phone to read the tag and open to a browser.
* Success if your phone opens to this Github repo.
*/
#include "MifareUltralight.h"
#include <MFRC522.h>
#include <SPI.h>
#define SS_PIN 10
#define RST_PIN 6
using namespace ndef_mfrc522;
MFRC522 mfrc522(SS_PIN, RST_PIN); // Create MFRC522 instance
void setup() {
Serial.begin(115200); // Initialize serial communications with the PC
SPI.begin(); // Init SPI bus
mfrc522.PCD_Init(); // Init MFRC522 card
Serial.println(F("Hold a tag to the MFRC522 and look for success."));
}
void loop() {
// Look for new cards
if (!mfrc522.PICC_IsNewCardPresent())
return;
// Select one of the cards
if (!mfrc522.PICC_ReadCardSerial())
return;
NdefMessage message = NdefMessage();
String url = String("https://github.com/aroller/NDEF-MFRC522");
message.addUriRecord(url);
MifareUltralight writer = MifareUltralight(mfrc522);
bool success = writer.write(message);
if (success)
Serial.println(F("Success. Now read the tag with your phone."));
else
Serial.println(F("Failure. See output above?"));
delay(5000); // avoids duplicate scans
}
but the part to read the code has a problem it looks like it needs something missing in the " tag.print(); "
#include "MifareUltralight.h"
#include <MFRC522.h>
#include <SPI.h>
#define SS_PIN 10
#define RST_PIN 6
using namespace ndef_mfrc522;
MFRC522 mfrc522(SS_PIN, RST_PIN); // Create MFRC522 instance
void setup() {
Serial.begin(115200); // Initialize serial communications with the PC
SPI.begin(); // Init SPI bus
mfrc522.PCD_Init(); // Init MFRC522 card
Serial.println(
F("Hold a tag with NDEF record to the MFRC522. Read the output."));
}
void loop() {
// Look for new cards
if (!mfrc522.PICC_IsNewCardPresent())
return;
// Select one of the cards
if (!mfrc522.PICC_ReadCardSerial())
return;
MifareUltralight reader = MifareUltralight(mfrc522);
NfcTag tag = reader.read();
//Uncomment Ndef.h#NDEF_USE_SERIAL
tag.print();
delay(5000); // avoids duplicate scans
}