Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/carlosefr/magstripelib
Magnetic (swipe-type) card reader library for the Arduino.
https://github.com/carlosefr/magstripelib
arduino card-reader driver library
Last synced: about 1 month ago
JSON representation
Magnetic (swipe-type) card reader library for the Arduino.
- Host: GitHub
- URL: https://github.com/carlosefr/magstripelib
- Owner: carlosefr
- License: mit
- Created: 2014-05-11T21:37:37.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2020-08-05T16:08:18.000Z (over 4 years ago)
- Last Synced: 2023-08-07T05:11:04.252Z (over 1 year ago)
- Topics: arduino, card-reader, driver, library
- Language: C++
- Homepage:
- Size: 1.81 MB
- Stars: 27
- Watchers: 5
- Forks: 16
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
What is it?
===========**MagStripe** is an [Arduino](http://arduino.cc/) 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.![MagStripe-KDE.jpg](https://raw.githubusercontent.com/carlosefr/magstripelib/master/MagStripe-KDE.jpg)
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:* Ground (black wire)
* RDT/data
* RCL/clock
* CLS/card present
* Power/+5V (red wire)For more information, you can check the
[KDE KDR-1000 datasheet](https://github.com/carlosefr/magstripelib/blob/docs/docs/KDR1000.pdf) (pictured above),
which can read all three tracks by repositioning the head, or the
[Panasonic ZU-M1121 datasheet](https://github.com/carlosefr/magstripelib/blob/docs/docs/ZU-M1121S1.pdf) for an
example of another reader which can only read track 2 and has a different pin arrangement.**Note:** This library is designed for **swipe-type** readers (like the one pictured above) meaning it requires the CLS pin to be active _low_ while the card is being swiped and _high_ otherwise. **Insert-type** readers usually have the CLS pin connected to a switch instead (active _high_ when the card is fully inserted and _low_ otherwise). This behavior is not supported by this library. Check your reader's datasheet if you're not sure how your reader behaves.
Installation
============Download the latest zip file from the [releases](https://github.com/carlosefr/magstripelib/releases) section. Then open it from the `Sketch > Include Library > Add .ZIP Library...` menu inside the Arduino IDE and a new "MagStripe" entry should appear in the `Sketch > Include Library` and `File > Examples` menus.
![Arduino IDE](https://raw.githubusercontent.com/carlosefr/magstripelib/master/screenshot-01.png)
How it Works
============Connect your card reader to the following digital pins of the **Arduino Uno** (or other arduinos based on the
ATmega8/168/328 processors):Arduino Pin | Card Reader Pin
--------------|-----------------
Digital Pin 2 | RDT/data
Digital Pin 3 | RCL/clock
Digital Pin 4 | CLS/card presentThe **Arduino Leonardo** or **Arduino Micro** (or other arduinos based on the ATmega32U4 processor) have a diferent
interrupt pin assignment so, if you have one of these, connect the wires like this instead (swapped clock/data wires):Arduino Pin | Card Reader Pin
--------------|-----------------
Digital Pin 2 | RCL/clock
Digital Pin 3 | RDT/data
Digital Pin 4 | CLS/card presentIf 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](MagStripe.h) and is very straightforward to use, just check if there is a
card present before trying to read. The included [`MagStripeReader.ino`](examples/MagStripeReader/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](https://github.com/carlosefr/magstripelib/blob/docs/docs/layoutstd.pdf)
reference.