Tracking multiple RFID tags with the SparkFun Simultaneous RFID Reader - M6E Nano

I am using the Arduino Mega with the SparkFun Simultaneous RFID Reader - M6E Nano and an external UHF RFID antenna. I am making a prototype for a security solution for the logistics industry. I need to place an array of RFID tags, say 100 of those, arranged in such a way that they within range of the antenna. I need to be able to count the number of RFID tags every 1min or so, to check if any are missing.

I got all the Arduino library examples working for this Sparkfun reader (e.g. Range Test, Constant RFID read) but I am unsure of how to adapt the library to address my specific case. It seems that the RFID reader randomly scans for any tags, often reading the same tag multiple times. How do I use the Sparkfun library to count the number of unique tags?

Right now, I have an idea of adapting the “RFID_Constant_Read” example. My idea is to store EPC numbers into an array. Whenever it gives a EPC number, I will check whether it is already in the array or not. I will only add it into the array if it is not already in the array because it is a new unique tag. After letting the RFID reader do its scanning for about 30 seconds, I will then check the size of the array to determine the number of unique tags. Will this work? I bought Sparkfun RFID tags. A related issue is whether they all have a unique EPC number?

Any code advice would be helpful. I am not a professional engineer or programmer, so some code examples would be great.

I have the same RFID reader, but have that connected to a raspberry Pi.

First of all indeed the EPC are unique on the tags provided, but you can always overwrite them if you want

The constant read should be able to do the job, but I am concerned that you will out of RAM space quickly on the Arduino. I did a quick test . added global (on top)

#define EPC_COUNT 50

uint8_t EPC_recv[EPC_COUNT][12];

added a function to init (as part of a loop ot setup)

void init_array()

{

int i;

for (i =0 ; i < EPC_COUNT; i++)

{

EPC_recv [ i ] [ 0 ] = 0;

}

}

added a function to check in the array and add if needed to the array (should be called from inside the loop as add_array(nano.msg)

/ add entry to array (if not there already)

void add_array(uint8_t *msg)

{

int i,j;

i=0;

int found;

// as long as not end of list

while(i < EPC_COUNT && EPC_recv [ i ] [ 0 ] != 0)

{

found = 1;

for (j = 0 ; j < 12 ; j++)

{

if (EPC_recv[ i ] [ j ] != msg[31 + j])

{

found = 0;

j = 12;

}

}

// if found

if (found == 1) return;

}

if (i == EPC_COUNT)

{

Serial.print(F(“Can not add more to array”));

Serial.println();

return;

}

// add to array

for (j = 0 ; j < 12 ; j++)

{

EPC_recv[ i ] [ j ] = msg[31 + j];

}

Serial.print(F(“Entry added”));

Serial.println();

}

and once you are done (time out of loop count etc). get the number.

int count_entries()

{

int i=0;

while(i < EPC_COUNT)

{

if( EPC_recv[ i ] [ 0 ] == 0)

break;

i++;

}

return(i);

}

If I try to allocate 100 entries for the array on my Arduino Uno, I get already the message that the memory is dangerous low.

Thanks for validating my approach! Good to know I’m on the right track.

Update: the algorithm works! I could read 70 unique tags within 10 seconds.

good job !!

@paulvha Hello,! i am new to this forum, i am trying to connect the reader to a raspberry pi 3 but i don’t know how to do it, please can you help me? i would really appreciate it

welcome Javier. You can either use this forum and/or https://support.thingmagic.com/thingmagic. The reader can be connected serial or to USB with help of the CH340G board. The later is the easiest. On the RPI3 the “real” UART is used by bluetooth. You can disable that with a settings in the software however, but it is an extra handicap. (google for the configuration setting to apply)

Make sure to download the API from http://www.thingmagic.com/manuals-firmware. The latest version is 1.29.4.34 and make sure you get that level.There is also other documentation about the API on that link.

Go to mercuryapi-1.29.4.34/c/src/api and type : make TMR_ENABLE_SERIAL_READER_ONLY=1.

It should then compile the examples (which are in …/samples).

Connect the reader and put an RFID tag to it.

Then use ./read tmr:///dev/ttyUSB0 --ant 1,1 (in case connected to USB0, otherwise change to the port connected)

It should read the EPC.

Thank You very much, i will try this!, you are very kind.

I have started to share some of the experiences and code on https://github.com/paulvha/ThingMagic

Paulvha, what is the distance of reading for this reader? with and without external power to the reader? do you have this information?

paulvha:
I have started to share some of the experiences and code on https://github.com/paulvha/ThingMagic

Wow, this is very useful, thank you!

I most of the time just put the reader on top of an RFID tag. on 500mW it works up to about 5 centimeter (rfid tag on table, lifting the reader). With 2000mW reading to a distance of 40 centimeter with the on-board antenna. There is other stuff on the table that might impact the reader. Mind you if you use the reader power only with USB, make sure to keep the power low (500mW or so) The reader will otherwise stop reaction. I have a separate 5V power supply connected with a battery.

it is always reading multiple tags? for example if they are close? or you can select to read just one at a time

I used demo.c (the adjusted version with antenna on the aforementioned website). I could try the others, but with that demo.c I can adjust the TX power.

You could also download the Universal Reader (URA) for windows from the ThingMagic download page. There you can do continuous read and adjust

the TX power.

okey, thank you, i am using now a rpi3 with the low cost reader rc522 (13,56MHz) but i need a UHF reader because tags are easier to find, i have an application running and as an input i just need the Unique Code of one tag at a time.

The M6E will do multiple read at the same time and display all the tags that it detects on a separate line. For continues reading I have added a readcont.c (based on the read.c) in gettingstarted-folder on the earlier mentioned github. It will do continues read and display EPC from the detected RFID tags. You could use that as sample code (it has a lot over flexibility in the default version that could be removed depending on you circumstances