SparkFun Forums 

Where electronics enthusiasts find answers.

For the discussion of Arduino related topics.
#199235
I have 5 RFID tags (in the final version there will be up to 50 RFID tags). Each of these TAGS reports multiple times. i need an output after scanning, each found TAG once.

Possibly the best solution to uniquely identify each TAG. Create a 2 dimensional array. The first dimension will be a counter, the second dimension will be the (for now) EPC (later TID & EPC). A loop checks whether the TAG is already contained in the array, if not it is added.

The Arduino uno has only 2KB SDRAM. What is the most effective way to create the 2 dimensional array, wich requires the least memory?

I use code form Example 1 - Constant Read
Code: Select all
      //Print EPC bytes, this is a subsection of bytes from the response/msg array
      Serial.print(F(" epc["));
      for (byte x = 0 ; x < tagEPCBytes ; x++)
      {
        if (nano.msg[31 + x] < 0x10) Serial.print(F("0")); //Pretty print
        Serial.print(nano.msg[31 + x], HEX);
        Serial.print(F(" "));
      }
      Serial.print(F("]"));
This gives me following Serial monitor output
Code: Select all
epc[E2 00 00 17 22 0A 00 51 14 70 7F BD]
epc[E2 00 00 17 22 0A 00 38 14 70 7F 97] 
epc[E2 00 00 17 22 0A 00 71 14 70 7F DF] 
epc[E2 00 00 17 22 0A 00 38 14 70 7F 97] 
epc[E2 00 00 17 22 0A 00 37 14 70 7F 9E]
epc[E2 00 00 17 22 0A 00 71 14 70 7F DF]
epc[E2 00 00 17 22 0A 00 71 14 70 7F DF] 
As far as I can see, nano.msg is an array. But what type is the array? If I create the following array
Code: Select all
byte tagEPCBytes[5][12];
I get the following error
Code: Select all
error: invalid types 'byte {aka unsigned char}[int]' for array subscript
tagEPCBytes[counter][x] = nano.msg[31 + x];
I try to save the data from tagEPCBytes[counter][x] = nano.msg[31 + x];
Code: Select all
      for (byte x = 0 ; x < tagEPCBytes ; x++)
      { 
        tagEPCBytes[counter][x] = nano.msg[31 + x];
        Serial.print(nano.msg[31 + x]);
        Serial.print(F(" "));
      }
      Serial.print(F("]"))
      
I need help with following questions
1. is a 2 dimensional array the best way to get each Tag once after a loop check?
2. What is the most effective way to create the 2 dimensional array, wich type requires the least memory?
3. Is nano.msg an array? When yes, what type is the array?
3. Why i get the error: invalid types 'byte {aka unsigned char}[int]' for array subscript?
#199237
1. indeed a 2 dimensional array is the easiest way (if you want to keep track of the count).
2. I suspect uint8_t should do it
3. nano.msg is not an array, but a buffer. it is defined as: uint8_t msg[MAX_MSG_SIZE]; It will offset [31] to skip other information that was received as well when reading the tag.
4. it seems you have a name conflict and double define 'tagEPCBytes'.
It is defined as a byte ; byte tagEPCBytes = nano.getTagEPCBytes();
AND you also define as an array byte tagEPCBytes[5][12];
Change the name in the array definition
regards,
Paul