Go Down

Topic: RFID ID-12 reader returning 255 only (Read 1 time) previous topic - next topic

Mark Small

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.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
7 = GND
9 = Digital Pin 4 (on arduino)
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


Nick Gammon

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

Code: [Select]
#include <Tone.h>

Tone tone1;

void setup()
  // start serial port at 9600 bps:

#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;
      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);
                  tone1.play(NOTE_E4, 100);
                  delay (100);
                  tone1.play(NOTE_D4, 100);
                  delay (100);
                  tone1.play(NOTE_C4, 100);
                  delay (1000);
        case 10:
        case 13:
             if (len >= (MAX_ID - 1))
             cur_id [len++] = inByte;
    }  // 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.
Please post technical questions on the forum, not by personal message. Thanks!

More info:

Go Up

Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

via Egeo 16
Torino, 10131