Two RFID readers, one arduino?

Would someone please help me? I'm a newbie trying to figure out how to use RFID readers.

From what I have figured about RFID readers so far, the arduino gets the input through the RX0 pin. The thing I am trying to make uses more than one RFID reader and I had just assumed it would go on the analog pins. So is my project actually impossible with more than one RFID reader or is there some way to get the output from more than one to go into the arduino?

Trying to program for RFID readers is a real uphill battle, especially since I can't find any real tutorials on it. Pretty much everything I can find about using RFID readers with arduino practically says "Here is some mysterious code to copy paste which you can use to make exactly this one thing" and absolutely no explanation of how to actually program for the RFID yourself. Maybe programming for RFID readers is just intuitively obvious for everyone except me and I'm the only one who needs them explained. :-[

What kind of RFID readers do you have? What kind of Arduino?

You can use the NewSoftSerial library to read from the "serial port" that the 2nd RFID reader is attached to.

Why do you need more than one, anyway?

Thank you for resonding.

I have Innovations ID-20 and the Duemilanove. So does that mean I can use the analog input pins for input from a reader if I learn how to use the NewSoftSerial library?

I need more than one for a project of my own that I'm working on. I need multiple objects to be able to tell when comes close to another one.

Using the ID-20 is pretty intuitively obvious if you know how the serial functions work. - In every pass through loop(), see if you have 16 bytes in the serial buffer- If you do, read those bytes into a byte array- Do something with the tag you retrieved Obviously the "do something" part depends on what you are trying to achieve. Myself, I assume if the first and last bytes are 02 and 03 respectively, we have a valid tag. Then I check a portion of the tag against a stored list of valid tags.

I have not used the soft serial libraries though; there may be some complications in using multiple soft serial ports. See

You can use an Arduino Mega instead. It has four hardware serial ports, so you could dedicate one port to communicating with the host (if needed) and have three ports for readers if you need them.

Sorry, I'm not very clever. So I'll have some function returning a variable and that variable is a number representing the ID of the card? That makes it sound so simple, like all the code I would need for reading a card would look something like:

byte id = somethingRead(somePin);

and I'm done. But all the sample code I find has all sorts of other stuff going on with hexadecimal numbers and stuff.

The NewSoftSerial page talks about "multiple instances" which I assume is what I need. It gives the example:

// Here's a GPS device connect to pins 3 and 4
NewSoftSerial gps(4,3);

// A serial thermometer connected to 5 and 6
NewSoftSerial therm(6,5);

// An LCD connected to 7 and 8
NewSoftSerial LCD(8,7); // serial LCD

So does that mean that one could then use the analog (or is it the digital?) input pins 3 and 4 to get the input from the GPS? Then 5 and 6 for the thermometer, and 7 and 8 for the LCD?

The "hexadecimal numbers and stuff" is because when the RFID reader detects a tag, it transmits 16 bytes over the serial port at 9600 baud. These are:

02 (10 data bytes) (2 checksum bytes) CR LF 03

So when you receive 16 bytes, you ought first to verify they are a real tag (02 as byte 0 and 03 as byte 15). Bytes 1 - 10 will be the unique numbers encoded on each tag.

What you do with that data is up to you. If you want to be able to identify specific tags, you will need to first determine the data encoded on each tag. A good exercise would be to write a simple program that waits to receive a character from the RFID serial port, then prints that character to the serial port you have the serial monitor connected to. Not only will this tell you the code of your tags, it will get you comfortable with the serial stuff.

In my application, I store a table of two-byte "key" sequences (at two particular positions in the packet) that uniquely identify each of my tags. When I receive a code from the reader, I scan through that table to see if the received tag's 2-byte key matches any of the stored 2-byte key. If it does, the function returns a number representing which tag was detected.

Again, I don't use the soft serial libraries, but the page on Mikal's site suggests that the serial buffers are discarded whenever you switch from one port to another. So it is not clear if you can simultaneously listen to multiple readers on multiple soft serial ports.

Thank you, Professor Chaos and Paul. You have pointed me in the right direction. I guess the problem is that I was googling for RFID tutorials when what I needed to google for was serial communication. I've been reading up on it and I'm beginning to get a clearer picture.

But if I may ask another question, is there a way I can program the arduino to turn the RFID readers on and off at my command? I read that there is badness with having two RFID readers close to each other, so I think I need to turn them on and off so that they take turns being on.

is there a way I can program the arduino to turn the RFID readers on and off at my command?

You can switch the power to them just like it was a motor:- However they might take some time to start working after initial power up (a second or two) this could give you trouble, if you want to rapidly switch from one to the other.

there is badness with having two RFID readers close to each other

The range is compromised if they are close, too close and they will stop working altogether. It depends a lot on the reader design, do some experiments with your readers.

Thank you, Grumpy Mike. Yikes, that was quite a read! I can't claim that I understood a word of that web page, but can I take away from it that there is no way to program the arduino to turn the reader on and off? The only way to turn a reader on and off is with hardware components?

EDIT: By the way, "Crazy People" is awesome! ;D

By the way, "Crazy People" is awesome

Thanks. You can see from that project I have three readers working quite close together. They used a Wiegand output rather than a serial one. Mind you the reader design was a good one. ;)