My favorites | Sign in
Project Home Downloads Wiki Issues Source
Project Information
Members
Featured
Downloads

What is it?

Mag Stripe is an Arduino library to interface with TTL (raw) magnetic card readers. It supports reading any of the cards' possible three tracks, but not simultaneously. Most cards only contain data on tracks 1 and 2 though.

Card Readers

There are many brands of TTL magnetic card readers on the market, some with a fixed reading head and others with screws allowing the head to be manually positioned to choose one of the tracks. The connector comes with varying colors for each wire, but usually there are five wires with the following order and function:

  1. Gnd (black wire)
  2. RDT/data
  3. RCL/clock
  4. CLS/card present
  5. +5V/Vcc (red wire)

For more information, you can check the KDE KDR-1000 datasheet (pictured above), which can read all three tracks by repositioning the head, or the Panasonic ZU-M1121 datasheet for an example of another reader which can only read track 2 and has a different pin arrangement.

Installation

Uncompress the ".zip" file into your "<arduino sketch folder>/libraries" folder (you may need to create it first). After restarting the Arduino IDE, it should appear in the libraries and examples menus.

How it Works

Connect your card reader to the following digital pins of the arduino:

  • Pin 2 - RDT/data
  • Pin 3 - RCL/clock
  • Pin 4 - CLS/card present

If your reader can read multiple tracks at a time, and thus has extra sets of data and clock wires, check its datasheet and use the ones appropriate for the track you want to read.

The library has a thin interface and is very straightforward to use, just check if there is a card present before trying to read. The included MagStripeReader.ino example shows how to do it.

The read() method does the necessary validation checks and only returns data if it has been read correctly from the card. The data returned is a string with the (ASCII) full contents of the track, including the control characters.

To know about the format of data returned for each track, check the magnetic card standards reference.

Downloads

Date Version Changes
2011-12-01 1.7 Updated for compatibility with Arduino 1.0.
2011-03-27 1.6 Memory usage reduced to a little over 100 bytes (1/8th as before). Allow changing the "card present" pin.
2010-10-08 1.5 Track 1 support. The "begin()" method now accepts the track number instead of the track format.
2010-10-05 1.1 Track 3 support. Bidirectional reading. LRC verification for increased reliability.
2010-10-03 1.0 Track 2 support. Initial public release.

Powered by Google Project Hosting