Go Down

Topic: Serial RFID Problem (Read 745 times) previous topic - next topic

S89

I'm currently playing around with RFID and Arduino at the minute, however I'm a little stuck. The RFID reader is connected to the RX and TX pins on the Arduino, communicating via serial.

What I want the code do to is to recognise when the RFID chip is actively in range of the reader and blink the LED on and off. When I remove the RFID chip away, it should turn off the LED.

What it's currently doing is turning on the LED... and not much else. I've been reading the serial references, but to no prevail.

Code: [Select]

int led = 7;

void setup()
{
 Serial.begin(9600);
 pinMode(led, OUTPUT);  
}
void loop()
{
 if(Serial.available())
 {
   digitalWrite(led, HIGH);
   delay(1000);              
   digitalWrite(led, LOW);  
   delay(1000);              
 }
}

PaulS

When you wave the tag by the reader, the reader sends some serial data to the Arduino. Once that arrives, you do nothing to remove it from the buffer (Serial.read() does that), so once there is serial data, Serial.available() reports a positive number of characters, so you turn the LED on, wait a second, turn it off, wait a second, and then check that the serial data is still there.

It would seem more useful to actually read the data. Further, it would seem more useful to actually light the LED is a specific tag was recognized.

PaulS

Quote
Ideally, the light would stay on whenever the tags being read (for an indefinite amount of time). Any reason why this would be?

I guess that depends on your concept of ideal. The RFID reader was designed to read the tag once when it comes into range, and then ignore it. It is not mean as a proximity detector.

S89

#3
Nov 07, 2012, 03:07 pm Last Edit: Nov 07, 2012, 03:10 pm by S89 Reason: 1
Is there no way that I could store the incoming data in a buffer and get the Arduino to check every 5 seconds or so? If the buffer is empty then turn off the LED, if it contains the ID, keep it on?

I need the LED to turn on whenever someone unique touches (or is very close) to the hotspot.

PaulS

Quote
Is there no way that I could store the incoming data in a buffer

Of course there is.

Quote
and get the Arduino to check every 5 seconds or so?

Check what?

Quote
If the buffer is empty then turn off the LED, if it contains the ID, keep it on?

The buffer won't be empty if a new tag has been scanned. Of course, you can check whether that is the same tag you saw last time. But, typically, if the tag has not moved out of range, it won't be read again.

Quote
I need the LED to turn on whenever someone unique touches (or is very close) to the hotspot.

For how long?

S89

...Get Arduino to check for a before/after difference within the buffer.

The tag is continually read every 50ms or so by the reader, even if it's still within range, so that's not an issue.

The LED will stay on until the tag is removed away from the reader (when the buffer is empty?) when it'll turn off.

--

Assuming this is the best avenue forward, could you give me some pointers to get started? Getting a little lost somewhat.

Thanks Paul :)

PaulS

Quote
could you give me some pointers to get started?

Sure:
Code: [Select]
char *pCharPtr;
int *pIntPtr;
float *pFloatPtr;


Perhaps you could post a link to the RFID reader you are using.

S89


PaulS

That looks like the same one I have. I don't recall that it scanned the tag over and over. I'll check this afternoon when I get home.

Nick Gammon


What I want the code do to is to recognise when the RFID chip is actively in range of the reader and blink the LED on and off. When I remove the RFID chip away, it should turn off the LED.


I just tested with my RFID reader. When you hold the card near it, it actives once. No matter how long you leave the card there. It isn't a proximity sensor, as PaulS said. No doubt the software in the sensor is configured to only send the same ID once. After all, if you are scanning a bag of chips at the supermarket, you don't want to be charged for 5 bags if they hold the bag in front of the sensor for a couple of seconds.
http://www.gammon.com.au/electronics

Nick Gammon

#10
Nov 08, 2012, 11:29 am Last Edit: Nov 08, 2012, 11:30 am by Nick Gammon Reason: 1
The datasheet from their web page says:

Quote
Reading Type:

Standard design -- card can't be read again within the range of read antenna after read once. User must
move it out of reading antenna range first, swipe card again & can be read.

Special design -- card can be read continuously within the range of read antenna.


Do you have standard design? Or special design?
http://www.gammon.com.au/electronics

xl97

I know I dont have same RFID hardware...

but I know my datasheet explains/outlines.. that it will take the first number in the 'area' and hold it in a 'buffer' (or whatever) to ensure that no other cards get mixed up if in the same vicinity.

Go Up