Hello there,
I am trying to read block 6 on the RFID tag which has data stored as uint16_t in it.
The problem is that I am constantly seeing weird symbols such as "⸮TT⸮".
Anyone knows how to read data of that block as a String.
Thanks in advance.
Hello there,
I am trying to read block 6 on the RFID tag which has data stored as uint16_t in it.
The problem is that I am constantly seeing weird symbols such as "⸮TT⸮".
Anyone knows how to read data of that block as a String.
Thanks in advance.
Two things: this is not an installation and troubleshooting issue, and we can't see your code
Sorry for that, I changed it.
I am new at this so have that in mind when your eyes start hurting... ![]()
#include <SPI.h>
#include <MFRC522.h>
#define RST_PIN 7
#define SS_PIN 10
MFRC522 mfrc522(SS_PIN, RST_PIN);
MFRC522::MIFARE_Key key;
MFRC522::StatusCode status;
void setup() {
Serial.begin(9600);
SPI.begin();
mfrc522.PCD_Init();
Serial.println(F("Read personal data on a MIFARE PICC:"));
}
void loop() {
for (byte i = 0; i < 6; i++) key.keyByte[i] = 0xFF;
byte block;
byte len;
//-------------------------------------------
if ( ! mfrc522.PICC_IsNewCardPresent()) {
return;
}
// Select one of the cards
if ( ! mfrc522.PICC_ReadCardSerial()) {
return;
}
Serial.println(F("**Card Detected:**"));
byte buffer1[18];
block = 6;
len = 18;
status = mfrc522.PCD_Authenticate(MFRC522::PICC_CMD_MF_AUTH_KEY_A, 4, &key, &(mfrc522.uid));
if (status != MFRC522::STATUS_OK) {
Serial.print(F("Authentication failed: "));
Serial.println(mfrc522.GetStatusCodeName(status));
return;
}
status = mfrc522.MIFARE_Read(block, buffer1, &len);
if (status != MFRC522::STATUS_OK) {
Serial.print(F("Reading failed: "));
Serial.println(mfrc522.GetStatusCodeName(status));
return;
}
String value;
for (byte i = 0; i < 16; i++)
{
Serial.println(buffer1[i]);
value +=(char) buffer1[i];
}
Serial.println("hit me with a brick please");
Serial.println("try 3 GOD PLEASE");
for(int i=0;i<16;i++){
Serial.print(value[i]);
}
Serial.println(F("\n**End Reading**\n"));
delay(1000);
mfrc522.PICC_HaltA();
mfrc522.PCD_StopCrypto1();
}
byte buffer1[18];
block = 6;
len = 18;
...
status = mfrc522.MIFARE_Read(block, buffer1, &len);
...
for (byte i = 0; i < 16; i++)
}
likely there are other problems, but your code is making some assumptions. would be better to use the # of bytes read from the read function. also report the value returned in "len"
#define BUF_SIZE 18
len = BUF_SIZE;
byte buffer1[BUF_SIZE];
block = 6;
...
status = mfrc522.MIFARE_Read(block, buffer1, &len);
...
for (byte i = 0; i < len; i++)
}
So the problem remains
Output of this:
Serial.print(buffer1[i]);
Is : 2364841184112323000060919362144138
And the output of this
value +=(char) buffer1[i];
Serial.print(value[i]);
Is: ⸮TT⸮
As I know uint16_t is not readable so I need to convert it to String to read it. I tried tons of things and it isn't working...
The real output should be something like this: 1260290024340980<[]>
"buffer1 [i]" is a single char
don't you want
Serial.print(buffer1);
if it is a NUL terminated c-ctring?
Why not simply print the hex value?
I tried that also, but it isn't working, maybe I am wrong, can you describe how to do it?
Serial.print(value[i] , HEX);
Something like that?
As I said, I want to read block 6 of the RFID tag memory, and Block 6 contains 16 bytes:
I just want to read the first 4 things. If anyone can help I would be very grateful.
Thanks in advance and sorry if my question is absolutely stupid.