3

I just extracted the problematic part of my program, I use RFID.h and SPI.h, I just want to know how to read on a RFID card (written with an android phone) I only write one letter : R, G, B, Y, ... (represent color) , on an Android tool I can See at sector 04 : ?TenR? When the "R" after Ten is the string that I wanna read :

    char buffer_data[8];
    rfid.read(0x04,buffer_data);
  
    String myString = String(buffer_data);
    Serial.println(myString);

I only want to know how to output => "R" (text on the RFID card at sector 04) : It output something like that :

22:05:15.885 -> 
22:05:15.885 -> &⸮
22:05:15.885 -> ⸮⸮

With other cards (Y, B char inside) same output...

Screenshot with card data (Mifare classic 1k (716B writable)):

screenshopt of card data + string that I want to read

neoteknic
  • 1,930
  • 16
  • 32

2 Answers2

2

The lib RFID.h with rfid.read doest not work... https://github.com/song940/RFID-RC522 don't use this lib !

The lib https://github.com/miguelbalboa/rfid is better, up to date, and can read most of tag types !

This is the fixed code to read the first text char on NTAG215 :

if (rfid.PICC_IsNewCardPresent()) {
 if ( ! rfid.PICC_ReadCardSerial()) {
   return;
 }
  Serial.println("");
  String str;
  byte buffer_data[18];
  byte size_data = sizeof(buffer_data);
  rfid.MIFARE_Read(4,buffer_data,&size_data);
  str=String((char *)buffer_data);
  Serial.println(str.charAt(9));
}

Ouput the first letter on the tag (if you write text data with Android NFC tools app ) only on NTAG215 (other tag = different adresses/position)!

neoteknic
  • 1,930
  • 16
  • 32
0

I assume that the "square" refers to the ASCII number printed to stdout. I would want to find out, what read_char is in HEX, so instead of printing it as a character to stdout, print the hex representation of it and see what value you get. It's difficult to give you more accurate troubleshooting steps with the limited system information available.

BitFreak
  • 406
  • 3
  • 10
  • I just want how to use the read function, no doc :s I dont know how to read text from rfid. – neoteknic Jul 25 '20 at 23:41
  • 1
    Does not `char read_char=rfid.read(01,buffer1);` do the reading from your rfid? Where `buffer1` contains your rfid data? – BitFreak Jul 26 '20 at 16:19
  • yes it read something, when I go in the lib code, data are written to buffer, but I doint know how to read it – neoteknic Jul 27 '20 at 20:07