Go Down

Topic: Magstripe Reader Project (Read 4503 times) previous topic - next topic

BBX

Hi  :),

I recently began attending school at college, and every student is issued an ID that has a magnetic strip on the back like a credit card.

I'd like to have my Arduino be able to pull the raw data off a swiped card and be able to do different actions based on which (different roomates) card is swiped.

I don't have much experience with Arduino programming, so I'm looking for guidance on a sketch + card reader that should work with the controller or a tutorial on how to wire up the reader. I've searched around at other projects, but haven't found one with a link to buy the same reader to ensure that it will work. My budget is about $25 for the reader.

Sorry for walking in cold on the topic :smiley-roll-sweat: and thanks for any help!

radman

For $25 I don't think you will get anything new.
This one is is a read/writer and cost $140 https://www.sparkfun.com/products/8634.

The simplest way to read the data is to get a reader with an RS232.
Probably best to search for second hand units, businesses shutting down.


BBX

#2
Aug 22, 2012, 10:35 pm Last Edit: Aug 22, 2012, 10:37 pm by BBX Reason: 1
Thank you for the reply!

I'm not looking to write to the card, just read it to determine whose card is being used.

Something similar to this reader:
http://www.amazon.com/CE-Compass-Magnetic-Stripe-Credit/dp/B008FW3XXG/ref=pd_cp_e_2

That works similar to this (except to light up an LED, not make money transactions):
http://www.ladyada.net/make/magstripe/index.html

mcreefer

They all read the same as long as its 3track. The trouble your going to run into is figuring out what track they write to. Plug this into your pc first and run a few cards through it with a capture program and you will see a pattern. Then once you figure it out, you can snip the end and plug it right into your arduino. From there your on your own. I don't know how the arduino is going to like it.
http://www.ebay.com/itm/USB-Mini-Portable-Magnetic-Stripe-MSR-3TK-3-Track-Swipe-Credit-card-reader-/310423171499?pt=BI_Credit_Card_Terminals&hash=item4846a9b1ab

BBX


Riva


Plug this into your pc first and run a few cards through it with a capture program and you will see a pattern. Then once you figure it out, you can snip the end and plug it right into your arduino. From there your on your own. I don't know how the arduino is going to like it.
http://www.ebay.com/itm/USB-Mini-Portable-Magnetic-Stripe-MSR-3TK-3-Track-Swipe-Credit-card-reader-/310423171499?pt=BI_Credit_Card_Terminals&hash=item4846a9b1ab

The device is USB so I don't think snipping the plug off and plugging it into the Arduino will work. You would need a USB host shield https://www.sparkfun.com/products/9947? or try hacking the hardware to intercept the card data before it gets converted to USB, though this really depends on how the hardware is used so probably won't be easy.
Your better off with a card reader that has either RS232 http://circamicro.com/p-1155924-zu-m1242l4dk-card-reader-2-track-swipe-rs232.aspx?currency=GBP or PS/2 http://www.ebay.co.uk/itm/PS2-Magnetic-Stripe-Credit-Card-Reader-3TK-PS-2-/180609077842#vi-content as Arduino can read/write PS/2 http://www.arduino.cc/playground/Main/PS2Keyboard

mcreefer

Mag readers are mostly 3 wire systems. I replaced them many times in ATMs and gas pumps as well as time clocks. You would be better off buying an OEM replacement for a machine like that since its wires and not USB. But I would think you could snip the end and find its very much the same. If you wanted another route you can look at this
http://www.ebay.com/itm/Magnetic-Stripe-Card-Reader-Magtek-21045002-/110747797136?pt=LH_DefaultDomain_0&hash=item19c9154690
Or many others like it on ebay. Although I've never seen one with so many wires so it code be a dual reader.

BBX

Thanks for the replies.

I've been reading some more on the topic, and while I'm about to give up and use a USB reader with a laptop instead, the possibility of using a Square Credit Card Reader as my card reader instead is very tantalizing.

Square makes a card reader that plugs into phones as a mic input, and then their software reads cards. I've plugged the reader into a mic input on my PC, and swiping a card generates a tangible waveform as an audio signature.. I feel like if I knew just a little bit more about what I'm doing, I'd be able to decode the audio and identify the dorm cards we're using.


eried


Thanks for the replies.

I've been reading some more on the topic, and while I'm about to give up and use a USB reader with a laptop instead, the possibility of using a Square Credit Card Reader as my card reader instead is very tantalizing.

Square makes a card reader that plugs into phones as a mic input, and then their software reads cards. I've plugged the reader into a mic input on my PC, and swiping a card generates a tangible waveform as an audio signature.. I feel like if I knew just a little bit more about what I'm doing, I'd be able to decode the audio and identify the dorm cards we're using.




I bought a used Magtek Ps/2 reader (for about 17 usd) and works pretty well with my arduino :)
Really easy to use, just add the keyboard library and I replaced some strings in the interpretation. And the SD shield was homemade from a chinese sd reader ~2-3 usd so you are still on budget hehehe.

http://www.youtube.com/watch?v=NN3jko0gWu0
My website: http://ried.cl

m4ck

I have a spark fun magnetic card reader that I cut the cords on to connect to my arduino (+5v, gnd, rx, tx)

here is the model: https://www.sparkfun.com/products/11096?

I connected the TX and RX to pins 2 + 3, and am using SoftwareSerial to read the incoming data.

Here is the code that i'm working with:

#include <SoftwareSerial.h>

SoftwareSerial mySerial(2, 3); // RX, TX

byte inByte;


void setup() 
{
// Open serial communications and wait for port to open:
  Serial.begin(9600);


  mySerial.begin(9600);
}

void loop() // run over and over
{
  if (mySerial.available()){
  inByte = mySerial.read();
 
  //Serial.write(inByte);
  Serial.print(inByte, DEC);
  }
}


When I swipe my school's id, I get this string of ascii numbers:

981721502142461182224624686172182182222286111150


I'm wondering if anyone has any insight to get this data into a readable format. In the reader's datasheet it says the data should be separated like this:
Track 1 start character?? End character??
Track 2 start character?? End character??
Track 3 start character?? End character??
Enter key is end character of the whole data packet.


Any help would be greattly appreciated!!!

PeterH

I guess that Serial.print is giving you a decimal representation of the ascii code received from the reader, but since you haven't separated the bytes it's impossible to tell what the byte values were.

If you think the values are ascii characters, you could convert the byte to a char before printing which would cause the print method to print the byte as-is. However, if it encountered a non-printable character then the output may not be too helpful. It's worth a try though, just in case it turns out that the data is actually printable ascii.

If it's not ascii then you can either print it in decimal with a separator (for example, space) between each byte, or print it in hex so that the number of characters printed per byte is known.
I only provide help via the forum - please do not contact me for private consultancy.

retrolefty

#11
Nov 22, 2012, 02:04 am Last Edit: Nov 22, 2012, 02:10 am by retrolefty Reason: 1
Several years ago I bought a surplus $5 mag card reader from electronics goldmine. It was a basic model with just a clock and a data signal line and I believe it was a track 2 only reader. Track 1 is what the majority of the cards (or at least the most common) use only, I think I read in my research at the time.

There was a arduino sketch someone posted at the time to get the arduino to decode the data stream and resend it out the serial port. It worked pretty well, but all the various cards I swiped just tended to have a rather long random series of numbers as your example. Note below in the specs that there is a standard defined ASCII start and end character for the protocol. My sketch showed those start and ending characters, where your serial data version is a higher level unit and may strip off the message start and stop characters.

I suspect that most issurers of these cards just put a long unique random number onto the card that then their central computer systems uses as an ID index into their complete database for the holder of the card. Only my Calif Drivers licence seem to have a simple clear text data which I recall correctly was the license number (same as printed on the front) and my data of birth.  So I think most just record straight ASCII number characters on them as you have printed on your posting.

Quote

Data packet format??Suitable to all magnetic card reader?
Track 1 start character?? End character??
Track 2 start character?? End character??
Subject  Specification
Track standard  Comply with ISO7811  
Decoding method  F2F (FM)
Starting character  Track 1"%"  Track 2"?"  Track 3"+"
Card reading Data bit
Track 1  79
Characters (7-bit)
Track 2  40
Characters(5-bit)
Track 3  107
characters(5-bit)
Card thickness  0.2~0.84 mm
Suitable Voltage  DC5V±0.5V
Static current  10mA/5V
Track reading width  1.5mm
Magstripe passing speed  15 - 120 cm/sec (6-50inch/sec)
Magnetic head life span  More than 800,000 passes
Error rate  Lower than 0.5%
Interface  RS232,USB,PS/2 Track 3 start character?? End character??
Enter key is end character of the whole data packet.

BBX

Woah! I don't know why I haven't gotten an email about replies until now  :(

I ended up purchasing a USB single track reader. But I'll keep playing around with tape heads to see if I can make something work :)

m4ck

#13
Nov 24, 2012, 04:52 am Last Edit: Nov 24, 2012, 04:56 am by m4ck Reason: 1
@PeterH and @retrolefty - thanks for your help. Really appreciate it.

With my school's ID, if I change:

byte inByte;

to

char inByte;

I get this sequence:

98-84-106-42-1011822-10-1086-84-74-74222286111150

Are these the byte separations you're referring to @PeterH? I have a feeling that this isn't ASCII now, however, as that didn't really help. Do you think you could tell me how to find out the number of characters per byte, or pass along any further ideas in decoding this? I would be very much appreciate your help!!

Thanks again.



Go Up