hi to all,
I'm trying to develop a login system based on magnetic cards.
I already have a magnetic card reader (please check the attached photo).
This reader works at 5VDC and its pinout is very simple: +5VDC, GND, RX and TX.
I connected RX and TX to Pin 10 and Pin 11 and I used Software Serial to check if there was something on the serial port.
Unfortunately, I receive only garbage randomly; moreover, the serial output is not synchronized to the card striping so I guess it's just garbage.
#include <SoftwareSerial.h>
SoftwareSerial mySerial(10, 11); // RX, TX
void setup() {
// Open serial communications and wait for port to open:
Serial.begin(9600);
while (!Serial) {
; // wait for serial port to connect. Needed for native USB port only
}
Serial.println("Goodnight moon!");
// set the data rate for the SoftwareSerial port
mySerial.begin(9600);
mySerial.println("Hello, world?");
}
void loop() { // run over and over
if (mySerial.available()) {
Serial.write(mySerial.read());
}
if (Serial.available()) {
mySerial.write(Serial.read());
}
}
I tried to search on google, but I found nothing about magnetic card reader with serial communication.
I do not have any datasheet related to this reader, I can only read TX and RX on the pinout diagram.
I even do not know the port velocity: should it be 9600? I tried to change it but nothing changed.
Do you have any suggestions?
I hope you can help me.
Thank you!
Any help? I'm continuing to search on google, but I didn't find anything 
Do you have any information on the reader, a part number for instance. Where did you buy it? What is the voltage level of the TX output. Is it 0 to 5V (TTL) or -12 to +12 (RS232)? If the latter you will need a level shifter (MAX232 or equivalent) and the RX pin (10) of the Arduino may have been damaged. Just because the supply is 5V does not mean that the TX output is 5V.
Your card can also have any combination of up to three magnetic stripes. Each is recorded differently. Do you know which stripe or stripes is read by the reader?
Paul
Try every common baud rate 300, 1200, 2400, 4800, 9600, 19200, 38400, 57600, 74880, 115200, 230400. Try to find which one the device speaks. If that fails, use a sketch like ArduinoScope to measure the serial pulses to determine the bit rate.
Thank you for all your suggestions.
I have no datasheet since I'm using a reader that comes from a working system. I do not know its model, I just now it works at 5VDC with serial port.
I tried to run an auto baudrate detector and it seems to work at 115000 and so I cannot try to read it by using Software Serial since the library doesn't support high speed communication.
Unfortunately, I do not know the information about the stripes.
The voltage level of the TX output is 5v.
For testing you can use the hardware USB-to-Serial on the Arduino (UNO, MEGA...). Jumper the Reset pin to Ground to hold the processor in reset. Then you can connect your card reader to Pin 0 and Pin 1. That will connect it directly to your PC over USB. Start up the Serial Monitor and set the baud rate to 115200. That will let you see what kind of data the card reader sends when you scan a card. If you get letters and digits then you are in good shape. If you get garbage, but the same garbage each time, it is probably sending binary. Still not bad.
If the reader baud rate is too high for SoftwareSerial, get a Leonardo or Micro. Then you can use Serial1 (Pins 0 and 1) for the reader and USB for the PC. Or get an Arduino MEGA which has Serial1, Serial2, and Serial3 in addition to Serial.
I tried with Arduino Mega and I uploaded this code:
void setup() {
// initialize both serial ports:
Serial.begin(9600);
Serial3.begin(9600);
}
void loop() {
// read from port 1, send to port 0:
if (Serial3.available()) {
int inByte = Serial3.read();
Serial.write(inByte);
}
// read from port 0, send to port 1:
if (Serial.available()) {
int inByte = Serial.read();
Serial3.write(inByte);
}
delay(100);
}
I found out a label inside the card reader (I disassembled it) and it says it can handle track 1 and 2, the power supply is 5VDC, velocity 9600.
The problem is that I receive nothing on serial monitor when I stripe the card.
Why is it no longer part of a working system? Was it working properly when removed? Did you try the card with stripe one way and then the other? In other words, does the reader have one reader or two?
Paul
The reader has only one sensor so it works only in one way. The reader and the system were working very well. I removed the reader because I wanted to make the reader work with arduino.
I tried it both ways but I get nothing as output.
I also tried to swap both rx and tx pins.
Normally, the reader works with an electronics board which is not open source so I do not know the algorithm.
I only know that the reader works at 5 VDC and that it uses rs232.
marcusbarnet:
The reader has only one sensor so it works only in one way. The reader and the system were working very well. I removed the reader because I wanted to make the reader work with arduino.
I tried it both ways but I get nothing as output.
I also tried to swap both rx and tx pins.
Normally, the reader works with an electronics board which is not open source so I do not know the algorithm.
I only know that the reader works at 5 VDC and that it uses rs232.
By now, you must be aware that RS-232 standard voltages are +3 to +25 volts and -3 to -25 volts. And you went ahead and connected it directly to your Arduino?
You must use a converter board to make RS-232 compatible with the Arduino 0-5 volt pins.
Paul
I tried to directly connect it to my computer which has a rs232 port, but ubuntu was not able to recognize the reader.
Should this solve the problem with the level shifting?
The linked level shifter is not for shifting RS232 signals to TTL. The proper device would be one like the MAX232 (5V) or MAX3222 (3.3V).