Pages: [1]   Go Down
Author Topic: Serial RFID Problem  (Read 698 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 1
Posts: 48
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
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);              
  }
}
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 601
Posts: 48543
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 601
Posts: 48543
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Offline Offline
Newbie
*
Karma: 1
Posts: 48
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
« Last Edit: November 07, 2012, 09:10:16 am by S89 » Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 601
Posts: 48543
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
Logged

Offline Offline
Newbie
*
Karma: 1
Posts: 48
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

...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 smiley
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 601
Posts: 48543
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
could you give me some pointers to get started?
Sure:
Code:
char *pCharPtr;
int *pIntPtr;
float *pFloatPtr;

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

Offline Offline
Newbie
*
Karma: 1
Posts: 48
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Sure, that probably would have been helpful to begin with: http://www.seeedstudio.com/depot/125khz-rfid-module-uart-p-171.html
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 601
Posts: 48543
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Global Moderator
Offline Offline
Brattain Member
*****
Karma: 474
Posts: 18696
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Global Moderator
Offline Offline
Brattain Member
*****
Karma: 474
Posts: 18696
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
« Last Edit: November 08, 2012, 05:30:54 am by Nick Gammon » Logged

0
Online Online
Edison Member
*
Karma: 7
Posts: 1235
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged


Pages: [1]   Go Up
Jump to: