Hi there,
I'm currently doing some tests with Arduino and an RDM630 RFID-reader, but the RFID reader is behaving a little strange.
The circuit is fairly simple and the sketch simple as well. The output of the RFID reader is connected to arduino pin #2 which is being read by a SoftwareSerial object. When a code is read it is being compared against seven different know codes and depending on the code that was read the appropriate led is flashed for 25msec.
Howerver, it seems that in my construction the arduino is not receiving rfid codes in a consistent way. Sometimes the RFID reader sends the codes fluently, sometimes it "stalls", sometimes it stops sending no codes at all, sometimes it sends one code only when I'm bring a tag close to the antenna or when taking it away, etc. This youtube video is demonstrating the behavior of the circuit:
Initially I thought that it must be a connection problem with the antenna (like a broken soldering or cable), but I ended up soldering the antenna directly onto the RFID reader board and I got the exact same results.
This is the circuit diagram (sorry for the bad quality and the hand-drawing):
This is the sketch-code:
#include <SoftwareSerial.h>
#define rxPin 2
#define txPin 3
#define ledPinBase 4
SoftwareSerial RFID = SoftwareSerial(rxPin,txPin);
#define numOfTags 7
char *known_codes[] = {
" 2 52 53 48 48 66 56 66 70 50 53 54 55 3",
" 2 51 68 48 48 65 56 54 53 56 66 55 66 3",
" 2 51 67 48 48 67 68 48 52 55 68 56 56 3",
" 2 52 52 48 48 69 55 48 52 51 70 57 56 3",
" 2 48 49 48 55 69 69 56 50 56 66 69 49 3",
" 2 52 53 48 48 66 56 70 70 57 49 57 51 3",
" 2 48 48 51 54 53 70 56 67 49 65 70 70 3",
};
void setup()
{
Serial.begin(9600);
RFID.begin(9600);
pinMode(rxPin,INPUT);
for (int i = 0; i < numOfTags; i++) {
pinMode(ledPinBase+i,OUTPUT);
digitalWrite(ledPinBase+i,LOW);
}
}
char code[1024];
void loop()
{
if (RFID.available()) {
code[0] = '\0';
int values = 0;
while (RFID.available() && values++ < 14) {
int val = RFID.read();
sprintf(code,"%s %d",code,val);
}
Serial.println(code);
int tag = -1;
for (int i = 0; i < numOfTags; i++) {
if (strcmp(known_codes[i],code) == 0) {
tag = i;
break;
}
}
if (tag != -1) {
digitalWrite(ledPinBase+tag,HIGH);
delay(25);
digitalWrite(ledPinBase+tag,LOW);
}
}
delay(25);
}
The code is not the best possible but this is roughly a prototype/test so this is not the import thing right now.
Any ideas what is going wrong?
Thank you in advance.
Giannis