Pages: [1]   Go Down
Author Topic: Magstripe Reader Project  (Read 3614 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Jr. Member
**
Karma: 0
Posts: 58
No time to learn
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi  smiley,

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!
Logged

Offline Offline
God Member
*****
Karma: 7
Posts: 647
"In this house, we obey the Laws of Thermodynamics" Homer J. Simpson
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.

Logged

0
Offline Offline
Jr. Member
**
Karma: 0
Posts: 58
No time to learn
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
« Last Edit: August 22, 2012, 03:37:21 pm by BBX » Logged

Offline Offline
Jr. Member
**
Karma: 0
Posts: 89
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

0
Offline Offline
Jr. Member
**
Karma: 0
Posts: 58
No time to learn
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Cool, thanks  smiley
Logged

Norfolk UK
Offline Offline
Edison Member
*
Karma: 66
Posts: 2484
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

There is no such thing as a stupid question but there are a lot of inquisitive idiots.

Offline Offline
Jr. Member
**
Karma: 0
Posts: 89
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

0
Offline Offline
Jr. Member
**
Karma: 0
Posts: 58
No time to learn
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.

Logged

Chile
Offline Offline
Edison Member
*
Karma: 35
Posts: 1251
Arduino rocks?
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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 smiley
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.

Logged

My website: http://ried.cl

Offline Offline
Newbie
*
Karma: 0
Posts: 2
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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!!!
Logged

UK
Offline Offline
Shannon Member
****
Karma: 223
Posts: 12579
-
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

I only provide help via the forum - please do not contact me for private consultancy.

Left Coast, CA (USA)
Offline Offline
Brattain Member
*****
Karma: 361
Posts: 17263
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
« Last Edit: November 21, 2012, 08:10:57 pm by retrolefty » Logged

0
Offline Offline
Jr. Member
**
Karma: 0
Posts: 58
No time to learn
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Woah! I don't know why I haven't gotten an email about replies until now  smiley-sad

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 smiley
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 2
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

@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.


 
« Last Edit: November 23, 2012, 10:56:23 pm by m4ck » Logged

Pages: [1]   Go Up
Jump to: