Arduino RFID (Wiegand) Continuous reading

6.4k views Asked by At

I have this RFID reader "Rosslare AY-X12", and it's working with Wiegand 26bit. I have an arduino mini Pro and connected together it's working fine but it only reads the card one time and then I have nothing.

When I put on the card arduino reads that card but only one time during the card is near by the reader and it again reads that card when I put off the card and then I put on. But I want to read that card continuously, I mean when the card is near by the Reader still reading the card, every 1ms reads that card.

Do you have any idea how to do that ? Is there any RFID arduino library which can do that? I had got the Mifare and its can do that. But this 125Khz reader which can communicate over Wiegand can't do that or I don't know how to do that.

I'm using this library : https://github.com/monkeyboard/Wiegand-Protocol-Library-for-Arduino

4

There are 4 answers

0
JP Liew On BEST ANSWER

My previous answer was deleted. I am going to make another attempt to answer the questions.

Do you have any idea how to do that ?

This cannot be done by Arduino because Arduino in your case is just reading the D0 and D1 pulses from your RFID reader. Since your RFID reader Rosslare AY-X12 does not send out continuous output of wiegand protocol, there is no way Arduino can read more than what was not sent to it.

The common RFID readers will not send continuous data of the same card because in the common use case (entry/exit/attendance), normally one tap is to check-in and another tap is to check-out. If the RFID reader sends continuous data of the same card, the main system receiving the multiple wiegand data will be confused and will not be able to determine if the user actually wish to check-in or check-out.

Is there any RFID arduino library which can do that?

No. There is no such RFID Arduino library. If the RFID reader is not sending out continuous data, there is no way the receiver (Arduino) can receive them.

Is there a way to achieve this?

Yes, there are some readers that has the option to turn on the continuous output of data, for example 714-52 MifareĀ® ID Reader with selectable outputs. In its specification :

Continuous output with tag in field or single transmission

With this reader configured to continuous output, you can then use Arduino and the monkeyboard wiegand library to read the data.

0
Gregor On

try a this timer libary Timer1 and mayby try this code it worked for me, my tags and cards now reads continuously. Greetings from Denmark Gregor

#include <Timer1.h>

//******************************************************************
// ATmega168, ATmega328:
// - Using Timer 1 disables PWM (analogWrite) on pins 9 and 10
// ATmega2560:
// - Using Timer 1 disables PWM (analogWrite) on pins 11 and 12
// - Using Timer 3 disables PWM (analogWrite) on pins 2, 3 and 5
// - Using Timer 4 disables PWM (analogWrite) on pins 6, 7 and 8
// - Using Timer 5 disables PWM (analogWrite) on pins 44, 45 and 46
//******************************************************************

unsigned int lastTime;

#include <SoftwareSerial.h>
 
SoftwareSerial RFID = SoftwareSerial(2,4);
 
char character;
String our_id;



void setup()
{
  // Disable Arduino's default millisecond counter (from now on, millis(), micros(),
  // delay() and delayMicroseconds() will not work)
  disableMillis();
  // Prepare Timer1 to count
  // On 16 MHz Arduino boards, this function has a resolution of 4us
  // On 8 MHz Arduino boards, this function has a resolution of 8us
  startCountingTimer1();
  lastTime = readTimer1();
   Serial.begin(9600);
  RFID.begin(9600);
}

void loop()
{
   unsigned int now = readTimer1();
      
   
  while (RFID.available()>0)
  {
     
     character = RFID.read();
      our_id += character;
     lastTime = now;
  }
 
  if (our_id.length() > 10) {
      our_id = our_id.substring(1,13);
      Serial.println(our_id);
      our_id = "";
      
  }
 
  
    
  delay(1000);
}

1
user5696297 On

You may need to find a reader that offer a continuously reading, as I know almost of Wiegand Reader in the market can't perform a continuously reading because they have a "onboard" control that controls this... Maybe you can try with Arduino Serial RFID Reader...

1
Karl Hunt On

I wrote my own wiegand code. Its not that difficult. I attached interrupts to the data pins and when they change I log the zero or one. You then build up the binary string and once timed out because no bits coming in. Then you convert the binary to decimal.

#include <LiquidCrystal.h>
int data0 = 2;                      //set wiegand data 0 pin
int data1 = 3;                      //set wiegand data 1 pin

unsigned long bit_holder;           //unsigned long (positive 32 bit number)
unsigned long oldbit = 0;
volatile int bit_count = 0;
LiquidCrystal lcd(8, 9, 10, 11, 12, 13);
unsigned long badge;
unsigned int timeout;
unsigned int t = 800;

void setup() {
  Serial.begin(9600);
  lcd.begin(16, 2);
  lcd.print("Present Badge");
  delay(2);
  Serial.println("Present Badge");

  pinMode(data0, INPUT);
  digitalWrite(data0, HIGH);
  pinMode(data1, INPUT);
  digitalWrite(data1, HIGH);
  attachInterrupt(0, zero, FALLING);   //attach interrupts and assign functions
  attachInterrupt(1, one, FALLING);
}


void zero(){
  bit_count ++; 
  bit_holder = (bit_holder << 1) + 0;  //shift left one and add a 0
  timeout = t;
}

void one(){
  bit_count ++; 
  bit_holder = (bit_holder << 1) + 1;  //shift left one and add a 1
  timeout = t;
}

void loop() {
  timeout --;
  if (timeout == 0 && bit_count > 0){
    lcd.clear();
    lcd.print("Dec:");
    lcd.print(bit_holder);
    lcd.setCursor(0,1);
    lcd.print("Hex:");
    lcd.print(String(bit_holder,HEX));

    Serial.print("bit count= "); 
    Serial.println(bit_count);
    Serial.print("bits= "); 
    Serial.println(bit_holder,BIN);
    oldbit = bit_holder;                //store previous this value as previous
    bit_count = 0;                     //reset bit count
    bit_holder = 0;      //reset badge number

  }

}