How To Implement Magnetic Stripe Reader In Mobile App

JetRuby Agency
JetRuby Agency
Published in
3 min readFeb 15, 2016

For the past years this technology has become one of the fundamental ones in the economic and business areas. As long as your app is to work with credit, membership or discount cards, a magnetic stripe reader will be the key component in it.
Today we are going to demonstrate how magnetic stripe reading can be implemented in a mobile app. But before we proceed to the algorithm part, let’s look into the main features of this technology.

Overview

A magstripe consists of 3 physically separated “tracks”. Track 1 is the closest to the bottom of the card, and track 3 is the highest. Track 2 is the most commonly used track, but most credit cards also use track 1. Track 2 includes card numbers and expiration dates. Track 1 includes that plus names. There may be other data too, depending on the particular card. Essentially you take the card and put it next to a magnetic reader which then reads the fields.

Generally magstripes use F2F encoding, which determines whether something is a 1 or a 0 by looking at the change within a particular ‘phase’ (the time taken for one cycle). The time for a phase is identified by a series of 0’s at the beginning of each track. It is called “self-clocking” and allows readers to read cards that are pushed through by a human unlike the cases where the speed is fixed (e.g. a tape player).

Reader

This tiny adapter, as you have probably guessed, is the reading device.

Basically it consists of a magnetic read head, resistor, and a microphone connection. We can read the data from a card by plugging the reader into the headphones input and then recording the “sound” of a magnetic stripe. As a result will receive something like this:

Magnetic stripe reader: numbers recognition

For this purpose we used many different approaches and tried various data filtering methods. Ultimately, the adaptive peak detector turned to be the most effective one.

After the consequence of 0’s and 1’s is received, you just need to render it to a number and do LRC (longitudinal redundancy check).

A little less conversation, a little more action! Here is how our app works:

And in your opinion, in which area did the magnetic stripe reading technology prove to be the most effective? Be sure to leave a comment below and stay tuned.

Sign up to discover human stories that deepen your understanding of the world.

Published in JetRuby Agency

We believe sharing knowledge pushes the industry forward and creates communication bridges. Our technical expertise includes Agritech, Healthcare, and many more.

Written by JetRuby Agency

JetRuby is a Digital Agency that doesn’t stop moving. We expound on subjects as varied as developing a mobile app and through to disruptive technologies.

No responses yet

What are your thoughts?