Pages: [1]   Go Down
Author Topic: RFID ID-12 reader returning 255 only  (Read 1064 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 2
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi There,

I recently bought:

2 x ID-12 reader module
1 X RFID Tag (Card) - 125kHz
1 X RFID Tag (Card) - Dual 125KHz/13.56Mhz MIFARE 4K

I have used a number of examples, most notably from the playground but none seem to work, they all return decimal 255.

Here is an example of one of the few code samples I've used:

#include <NewSoftSerial.h>

NewSoftSerial mySerial(4, 5);

void setup() {
//Start serial output
Serial.begin(38400);
Serial.println("RFID Reader is ready...");

mySerial.begin(9600); //Set the data rate for the NewSoftSerial port
}

void loop() {
byte tagString = 0;

if (mySerial.available()) {
tagString = mySerial.read();
Serial.println(tagString, DEC);
}
}

This produces the output 255 13 times, I was expecting some variance in the values received as the cards are supposed to be pre-programmed with a unique 32-bit id.

The wiring I've used is:

1 = GND
2 = 5V
3
4
5
6
7 = GND
8
9 = Digital Pin 4 (on arduino)
10
11 = 5V

Do you have any ideas what my problem could be, or are you able to direct me to somewhere I can possibly get the answers.

Many Thanks

MARK
Logged

Global Moderator
Offline Offline
Brattain Member
*****
Karma: 452
Posts: 18694
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I got hardware virtually identical to yours and this sketch worked:

Code:
#include <Tone.h>

Tone tone1;

void setup()
{
  // start serial port at 9600 bps:
  Serial.begin(9600);
  tone1.begin(8);

}
 
#define MAX_ID 20

char cur_id [MAX_ID] = "";
int len = 0;

void loop()
{
  char inByte;
 
  if (Serial.available() > 0) {
    // get incoming byte:
    inByte = Serial.read();
   
    switch (inByte)
    {
      case 2:   len = 0;
                break;
     
      case 3:  cur_id [len] = 0;
               Serial.println (cur_id);
               if (strcmp (cur_id, "4400ABCD553F") == 0)
                  {
                  tone1.play(NOTE_C4, 100);
                  delay (100);
                  tone1.play(NOTE_D4, 100);
                  delay (100);
                  tone1.play(NOTE_E4, 100);
                  delay (1000);
                  }     
                  else
                  {
                  tone1.play(NOTE_E4, 100);
                  delay (100);
                  tone1.play(NOTE_D4, 100);
                  delay (100);
                  tone1.play(NOTE_C4, 100);
                  delay (1000);
                  }     
              break;
             
        case 10:
        case 13:
             break;
         
        default:
             if (len >= (MAX_ID - 1))
               break;
             
             cur_id [len++] = inByte;
             break;
             
     
    }  // end of switch
   
  }  // end of incoming data
}  // end of loop

I had a speaker on pin 8, and it played a "good" tune for one of the cards and another one for the others. I just plugged the RFID reader into D0 (Rx) so I could read from the ID-12 but output back to the Arduino. You need to unplug it for programming though.
Logged

Pages: [1]   Go Up
Jump to: