Hi,
I'm new to arduino, and I acknowledge that there are a lot of RFID reader topics, but I still have issues.
I have connected an RFID reader (PDF data sheet attached) to an Arduino Uno using a MAX485 IC. After some time playing with termination resistors I have started to get some promising information fed through "myserial" pin (pin2).
When a sample tag is waved in front of the reader, the reader beeps and sends info automatically. This info can be seen in the attached picture (RFID_MMIcode_screenshot_01). Although the info looks ok, could this still be rubbish data?
I am not really sure what way to approach the communication protocol. Is it possible to send data to the RFID reader using a MAX485 configuration?
Below is the code I used to receive the automatic response.
#include <SoftwareSerial.h>
SoftwareSerial mySerial(2, 3); //pin2 Rx, pin3 Tx
void setup()
{
Serial.begin(9600);
mySerial.listen();
Serial.println("Serial number will be displayed here if a card is detected by the module:\n");
mySerial.begin(19200);
delay(10);
}
void loop() // run over and over
{
while (mySerial.available()) {
byte C = mySerial.read();
if (C<16) Serial.print("0");
Serial.print(C,DEC);
Serial.print(" ");
}
}
Picture of wiring is also attached.
Hopfully someone can help.
Many Thanks, Michael.
mySerial.listen();
Serial.println("Serial number will be displayed here if a card is detected by the module:\n");
mySerial.begin(19200);
Why would you call listen() before begin()? You only need to call listen() if you have more than one instance of SoftwareSerial.
The picture of the wiring is next to useless. Use short wires, of different colors, that do not connect to the board under other things.
What are you powering the RFID with? The pdf file says 12 to 18 volts. I don't see where the ground from that power supply connects to the MAX232 chip or to the Arduino.
Thanks, I have taken the "mySerial.listen()" out and is working the same. It must not have been doing anything.
I have rewired and attached a few more picture(Wiring_overview_01).
The power rails have 5v and ground.
The RFID is getting 12v from an alternative source (see power_source_02).
Also attached is a picture of the tag scanned(Tag_01).
The output to the serial monitor is as follows;
"
Serial number will be displayed here if a card is detected by the module:
96 248 06 254 00 248 06 248 06 248 24 248 254 152 158 152 96 254 134 248 134 248 134 248 00 248 00 248 06 248 102 248 06 248 06 248 24 248 128 248 00 248 30 248 96 248 120 248 30 248 102 248 30 248 00
"
I have seen rubish data before and it never formed whole digits like that...?
I am not really sure what way to approach the communication protocol. Is it possible to send data to the RFID reader using a MAX485 configuration?
Yes.
Currently pin 2 and 3 of the MAX are connected to ground (by the looks of it) allowing for receive. Connect them to a pin on the Arduino and you can set the direction of the communication.
According to the MAX485 datasheet (figure 21), you should have a resistor (120 Ohm) between the two output pins, not resistors to Vcc and GND; I don't know how they need to be calculated but I would start with the 120 Ohm. I wonder where you got the idea from to use pullup and pulldown (it might be valid, I don't know).
Your data in the screenshot does not seem to be correct. According to the datasheet of the reader, the communication is text based (so why are you printing decimal?). Anything you receive should be between '[' (91 decimal, 5B hex) and ']' (93 decimal, 5D hex); I don't see those.
#include <SoftwareSerial.h>
SoftwareSerial mySerial(2, 3); //pin2 Rx, pin3 Tx
void setup()
{
Serial.begin(9600);
//mySerial.listen();
Serial.println("Serial number will be displayed here if a card is detected by the module:\n");
mySerial.begin(19200);
delay(10);
}
void loop() // run over and over
{
while (mySerial.available()) {
byte C = mySerial.read();
if (C<16) Serial.print("0");
Serial.print(C,HEX);
Serial.print(" ");
}
}
And I now get and output on the monitor;
"
Serial number will be displayed here if a card is detected by the module:
60 F8 06 FE 00 F8 06 F8 06 F8 18 F8 FE 98 9E 98 60 FE 86 F8 86 F8 86 F8 00 F8 00 F8 06 F8 66 F8 06 F8 06 F8 18 F8 80 F8 00 F8 1E F8 60 F8 66 F8 1E F8 78 F8 1E F8 00
"
Does this look any better? Am I doing anything fundamentally wrong?
Maybe this might help diagnose the problem - I have tryed another sketch which gives a different output.
#include <SoftwareSerial.h>
const int RFID_RX = 2;
const int RFID_TX = 3;
SoftwareSerial RFID = SoftwareSerial(RFID_RX, RFID_TX);
void setup() {
Serial.begin(9600); //Setup connection to Computer via HardwareSerial
RFID.begin(19200); //Setup connection to RFID Reader via SoftwareSerial
Serial.println("Awaiting Tag");//Provide Arduino's current status
}
void loop()
{
if (RFID.available())
{
char val = RFID.read();
Serial.print(val, HEX);
Serial.println(" ");
}
}
//http://forum.arduino.cc/index.php?topic=113970.0
The output to the monitor is as follows;
"
Awaiting Tag
60
FFFFFFF8
6
FFFFFFFE
0
FFFFFFF8
6
FFFFFFF8
6
FFFFFFF8
18
FFFFFFF8
FFFFFFFE
FFFFFF98
FFFFFF9E
FFFFFF98
60
FFFFFFFE
FFFFFF86
FFFFFFF8
FFFFFF86
FFFFFFF8
FFFFFF86
FFFFFFF8
0
FFFFFFF8
...........................This continues...
"
Any ideas?
Thanks again.
Maybe you can use some ASCII art to make the schematic.
ARDUINO
+----------------+
| |
| SCL o
| |
| SDA o
| |
| AREF o
| |
| GND o
| |
o IOREF 13 o
| |
o RESET 12 o Power Supply
| | +---------------+
o 3.3V 11 o | |
| | ??? ----------+------o GND12 |
5V ----o 5V 10 o | | |
| | | +---o 12V |
o GND 9 o 5V | | | |
| | | | | +---------------+
GND5 ----o GND 8 o | | |
| | MAX485 | | | RFID
o Vin 7 o +-------------------+ | | | +---------------+
| | | | | R1 | | | |
| 6 o +-----------o 1 8 o--+----/\/\/\/\--+ | +---o RED (DC) |
| | | | | | | | |
o A0 5 o | +--o 2 7 o-----------------+----------+ +------o BLACK (GND) |
| | | | | | | | |
o A1 4 o | +--o 3 6 o-----------------+-------+ +-- o YELLOW (A) |
| | | | | | | | | |
o A2 3 o-----------------------o 4 5 o--+----/\/\/\/\--+ +----- o GREEN (B) |
| | | | | | | R2 | |
o A3 2 o-----------+ | +-------------------+ | +---------------+
| | | |
o A4 TX/1 o | |
| | | |
o A5 RX/0 o GND5 GND5
| |
+----------------+
Copy and paste the above in an text editor (notepad, vi, ...), correct it (I might have made a mistake) and complete it.
Use a '+' for wires that are connected (shown for e.g. pin 8 of the MAX485 connects both to a resistor and 5V) and 90 degree angles and leave it out for crossing lines (shown for e.g. pin2 of the Arduino to pin1 of the MAX485 and pin3 of the Arduino to pin4 of the MAX485).
I've used two different grounds (GND5 / Arduino ground and GND12 / RFID power supply ground) because it's not known if they are connected. If GND12 of the power supply is connected to GND5 of the Arduino, replace the question marks by GND5.
You can also use something like MS Paint to make the drawing.
Note:
BothASCII art and Paint are a bit of work, but it helps us to help you. It would even be better if you could learn and use a proper schematic editor.
PS:
Still wondering where you found the wiring of the resistors around the MAX485; do you have a link?