Menu

Home

angus71


Discussion

1 2 > >> (Page 1 of 2)
  • angus71

    angus71 - 2012-01-20

    Welcome to the Smartcard Lib for Arduino compatible boards wiki.

    Currently this is a project I'm working on to learn more about the Ardunio programming and interfacing to external hardware.

    As it might be quite hard to setup a complete smart card reader for the Arduino from scratch, I just looked around and found a old settop box, which had a seperate module to interface with the smart card.

    All the documentation and data sheets I read, had a lot to say about high frequency and other effects, you can face if you use chips like the TDA 8204T to interface with a smart card.

    This library can be used to talk to a directly to the Arduino board connected smartcard or a smartcard connected via a TDA 8204T (or compatible).

    Per default the library behaves, like the smartcard is directly connected to the Ardunio board, as this is the default for the most people (The connection is described in the schematic attached to a post below).

    I that you actually don't need a TDA 8204T or any other chip to talk to a smart card, as you can connect the smart card directly to the I/O pins of the Arduino board, but with the interface chip it's just safer for my Arduino board and my smart cards.

    Setup

    As per release 0.0.4, the default behaviour is changed to a directly connected smartcard and the TDA 8204T interface needs to be activated via a define in the code.

    See the attached schematic, how the signals need to be connected to the Arduino board.

    Smartcard Arduino UNO
    C1(Vcc) D11
    C2(RST) D7
    C3(CLK) D9
    C4(AUX1) N.C.
    C5(GND) GND
    C6(Vpp) N.C
    C7(I/O) D10
    C8(AUX2) N.C.
    SWITCH D8

    Currently the C3(CLK) - D9 connection is hard coded, as I didn't found a way to get the timer associated with a pin and access the registers. The D9 pin is used to generate a clock signal for the smart card.

    To have defined values for the C3(RST) and C7(I/O) signales I used 100k pull-up resistors and a 100k pull-down resistor for the switch signaling that the smardcard is inserted into the smartcard slot

    If USE_DEBUG_PIN is enabled, which is by default, the D13 is used to signal changes in the internal state machines. Used to trigger my logic state analyser.

    It is also possible to minimize the binary size, by enable synchronous or asynchronous communication in the header file.

     

    Last edit: angus71 2012-07-22
    • Anistardi

      Anistardi - 2017-10-31

      Can you add T1 protocol?
      Microchip have an source code example (application note): http://ww1.microchip.com/downloads/en/AppNotes/01370A.pdf

       
  • angus71

    angus71 - 2012-02-07

    The easiest way to get to this information would be the article about smart cards in wikipedia. In the english version is a pin out given and with the provided table it should be possible to connect it directly to the arduino board (See attached schematic)

    Smart Card Arduino (Based on the above given table)
    C1 - VCC D11 (!CMDVCC) *
    C2 - RST D7 (RSTIN)
    C3 - CLK D9 (XTAL1)
    C4 - Not Connected
    C5 - GND GND
    C6 - VPP Not Connected
    C7 - I/O D10 (I/OUC)
    C8 - Not Connected

    * With the new release 0.0.4 this works right out of the box, as direct connection is the default.

     

    Last edit: angus71 2012-07-22
  • tavovalencia

    tavovalencia - 2013-01-21

    Hi Angus, I'm really very interested in this project!! Thanks

    I have a doubt. My SC Connection switch is always closed and opens when the card is inserted, thereby if I connect the switch in a pull-down, it thinks that there are no-card-inserted when there actually is. I modified my connection to pull-up resistor by connecting as follow:

    * SWITCH 1 to GND
    * SWITCH 2 to (between D8 and 1K resistor that goes to 5V).
    

    Now it tries to read the card every-time I insert a card. However, each time I have inserted a card the following pattern happens:

    * Waiting for Smartcard
    * Smartcard found
    * Unable to identify card ... Please remove
    

    Not really sure what I'm doing wrong!

     

    Last edit: tavovalencia 2013-01-21
    • angus71

      angus71 - 2013-01-21

      Hi tavovalencia,

      I think you should try a revision >= 20 from the trunk SCLib.h & SCLib.cpp as I added a feature to invert the card recognition (Parameter off_invert of the constructer set to true) after I've purchased a smartcard slot with the same switch behaviour as yours. That should do the trick, if go back to the pull down configuration.

      If you have further question just send me a mail.

       
      • tavovalencia

        tavovalencia - 2013-01-21

        Hi Angus,
        I don't know your email, so I'll continue with this thread.

        After I downloaded both files, I tried both ways with the pull-down (left on the attached image), It continuously said "waiting for Smartcard" (not recognizing it), and with pull-up (right on the attached image).

        It appears that the original circuit (on the left) can't work with my socket, not even with the new libraries, however, I kind of had a better result with the other schem:

        I started with the SCTest. -> The card was now found and the serial monitor showed:

        //Inserted CARD #1
        Smartcard found
        00|07 8E 07 8D '................'

        Waiting for Smartcard

        //After a couple of seconds repeats the same
        Smartcard found
        00|07 8E 07 8D '................'

        Waiting for Smartcard

        Smartcard found
        00|07 8E 07 8D '................'

        Waiting for Smartcard

        // Here I changed the cards (2nd)
        Smartcard found
        00|92 23 10 91 '.#..............'

        Waiting for Smartcard

        // Here I changed the cards (3rd)
        Smartcard found
        00|07 8E 07 8D '................'

        Waiting for Smartcard

        The good news is that three different smartcards were apparently recognized with 4-bytes each. But it kind of crashes after the 4th byte. I have to take the card out and re-enter it.

        When testing on the SCTest2 the thing is different. Once I entered the SC in the socket it read the card once and printed into serial monitor:

        Smartcard found
        Received ATR ...
        00|0C 02 0C 01 '................'
        SELECT FILE Command ...
        Received ... 0
        Waiting for Smartcard

        This happened VERY fast I tested this several times and after the "Waiting for Smartcard" print, I couldn't change the smartcard and have new readings without reseting the Arduino.

        I'm not sure but in both cases it seems like only the first 4 bytes are transmitted, then the program continues the loop without delays or without prompting anything... Is this right?

        PS> Link to Attached Image

         

        Last edit: tavovalencia 2013-01-21
        • angus71

          angus71 - 2013-01-22

          Hi tavovalencia,

          If the ATR's you receive are correct, they lead to the point that you are using synchronus cards, as they normaly only have a 4 byte ATR. .. Like SL4432/SL4442 or other memory cards, which can be found often as keycards in hotels, member cards etc.

          Do you have additional information regarding the type of the card? I think, if the cards you used are synchrous, everything worked fine and now the protocol implementation has to be done to support the card type you want to use.
          I'm currently implementin a SL4432/SL4442 support class, which provides all the features of this card type for easy usage.

          So to have your problems fixed I think i have to ask some questions ;-.)

          1. What kind of Arduino are you using?

          There might be a problem, when using a Arduino Mega compatible board as the CLK Pin has to be moved from Digital 9 to Digital 11 and the function of the Digital 11 (Vcc) can be moved to every other digital pin avaialable (The CLK pin is tied to the TIMER1A and the output pin of the timer was moved).

          1. Do you have more information regarding the type and protocol of the cards you want to use?

          The SCTest2 is only working with asynchrous cards of protocol type T=0, that's the reason, why you might get the "Received .. 0" as the APDU command format is not supported by all the synchronous cards I know :-(

          I will have a look into the problem of the need to reset the Arduino this condition, that should not happen and I will rename/comment the examples a little bit better to have them more intuitive.

          Can you please send me the answers via the "Send me a message" form on my users page or open a discussion in the genral discusion form, as I don't think tha communication through the wiki is a good idea ;-.)

          regards,

          Angus

           
          • Stellaras

            Stellaras - 2014-08-24

            Hi Angus, when you say "Arduino Mega compatible boards" those boards include only Arduino Mega AKD and 2560? or any board that uses the ATmega processor?
            For example in wiki (http://en.wikipedia.org/wiki/List_of_Arduino_boards_and_compatible_systems ) I see that Arduino Uno is listed under the arduino format even though it is using at atmega processor. Is that what you mean?

            I would like to apologize in advance for asking such a basic question. Thank you for your time and help.

             

            Last edit: Stellaras 2014-08-26
            • angus71

              angus71 - 2014-09-08

              Hi Stellaras,

              The only "processor" specific feature the code uses of an ATmega processor is the Timer feature, to create the clock for the smart card communication and that is more or less the only feature that limits the usage of this lib to the ATmega compatible boards, if the clock generation is exchanged with a mechanism available on a different platfrom, it should be portable to nearly any other platform ... (As long as the supporting features of the Arduino development environment are available or replaced with suiteble libs.)

              So if I unsderstood your question correctly, the anser is the ATMega processor is needed, due to the Timer feature. The Arduino UNO board might work, but there isn't much memory / flash left for your own code.

              With kind regards

              Angus

               
  • Prem

    Prem - 2013-02-21

    Hi Angus,
    I'm doing a work with SIM card, i want to copy the entire phonebook and message from one sim to another with arduino. Is it possible to use this library for the purpose?? how can i access and copy the phonebook and message location in the sim card?
    plz help me
    thank you :)

     
  • pedro

    pedro - 2013-11-26

    Oi amigos, pode me ajudar como faço para ler minha lista telefonica com arduino, o codigo fonte ja funciona mas agenda do sim card teria como ler?

     

    Last edit: pedro 2013-11-26
  • heringer

    heringer - 2015-03-14

    hello angun71.
    First I want to thank for his work on this lib Arduino, was very good to make the smart card reading. I wonder if you can make a sniffer smartcard with this lib if possivem is how you make an example.
    thank you.

     
    • angus71

      angus71 - 2015-03-18

      Hi Heringer,

      In principle this will work, but the lib won't be much of a help, as it was designed to provide a "Smart Card Reader" interface to the Arduino ..

      The effort needed might depend on your approach, to actually sniff the communication won't be hard and might be done with the low level "bit-reading" functions, but still a lot of modification will be needed to "convert" the SCLib into a "protocol decoder".

      An easier way might be to use a logic analyzer, as most of them have protocol decoders available .. I use a Open Logic Sniffer from dangerous prototypes (inexpensive compared to other devices, but limited in the sample time).

      A more interesting approach might be a "man-in-the-middle" setup, one side connected to the SmartCard the other side connected to the "original" Smart Card Reader, this would give you more options for debugging and testing, but this might be hard to be done with a classic "Arduino" based board ... A fair amount of multitasking is needed for this and this might be accomplished with a more "capable" hardware / OS ... The PRU of the "BeagleBoneBlack" might be a good starting point or any other Embedded board (Raspberry etc.)

      Regards

      Angus

       
  • Andon

    Andon - 2015-03-29

    Good day!

    I was poking around Futurlec and came across some smart cards, and of course wished to utilize them with Arduino. Did a quick search, and came across your wonderful little library here.

    However, I noted that neither of the cards on Futurlec (link: http://www.futurlec.com/Smart_Cards.shtml ) are listed in the supported cards list. I am curious if either of them would work, or if they could be made to work. I doubt the AT24C64 would work, given that it looks like it's a completely different thing, but I was hoping the SLE4428 could be made to work.

    Alternately, where would be a place that I could acquire a compatible card for a decent price?

     
    • angus71

      angus71 - 2015-04-09

      Hi Andon,

      Sorry for the late answer, but I was busy in the last weeks to to my "normal" job .. :-)

      It should not be a problem to make the SLE4428 work, as there is already a support class for the SLE44x2 cards. It had a "really" quick look on the data sheet for the SLE44x8 and they look quite similar, but some changes might be needed ... So it will not work right out of the box :-( but it is definitely possible.

      With the AT24C64 you are right, they might be "plugged" into the sclib, but this would be more of rewrite, maybe something for the future :-). These cards are accessed via a TWI (I2C) and it should be quite simple to access them via the appropriate Ardunio libraries.

      If you still are looking for compatible cards I would recommend SLE4442 (or compatible cards), they should be in the same price section, as the ones you found from Futurlec, but still they need to fit your project / security requirements (But they should work right out of the box).

      Regards

      Angus

       
  • adruha

    adruha - 2015-04-15

    Hi Angus! Can you tell me? How to reset the error the wrong password for the smart card SLE4442? After several attempts to write to the card I have wrong password, and now the card is locked. Perhaps you could add this feature to your library?

     

    Last edit: adruha 2015-04-15
  • Slobodan

    Slobodan - 2015-11-07

    Hi angus,
    I just salvaged card reader from my old tvbox TDA8024T and it has 12 lines on output in this order

    5VDA -------------- pin 6 Vddp ----------------(D11 ?)
    SCOCLK --------- pin 24 XTAIL1 ------------(D9 ?)
    GND --------------- pin 2 CLKDIV2
    SCODET --------- pin 23 OFF
    SCORST --------- NC
    SCOC8 ------------ pin 28 SCOC8
    SCOVCCEN ----- pin 19 CMDVCC
    D3V3 --------------- pin4 GND, pin10 PRESS, pin14 CGND, pin21 Vdd
    SCOOUT --------- pin 27 AUX1UC
    SCOIN ------------- pin 26 I/OUC
    5V/3V_SEL ------ pin 3 5V/3V
    GND -----------------

    So Im not sure how my pinout corespond to yours and what goes where on arduino
    Tnx for sharing your work, and tnx in advance for any advice, cheers

     

    Last edit: Slobodan 2015-11-08
    • angus71

      angus71 - 2015-11-10

      Hi Slobodan,

      So just let me summarize what I understood from your post.

      You have a TDA8024T from an old settop box, which has a "SmartCard" Slot on one side and an interface to the TDA8024T on the "other side", the place where you want to connect the "Arduino" to.

      The names you gave "5VDA", "SCOCLK" etc are the names of the pins given by the "old" SetTop Box SmartCard Slot and these pins are connected to the pins of the TDA8024.

      Based on the data sheet and the examples available I would recommend to connect the TDA8024T in the following way.

      PIN Arduino PIN
      5VDA 5V
      SCOCLK D9
      GND GND
      SCODET D8
      SCORST D7
      SCOVCCEN D11
      SCOIN D10
      SCOC8 n.c.
      SCOOUT n.c,
      5V/3V_SEL 5V or GND

      It's stange that SCORST is "NC", this is a quite important signal, as all communication starts with it. This should normally be connected to PIN20 of the TDA8024T. See also data sheet of TDA8024T.

      For the other signals it might be helpful to have a look into the data sheet, as in my case they have not been available to the outside and have been set to the approritate values. The SCOC8 and SCOOUT are only required, if your smartcard supports C4 and C8 pads, but currently they are not supported by the smart card lib.

      The 5V/3V_SEL depends on your smart card as this selects the voltage used for the smartcard communication (not the voltage used to communicate with the Arduino).

      Also important is to "uncomment" the line 63 in SCLib.h, otherwise the TDA8024 "inverted" Vcc handling is not activated.

      #define USE_TDA8204
      

      Let me know if this helps

      Angus

       

      Last edit: angus71 2015-11-10
  • Slobodan

    Slobodan - 2015-11-14

    Hi Angus,
    So you summarize is correct, it is just like u described, I was tired and misplaced things. In shor it works but only when card is inserted and 5V/3V_SEL is manualy connected from GND to 5V.
    Here i describe it in better way

    Card not inserted

    Waiting for Smartcard
    

    If I insert card it say

    Smartcard found
    Unable to identify card ... Please remove
    

    But if card is inserted and(arduino start) and I disconect 5V/3V_SEL from GND and connect to 5V it say

    Waiting for Smartcard
    Smartcard found
    00|05 E2 05 E1                                     '................'
    

    I doubly checked SCORST it is not connected to anything nither pin 20 of TDA8024T
    If diagram of my cardreader could help I could make one

    So should I place wire from pin 20 to SCORST. I guess that settop box readed card just like I now then did not used SCORST they just "power" it when they needed or just on start up :) If you have any sugestion that would be great

     

    Last edit: Slobodan 2015-11-14
  • Slobodan

    Slobodan - 2015-11-14

    TDA 8024T Card Reader !

    Board with traces

     

    Last edit: Slobodan 2015-11-15
  • Zlodeyz

    Zlodeyz - 2019-03-01

    Hi. I use your library. Prompt at me the card works only with StopBit = 2. How to fix your library under StopBit = 2? Thanks.

     
  • Paul Chen

    Paul Chen - 2019-06-27

    Great work! Thanks

     

    Last edit: Paul Chen 2019-06-28
  • Bhagy Tech

    Bhagy Tech - 2020-09-30

    Great Work!
    Me and our team trying to communicate arduino wth SLE4428! But we are not getting success. Post admin or anyone, please help us for the same!
    Thank You!!!

     

    Last edit: Bhagy Tech 2020-10-06
    • angus71

      angus71 - 2020-09-30

      Hi,

      It's a little bit hard to help you, without any additional infomation.

      • Is the "electrical" connection stable?
      • Did you check the eletrical signals?
      • Do you receive any data from the card. Do you have any output from the test program?

      With kind regards

       
      • Bhagy Tech

        Bhagy Tech - 2020-10-01

        Please check attached files.
        I am using same library files, which given on above download button. I tried some changes as per datasheet, but no success! :(

        • SLE4442 Card working perfect
        • SLE4428 not working, even not able to read any value
        • Tried to make changes in SLE4442's library, but still no output
        • Not able to read and write

        I need atlest 1KByte storage, i.e. need SLE4428 Card!!!

         

        Last edit: Bhagy Tech 2020-10-05
1 2 > >> (Page 1 of 2)

Log in to post a comment.