Go Down

Topic: Inerfacing with smart card (Read 4 times) previous topic - next topic

prodigyQB

Hi all,
I want to read the data of a smart card with arduino but it isn't as simple as i thought.
I have a smart card that I don't know of which type it is, so I discover that by sending a "answer to reset" command to the card I should get a 4 byte string that identify the card type. My problem now is how to get this code.

I've  plugged the card to arduino by following this image:

1. VCC (alimentation)
2. RST (remise à zéro)
3. CLK (horloge)
4. D+ (USB Inter-chip)
5. GND (masse)
6. SWP
7. I/O (entrée/sortie)
8. D- (USB Inter-chip)

I've plugged 1 with the 5v pin
2 with the 3 analog pin
3 with the 5 analog pin
5 with the GND pin
7 with the 4 analog pin

To send an ATR command you have to held the reset pin high, send one clock, relase the reset pin and then you can read the 4 byte data.
Here is shown well:

I've wrote this code:
Code: [Select]
#include <Wire.h>

int resetPin=3;
int clockPin=4;
int dataPint=5;

void clock(){
  analogWrite(clockPin, 1023);
  delay(70);
  analogWrite(clockPin, 0);
}

void setup(){
 
  Wire.begin();
  Serial.begin(9600);
  Wire.beginTransmission(0x00);

  analogWrite(resetPin, 1023);
  clock();
  analogWrite(resetPin,0);
  Serial.println(Wire.receive());
 
  Wire.endTransmission();
}

void loop(){}


Obviously it doesn't work... Any idea about how to do this operation? I can't find any reference on the internet...

Thanks

PaulS

Quote
so I discover that by sending a "answer to reset" command to the card I should get a 4 byte string that identify the card type.

Quote
To send an ATR command you have to held the reset pin high, send one clock, relase the reset pin and then you can read the 4 byte data.

Quote
1. VCC (alimentation)
2. RST (remise à zéro)
3. CLK (horloge)

Quote
I've plugged 1 with the 5v pin
2 with the 3 analog pin
3 with the 5 analog pin

To send the ATR command, you set the reset pin (#2 on the card) HIGH. Since you have connected the reset pin on the card to an analog pin, which is, by definition, input only, how did you "held the reset pin HIGH"?

Since you have connected the clock pin (#3 on the card), to an analog pin, which is, by definition, input only, how did you "send one clock"?

philicoe

Hi There,
There  are a few things you need to be aware of with smart cards:
1) Know if the card is just a memory chip or a proper microprocessor card.
2)Smartcards (SC's) have two protocols T0 and T1. The comms from the chip is different for both.
3)Checkout http://www.cardwerk.com/smartcards
4) the bottom two contacts (4 and 8) are not used = RFU
5) Some SC's work on lower voltages than 5v, so just be carefull not to pop the device.

philicoe

Sorry forgot also:
6) All SC's initial baud rate is 9600, then you can get the max baud rate available from the ATR.
7) Atr's are much longer than 4 bytes most of the time. like :
   00 31 C0 71 D6 65 13 0D 01 81 01 83 

prodigyQB

Thanks for the answers.

@PaulS
Quote
Since you have connected the clock pin (#3 on the card), to an analog pin, which is, by definition, input only, how did you "send one clock"?

That's my problem. Since I want to use the Wire lib to read the data (it makes things a lot easier), i had to plug the CLK line and the data line to analog pin #5 and #4. So I have no idea how to send one clock, i tried to do it in my code (see clock() function) but it doesn't work.
The problem with the Wire library is that it doesn't provide any support for a third line (the reset one trough which i need to send the ATR command) so i need to manually do the clock-thing...

@philicoe
Thanks for the infos!

Go Up