Portable Magnetic card Reader with Arduino???

Hello,

First of all, iam a student from the Netherlands so please forgive me for my bad English. Second of all, iam a total n00b in electronics, so also forgive me, if iam saying stupid things... ;)

Okay here we go. Iam doing a project for school in which i have to build a portable magnetic card reader, which can store the information of a magnetic swipe card. Later on the data stored on the device has to be converted to a computer into a file.

On the internet i found this instructable:

instructables.com/id/Arduino-magnetic-stripe-decoder/

A magnetic card reader is connected to an Arduino. The only problem is this device isn't portable.

Is it in any way possible to make the Arduino portable? Like this:

arduino.cc/playground/Learning/9VBatteryAdapter

So the data of the swiped card is stored on the Arduino's flashmemory and can be converted to a computer in a later stadium?

I don't want to spend the money of me and my projectgroup on an Arduino and a magnetic card reader if this isn't possible in any way.

I would really appreciate if somebody could give me an answer to my questions!

Thank you in advance!

Sander

Using an Arduino and read and store the data from a mag card reader is perfectly feasible, and well within it's capabilities.

However, making it portable may cause problems. The arduino can run off a 9v battery as you've seen, but the actual card reader its self may cause a problem. It's going to be down to the specifications of the reader - some work on 24V, others 12V etc, and they tend to need quite a bit of current, as such it may require quite a heavy duty battery rather than a standard PP3 9V one. It's not impossible, but you`ll have to hunt around and find a reader that makes it practical.

a portable magnetic card reader, which can store the information of a magnetic swipe card. Later on the data stored on the device has to be converted to a computer into a file.

Hmmm You don’t happen to work part time in a restaurant do you?

@ Programmer: Thanks for that! Powering the Cardreader seems to be the biggest problem. Any thoughts how to let the Arduino save the data on it's memory?

@Sparks: No, i don't. I hear this all the time, but i have nothing but good intentions. (Getting a good mark ;)). The device stays in school after it's build. :)

Anyone other thoughts how to do this?? Haven't worked with anything like this before....

Any thoughts how to let the Arduino save the data on it's memory?

This is actually pretty easy. You have 512 bytes available on the internal EEPROM. See the following for details on how to use it:

http://www.arduino.cc/en/Reference/EEPROM

Alternatively, you can use an external EEPROM which will give you much more storage space (and they are really cheap). Again, see the following for more details:

http://www.arduino.cc/playground/Main/InterfacingWithHardware#Storage

From a battery point of view, have a look at the battery packs for remote control cars etc, or maybe a mobile phone. Both tend to be fairly high current, but still fairly portable.

Do a bit of research, obviously there are portable card readers available, so read up on their specs and see what sort of battery capacity they have. Obviously its going to depend on your card reader though, and you may not have much choice available. New magnetic card readers tend to be fairly expensive, however you can usually pick up cheap ones from electronics surplus stores. Also try ebay, I recently managed to pick up 5 of them for £1 each, keep an eye out and you save a lot of money.

Have a browse round the net for more details about this type of project. Theres a load of info out there, and many different project write ups etc - all the info you`ll need is already out there, it's just a case of finding it and working out how to apply it to your specific application. It's not an overly complicated project though, and totally possible, so if you stick at it you should be able to build a good device.

Thanks that seems doable!

When searching for Magnetic card Readers, lots of them have 5.0V dc in their specs. Is this possible? And are you going to overcharge them with a 9V battery?

5V DC is good, they are likely to be lower current than the high voltage ones, so will be better for being battery powered.

You can't hook a 5V reader to a 9V supply directly, you`ll most likely damage it. You just need a voltage regulator, which will give you 5V from the 9V battery (eg 7805, very cheap). Alternatively, you could use 4 x 1.5 batteries to give you 6V instead of using a 9V battery, and this would give better battery life.

Instead of the EEPROM for storing the data, you could use an SD card. The card could then easily be removed, and read by the computer. It depends on how much data there is to be stored, and how frequently the data is to be stored.

@ Programmer: Is 6V enough to run the Arduino as well? So i only have to power the Arduino and don’t need a separate powersource for the magreader which is connected to the Arduino?

@ PaulS: How do i use a SD Card with the Arduino?? :slight_smile: Edit: Already found it, but i do not want to buy any extra hardware for the Arduino to make this possible.

I only have to save the data from 1 magcard when we run the project at school.

Here is the Arduino Credit Card Decode Code:

http://www.kingsdesign.com/wordpress/?p=60

What do i have to add to this code to let the Arduino save the data from the card to the EEPROM of the Arduino? :)

I found this:

http://arduino.cc/en/Reference/EEPROMRead

But where do i have to place it in the code? :o

Can someone with some experience with programming and the Arduino please help me with the code i have to load on the Arduino, to save the data from the magnetic card on the EEPROM? :)

Many thanks in advance! ;)

Can someone with some experience with programming and the Arduino please help me with the code i have to load on the Arduino, to save the data from the magnetic card on the EEPROM?

Isn't that one of the requirements of your project, to research and learn? ;)

Lefty

Well the project doesn't say anything about using the Arduino. I just brought that up myself. It's difficult to understand, and after this project i will most likely never use an Arduino again.

I don't ask to completely write the code for me, but some assistance from people who use the Arduino on a more common base would be really appreciated! ;)

I already found the code to directly read the data on the computer:

http://www.kingsdesign.com/wordpress/?p=60

I also found how to write data to the EEPROM:

http://arduino.cc/en/Reference/EEPROMRead

Iam just having difficulties to combine them. :(

Hello, I want to know if somebody can make a schematic and the source code for a magnetic card reader wich one can reads interrupted swipes in both directions and the PCB to be verry small like 5-7mm W,15mm L .I have small magnetic head wich one read all 3 tracks.I need just the schematic,source code and the software to read data,erase and set clock.I will pay for this proiect depends how much u want. Thanks!!

Here is the Arduino Credit Card Decode Code:

http://www.kingsdesign.com/wordpress/?p=60

What do i have to add to this code to let the Arduino save the data from the card to the EEPROM of the Arduino? Smiley

I found this:

http://arduino.cc/en/Reference/EEPROMRead

But where do i have to place it in the code? Shocked

Sure is looking like the subject should be "How to make a Credit Card Skimmer with the Arduino".

Interesting school project. I wonder what the educational goal was?

I already explained to you. Believe me or not.....

And the subject is not: How to make a Credit Card Skimmer with the Arduino, but it is How to make a "Portable Magnetic card reader".

I came up with the Arduino myself. And yes, i agree it's kind of a special project for people who dont study electronics or something like that. But we have to think outside the box. And it should be doable for everyone with parts available for everyone. But iam thinking it's rather difficult to do.... But i still hope someone could give me a hint to make to code work to write the data to the EEPROM. Thanks!

sounds like a great project

It is :slight_smile:

OK, we have ordered every part we need. Soldering is easy, so were are up to the code now :slight_smile:

This is the Magnetic stripe reader decoder code by Stephan King.

/*
 * Magnetic Stripe Reader
 * by Stephan King http://www.kingsdesign.com
 *
 * Reads a magnetic stripe.
 *
 */
 
int cld1Pin = 5;            // Card status pin
int rdtPin = 2;             // Data pin
int reading = 0;            // Reading status
volatile int buffer[400];   // Buffer for data
volatile int i = 0;         // Buffer counter
volatile int bit = 0;       // global bit
char cardData[40];          // holds card info
int charCount = 0;          // counter for info
int DEBUG = 0;
 
void setup() {
  Serial.begin(9600); 
 
  // The interrupts are key to reliable
  // reading of the clock and data feed
  attachInterrupt(0, changeBit, CHANGE);
  attachInterrupt(1, writeBit, FALLING);
}
 
void loop(){
 
  // Active when card present
  while(digitalRead(cld1Pin) == LOW){
    reading = 1;
  }     
 
  // Active when read is complete
  // Reset the buffer
  if(reading == 1) {  
 
    if (DEBUG == 1) {
      printBuffer();
    }
 
    decode();
    reading = 0;
    i = 0;
 
    int l;
    for (l = 0; l < 40; l = l + 1) {
      cardData[l] = '\n';
    }
 
    charCount = 0;
  }
}
 
// Flips the global bit
void changeBit(){
  if (bit == 0) {
    bit = 1;
  } else {
    bit = 0;
  }
}
 
// Writes the bit to the buffer
void writeBit(){
  buffer[i] = bit;
  i++;
}
 
// prints the buffer
void printBuffer(){
  int j;
  for (j = 0; j < 200; j = j + 1) {
    Serial.println(buffer[j]);
  }
}
 
int getStartSentinal(){
  int j;
  int queue[5];
  int sentinal = 0;
 
  for (j = 0; j < 400; j = j + 1) {
    queue[4] = queue[3];
    queue[3] = queue[2];
    queue[2] = queue[1];
    queue[1] = queue[0];
    queue[0] = buffer[j];
 
    if (DEBUG == 1) {
      Serial.print(queue[0]);
      Serial.print(queue[1]);
      Serial.print(queue[2]);
      Serial.print(queue[3]);
      Serial.println(queue[4]);
    }
 
    if (queue[0] == 0 & queue[1] == 1 & queue[2] == 0 & queue[3] == 1 & queue[4] == 1) {
      sentinal = j - 4;
      break;
    }
  }
 
  if (DEBUG == 1) {
    Serial.print("sentinal:");
    Serial.println(sentinal);
    Serial.println("");
  }
 
  return sentinal;
}
 
void decode() {
  int sentinal = getStartSentinal();
  int j;
  int i = 0;
  int k = 0;
  int thisByte[5];
 
  for (j = sentinal; j < 400 - sentinal; j = j + 1) {
    thisByte[i] = buffer[j];
    i++;
    if (i % 5 == 0) {
      i = 0;
      if (thisByte[0] == 0 & thisByte[1] == 0 & thisByte[2] == 0 & thisByte[3] == 0 & thisByte[4] == 0) {
        break;
      }
      printMyByte(thisByte);
    }
  }
 
  Serial.print("Stripe_Data:");
  for (k = 0; k < charCount; k = k + 1) {
    Serial.print(cardData[k]);
  }
  Serial.println("");
 
}
 
void printMyByte(int thisByte[]) {
  int i;
  for (i = 0; i < 5; i = i + 1) {
    if (DEBUG == 1) {
      Serial.print(thisByte[i]);
    }
}
    if (DEBUG == 1) {
      Serial.print("\t");
      Serial.print(decodeByte(thisByte));
      Serial.println("");
    }
 
    cardData[charCount] = decodeByte(thisByte);
    charCount ++;
}
 
char decodeByte(int thisByte[]) {
    if (thisByte[0] == 0 & thisByte[1] == 0 & thisByte[2] == 0 & thisByte[3] == 0 & thisByte[4] == 1){
      return '0';
    }
    if (thisByte[0] == 1 & thisByte[1] == 0 & thisByte[2] == 0 & thisByte[3] == 0 & thisByte[4] == 0){
      return '1';
    }
 
    if (thisByte[0] == 0 & thisByte[1] == 1 & thisByte[2] == 0 & thisByte[3] == 0 & thisByte[4] == 0){
      return '2';
    }
 
    if (thisByte[0] == 1 & thisByte[1] == 1 & thisByte[2] == 0 & thisByte[3] == 0 & thisByte[4] == 1){
      return '3';
    }
 
    if (thisByte[0] == 0 & thisByte[1] == 0 & thisByte[2] == 1 & thisByte[3] == 0 & thisByte[4] == 0){
      return '4';
    }
 
    if (thisByte[0] == 1 & thisByte[1] == 0 & thisByte[2] == 1 & thisByte[3] == 0 & thisByte[4] == 1){
      return '5';
    }
 
    if (thisByte[0] == 0 & thisByte[1] == 1 & thisByte[2] == 1 & thisByte[3] == 0 & thisByte[4] == 1){
      return '6';
    }
 
    if (thisByte[0] == 1 & thisByte[1] == 1 & thisByte[2] == 1 & thisByte[3] == 0 & thisByte[4] == 0){
      return '7';
    }
 
    if (thisByte[0] == 0 & thisByte[1] == 0 & thisByte[2] == 0 & thisByte[3] == 1 & thisByte[4] == 0){
      return '8';
    }
 
    if (thisByte[0] == 1 & thisByte[1] == 0 & thisByte[2] == 0 & thisByte[3] == 1 & thisByte[4] == 1){
      return '9';
    }
 
    if (thisByte[0] == 0 & thisByte[1] == 1 & thisByte[2] == 0 & thisByte[3] == 1 & thisByte[4] == 1){
      return ':';
    }
 
    if (thisByte[0] == 1 & thisByte[1] == 1 & thisByte[2] == 0 & thisByte[3] == 1 & thisByte[4] == 0){
      return ';';
    }
 
    if (thisByte[0] == 0 & thisByte[1] == 0 & thisByte[2] == 1 & thisByte[3] == 1 & thisByte[4] == 1){
      return '<';
    }
 
    if (thisByte[0] == 1 & thisByte[1] == 0 & thisByte[2] == 1 & thisByte[3] == 1 & thisByte[4] == 0){
      return '=';
    }
 
    if (thisByte[0] == 0 & thisByte[1] == 1 & thisByte[2] == 1 & thisByte[3] == 1 & thisByte[4] == 0){
      return '>';
    }
 
    if (thisByte[0] == 1 & thisByte[1] == 1 & thisByte[2] == 1 & thisByte[3] == 1 & thisByte[4] == 1){
      return '?';
    }
}

I have to add this code somewere in the code above to save the data from the magnetic card on the EEPROM of the arduino.

#include <EEPROM.h>

void setup()
{
  for (int i = 0; i < 512; i++)
    EEPROM.write(i, i);
}

void loop()
{
}

Were do i have to put it? All at the end of the code, or after the first part were the data from the card is read? Or even somewere else? Do i have to change to code in any way? Or can i put it in as it is?

Thanks in advance! :wink:

@sander: this thread is a prime example of what is wrong with education in the Netherlands right now. Instead of actually putting in the time to research how to program an Arduino, all you're doing is trying to copy/paste code together to make it work with as little effort as you can. People in this thread have been very helpful, and yet you keep asking them questions in the hopes that they will take as much work out of your hands as possible. If you could get someone to come over to your house and put the thing together for you, you probably would.

This is exactly the reverse of the attitude you should be having. Why the hell are you even in school? Is it just to get some sort of degree because everybody says you should get one? Did you like vidya games as a kid so you decided to get a degree in 'something with computers'? Take it from someone who has real-world experience both in academia and industry: nobody is looking for your kind of people. Academia doesn't want you because apparently you don't like to do any work, let alone research independently, and industry doesn't want you because you obviously don't care about learning new things. So why not just become a baker or something? It's an honerable job, you get to work with your hands, and you don't even have to learn to program Arduinos.

It sickens me that tax payers money is wasted on giving free education to people that have absolutely zero passion for their subject, and just want to get the grade as easily as possible so that they can go back to playing wow or tf2. I know people will think I'm harsh on you, but I dont care, you really need a kick in the balls. Figure it out for yourself. Read the bloody manual.