i have successfully modified the source code as follows.
#include <SoftwareSerial.h>
#include <stddef.h>
SoftwareSerial softSerial(2, 3);
#include "SparkFun_UHF_RFID_Reader.h"
RFID nano;
#define BUZZER1 10
#define BUZZER2 9
boolean tagDetected;
long lastSeen = 0;
int counter = 0;
void setup()
{
Serial.begin(115200);
pinMode(BUZZER1, OUTPUT);
pinMode(BUZZER2, OUTPUT);
digitalWrite(BUZZER2, LOW);
while (!Serial);
if (setupNano(38400) == false)
{
Serial.println(F("Das Modul hat nicht reagiert. Bitte überprüfen Sie die Anschlüsse."));
while (1);
}
nano.setRegion(REGION_NORTHAMERICA);
nano.setReadPower(2700);
nano.startReading();
Serial.println("Scannprozess läuft!");
lowBeep();
tagDetected = false;
}
void loop()
{
byte myEPC[12];
byte myEPClength;
byte responseType = 0;
uint8_t tagEPCBytes[50][12];
if (nano.check() == true)
{
byte responseType = nano.parseResponse();
if (responseType == RESPONSE_IS_TAGFOUND)
{
long timeStamp = nano.getTagTimestamp();
byte tagEPCByteCount = nano.getTagEPCBytes();
Serial.print(F("RFID-Tag detektiert: "));
Serial.println(counter++);
Serial.print(F("RFID-Daten EPC["));
for (byte x = 0 ; x < tagEPCByteCount ; x++)
{
if (nano.msg[31 + x] < 0x10) Serial.print(F("0"));
Serial.print(nano.msg[31 + x], HEX);
if (x != 11) Serial.print(F(" "));
}
Serial.println(F("] "));
Serial.print(F("Bin-Daten["));
for (byte p = 0 ; p < tagEPCByteCount ; p++)
{
tagEPCBytes[counter][p] = ((uint8_t) nano.msg[31 + p]);
Serial.print(nano.msg[31 + p]);
if (p != 11) Serial.print(F(" "));
}
Serial.println(F("] "));
if (tagDetected == false)
{
tagDetected = true;
}
else if (millis() - lastSeen > 250)
{
}
lastSeen = millis();
}
}
if (tagDetected == true && (millis() - lastSeen) > 1000)
{
Serial.println(F("Kein RFID-Tag gefunden..."));
tagDetected = false;
}
if (Serial.available())
{
nano.stopReading();
Serial.read();
delay(1000);
Serial.println("Array Ausgabe:\n");
delay(333);
int i, j;
for (i = 0; i < 50; i++) {
for (j = 0; j < 12; j++) {
Serial.print(tagEPCBytes[i][j]);
Serial.print(" ");
if (j == 11) {
Serial.println(" ");
}
}
}
delay(333);
Serial.println("Scannen angehalten. Drücken Sie die Taste, um fortzufahren.");
while (!Serial.available());
Serial.read();
nano.startReading();
}
}
boolean setupNano(long baudRate)
{
nano.begin(softSerial);
softSerial.begin(baudRate);
while (!softSerial);
while (softSerial.available()) softSerial.read();
nano.getVersion();
if (nano.msg[0] == ERROR_WRONG_OPCODE_RESPONSE)
{
nano.stopReading();
Serial.println(F("Modul liest kontinuierlich. Modul soll kontinuierlich lesen beenden...."));
delay(1500);
}
else
{
softSerial.begin(115200);
nano.setBaud(baudRate);
softSerial.begin(baudRate);
}
nano.getVersion();
if (nano.msg[0] != ALL_GOOD) return (false);
nano.setTagProtocol();
nano.setAntennaPort();
return (true);
}
void lowBeep()
{
tone(BUZZER1, 130, 150);
}
void highBeep()
{
tone(BUZZER1, 2093, 150);
}
I get follwing serial monitor output.
Scannprozess läuft!
RFID-Tag detektiert: 0
Bin-Daten[226 0 0 23 34 10 0 55 20 112 127 158]
RFID-Tag detektiert: 1
Bin-Daten[226 0 0 23 34 10 0 56 20 112 127 151]
RFID-Tag detektiert: 2
Bin-Daten[226 0 0 23 34 10 0 55 20 112 127 158]
RFID-Tag detektiert: 3
Bin-Daten[226 0 0 23 34 10 0 56 20 112 127 151]
RFID-Tag detektiert: 4
Bin-Daten[226 0 0 23 34 10 0 55 20 112 127 158]
RFID-Tag detektiert: 5
Bin-Daten[226 0 0 23 34 10 0 113 20 112 127 223]
RFID-Tag detektiert: 6
Bin-Daten[226 0 0 23 34 10 0 55 20 112 127 158]
RFID-Tag detektiert: 7
Bin-Daten[226 0 0 23 34 10 0 56 20 112 127 151]
RFID-Tag detektiert: 8
Bin-Daten[226 0 0 23 34 10 0 81 20 112 127 189]
RFID-Tag detektiert: 9
Bin-Daten[226 0 0 23 34 10 0 113 20 112 127 223]
RFID-Tag detektiert: 10
Bin-Daten[226 0 0 23 34 10 0 56 20 112 127 151]
RFID-Tag detektiert: 11
Bin-Daten[226 0 0 23 34 10 0 56 20 112 127 151]
RFID-Tag detektiert: 12
Bin-Daten[226 0 0 23 34 10 0 113 20 112 127 223]
Array Output:
226 0 0 23 34 10 0 55 20 112 127 158
226 0 0 23 34 10 0 56 20 112 127 151
226 0 0 23 34 10 0 55 20 112 127 158
226 0 0 23 34 10 0 56 20 112 127 151
226 0 0 23 34 10 0 55 20 112 127 158
226 0 0 23 34 10 0 113 20 112 127 223
226 0 0 23 34 10 0 55 20 112 127 158
226 0 0 23 34 10 0 56 20 112 127 151
226 0 0 23 34 10 0 81 20 112 127 189
226 0 0 23 34 10 0 113 20 112 127 223
226 0 0 23 34 10 0 56 20 112 127 151
226 0 0 23 34 10 0 56 20 112 127 151
226 0 0 23 34 10 0 113 20 112 127 223
226 0 0 23 34 10 0 55 20 112 127 158
226 0 0 23 34 10 0 81 20 112 127 189
226 0 0 23 34 10 0 56 20 112 127 151
226 0 0 23 34 10 0 57 20 112 127 159
226 0 0 23 34 10 0 81 20 112 127 189
226 0 0 23 34 10 0 113 20 112 127 223
226 0 0 23 34 10 0 56 20 112 127 151
226 0 0 23 34 10 0 81 20 112 127 189
226 0 0 23 34 10 0 113 20 112 127 223
226 0 0 23 34 10 0 57 20 112 127 159
226 0 0 23 34 10 0 56 20 112 127 151
226 0 0 23 34 10 0 81 20 112 127 189
226 0 0 23 34 10 0 56 20 112 127 151
226 0 0 23 34 10 0 81 20 112 127 189
226 0 0 23 34 10 0 55 20 112 127 158
226 0 0 23 34 10 0 57 20 112 127 159
226 0 0 23 34 10 0 56 20 112 127 151
226 0 0 23 34 10 0 113 20 112 127 223
226 0 0 23 34 10 0 81 20 112 127 189
226 0 0 23 34 10 0 57 20 112 127 159
226 0 0 23 34 10 0 55 20 112 127 158
226 0 0 23 34 10 0 81 20 112 127 189
226 0 0 23 34 10 0 56 20 112 127 151
226 0 0 23 34 10 0 113 20 112 127 223
220 93 169 149 222 117 79 139 22 252 208 175
69 82 162 142 124 127 3 174 81 242 43 136
153 4 98 75 88 163 79 241 31 166 107 54
239 4 62 52 164 91 117 244 229 29 171 246
220 78 136 193 254 233 129 190 104 61 190 140
90 93 27 15 55 225 197 194 122 223 11 64
60 9 93 59 127 216 212 59 53 59 218 58
202 125 253 214 139 117 207 98 40 166 23 145
103 91 6 249 0 0 255 36 6 249 0 0
7 17 3 108 29 35 2 108 157 41 216 144
33 17 0 2 54 4 187 7 132 0 193 1
202 0 1 1 108 7 7 1 201 0 1 201
1 201 0 0 0 0 2 208 0 0 0 0
Scannen angehalten. Drücken Sie die Taste, um fortzufahren.
The Problem is solved, I can now write the RFID-values in a 2D-Array.
I don't know why i have much more data in the array uint8_t tagEPCBytes[50][12] than i have scanned?
I have a other question, but it is better to open a new thread. Because it has nothing to do with this problem.
Thanks to all those who helped me.