# Continually reading an RFID Tag

I am attempting to build a system which stays active when an RFID tag is present and then deactivates when it's removed.

RFID readers seem to have an output that fires once when the tag is in range and then doesn't run again until the tag is moved away then then rescanned.

My initial idea was to use a standard reader and then reset it forcing a new tag to come through each time. The ID-20 reader has a reset pin which I believe supports this.

I would prefer to use a cheaper reader for this project as I have quite a few to build so I am currently working with this device.

The cheaper reader doesn't have a reset pin so I was going to toggle the power to the reader when I wanted a new read. Sadly this didn't work as planned, this cheaper reader only seems to read when a tag is moving through the field.

Has anyone done anything like this before and can offer advice or would anyone know why the cheaper reader wouldn't work when the tag is static?

This is a reader firmware problem. Most access control readers default to emulating old-fashioned magstripe readers, so they only report once per "insertion" and mask the rest of their reads, as long as the tag is still visible.

Internally, the tag is constantly repeating its ID -- otherwise, the system would be much less reliable, since there would only be one chance to catch the message.

The "right" solution is to find a reader that's configurable for repeating reports, such as the Olimex MOD-RFID125, but I don't know if any meet your price point.

It's strange that the cheaper reader doesn't report a tag on powerup. It's possible that it has a sloppy RF powerup ramp, so the tag gets into a weird state because it didn't cleanly initialize. If you have an oscilloscope and a loop of wire, you can try to put it near the reader and tag to try observing the signal. You're working with a 125 kHz carrier, which should be slow enough for most scopes to capture.

The RFID tag you are using is most likely powered through electromagnetic induction. Therefore, the tag will only be powered when it is exposed to a varying magnetic field. In your case, the magnetic field is probably constant in time but varies in space. The RFID tag will be powered when it is moved through the spatially varying magnetic field.

When you turn on your reader, my guess is that the magnetic field produced by the reader doesn't vary fast enough to generate power in the RFID tag. That is, although you are transitioning from 0 magnetic forces (when the device is off) to some constant magnetic field (when the device is on), this transition does not occur fast enough. If you want the RFID tag to produce a signal while sitting in 1 place, you will need to generate a time-varying magnetic field.

• From what I could remember from college this seemed like a possible option but I was expecting the naturally pulsating (I think it is at least) field to negate the need for the tag to be moving. You can also move the tag very slowly and still get a read which is odd. – ArthurGuy Sep 18 '14 at 16:28
• No, the reader field is not static. All RFID readers send out an oscillating carrier wave to deliver power to the tag. What you describe is more like a magstripe reader, where your swiping of the card really is what generates the motion of the magnetic field. ArthurGuy's problem seems to be that his readers simulate old-fashioned magstripe readers by only outputting the read once then masking further repetitions. Internally, I'm pretty sure the tag keeps repeating its ID as long as it's in the field. – Harry Tsai Oct 3 '14 at 17:33

The RFID reader you are using has fixed function(read tag when tag approaches).

You have to design a new module or use programmable module.

The easier way is to have an IR sensor or similar behind the reader, so it can detect card's presence.

• A proximity switch for the tag is possible but very easy to defeat, I don't need this to be secure but I don't want people using a workaround like this. – ArthurGuy Sep 18 '14 at 16:29

I have actually been able to make this kind of system work with an RFID-RC522. I don't know how or why it works, but it pings the card every time the loop goes around. Will attach code, hope this helps others.

CODE:

#include <SPI.h>
#include <MFRC522.h>
#include <Wire.h> //include Wire.h library
#include "RTClib.h" //include Adafruit RTC library

#define SS_PIN 10
#define RST_PIN 9
#define RED 3
#define GREEN 2

RTC_DS3231 rtc; //Make a RTC DS3231 object

MFRC522 rfid(SS_PIN, RST_PIN); // Instance of the class

MFRC522::MIFARE_Key key;

String cardnum =  "";

// Init array that will store UID
byte uid[4];

void setup() {
Serial.begin(9600);
pinMode(RED, OUTPUT);
pinMode(GREEN, OUTPUT);
digitalWrite(RED, HIGH);
digitalWrite(GREEN, LOW);
SPI.begin(); // Init SPI bus
rfid.PCD_Init(); // Init MFRC522
for (byte i = 0; i < 6; i++) {
key.keyByte[i] = 0xFF;
}
}

void printHex(byte *buffer, byte bufferSize) {
cardnum = "";
for (byte i = 0; i < bufferSize; i++) {
//    Serial.print(buffer[i] < 0x10 ? " 0" : " ");
//    Serial.print(buffer[i], HEX);
cardnum += buffer[i] < 0x10 ? "0" : "";
cardnum += buffer[i];
}
//    Serial.print(cardnum);
}

void loop() {
for (byte i = 0; i < 4; i++) {
uid[i] = rfid.uid.uidByte[i];
}

printHex(rfid.uid.uidByte, rfid.uid.size);

if (cardnum == "144123239121"){
Serial.println();
Serial.print("");
digitalWrite(RED, LOW);
digitalWrite(GREEN, HIGH);
}
else if (cardnum == "64126193128")
{
Serial.print("");
digitalWrite(RED, LOW);
digitalWrite(GREEN, HIGH);
}
delay(20);
}else
{
digitalWrite(RED, HIGH);
digitalWrite(GREEN, LOW);
}
}

• "I don't know how or why it works" is hardly a very good basis for a technical answer, is it? – MrGerber Aug 8 '19 at 8:38